Coverage for nova/virt/zvm/guest.py: 0%
18 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
1# Copyright 2017,2018 IBM Corp.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
15from oslo_log import log as logging
17from nova.compute import power_state as compute_power_state
18from nova import conf
19from nova.virt import hardware
22LOG = logging.getLogger(__name__)
23CONF = conf.CONF
26ZVM_POWER_STATE = {
27 'on': compute_power_state.RUNNING,
28 'off': compute_power_state.SHUTDOWN,
29 }
32class Guest(object):
33 """z/VM implementation of ComputeDriver."""
35 def __init__(self, hypervisor, instance, virtapi=None):
36 super(Guest, self).__init__()
38 self.virtapi = virtapi
39 self._hypervisor = hypervisor
40 self._instance = instance
42 def _mapping_power_state(self, power_state):
43 """Translate power state to OpenStack defined constants."""
44 return ZVM_POWER_STATE.get(power_state, compute_power_state.NOSTATE)
46 def get_info(self):
47 """Get the current status of an instance."""
48 power_state = self._mapping_power_state(
49 self._hypervisor.guest_get_power_state(
50 self._instance.name))
51 return hardware.InstanceInfo(power_state)