Merge "Remove unused InstanceInfo class"

This commit is contained in:
Zuul 2018-07-23 13:34:04 +00:00 committed by Gerrit Code Review
commit 87e7517cc2
1 changed files with 0 additions and 74 deletions

View File

@ -151,80 +151,6 @@ def _translate_vm_state(pvm_state):
return nova_state
class InstanceInfo(hardware.InstanceInfo):
"""Instance Information
This object tries to lazy load the attributes since the compute
manager retrieves it a lot just to check the status and doesn't need
all the attributes.
:param adapter: pypowervm adapter
:param name: instance name
:param uuid: powervm uuid
"""
def __init__(self, adapter, name, uuid):
self._adapter = adapter
self._name = name
self._uuid = uuid
self._state = None
self._mem_kb = None
self._max_mem_kb = None
self._num_cpu = None
# Non-lazy loaded properties
self.cpu_time_ns = 0
# Todo(IBM) Should this be the instance UUID vs PowerVM?
self.id = uuid
def _get_property(self, q_prop):
return get_vm_qp(self._adapter, self._uuid, q_prop)
@property
def state(self):
# return the state if we previously loaded it
if self._state is not None:
return self._state
# otherwise, fetch the value now
pvm_state = self._get_property('PartitionState')
self._state = _translate_vm_state(pvm_state)
return self._state
@property
def mem_kb(self):
# return the memory if we previously loaded it
if self._mem_kb is not None:
return self._mem_kb
# otherwise, fetch the value now
pvm_mem_kb = self._get_property('CurrentMemory')
self._mem_kb = pvm_mem_kb
return self._mem_kb
@property
def max_mem_kb(self):
# return the max memory if we previously loaded it
if self._max_mem_kb is not None:
return self._max_mem_kb
# TODO(IBM) max isn't a quick property. We need the wrapper
return self.mem_kb()
@property
def num_cpu(self):
# return the number of cpus if we previously loaded it
if self._num_cpu is not None:
return self._num_cpu
# otherwise, fetch the value now
pvm_num_cpu = self._get_property('AllocatedVirtualProcessors')
self._num_cpu = pvm_num_cpu
return self._num_cpu
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self._uuid == other._uuid)
class VMBuilder(object):
"""Converts a Nova Instance/Flavor into a pypowervm LPARBuilder."""