BUG FIX: Collect correct hardware resource information
- update version of rsd-lib - update requirements - update unit tests Change-Id: I94a78457f217a427431f834a5dc7c99eb20884da Signed-off-by: Helena McGough <helena.mcgough@intel.com>
This commit is contained in:
parent
cb6f9fae17
commit
bbc9417e83
@ -2,5 +2,4 @@
|
||||
templates:
|
||||
- openstack-python-jobs
|
||||
- openstack-python36-jobs
|
||||
- check-requirements
|
||||
- openstack-cover-jobs
|
||||
|
@ -8,4 +8,5 @@ oslo.log>=3.36.0 # Apache-2.0
|
||||
oslo.config>=5.2.0 # Apache-2.0
|
||||
jsonschema<3.0.0,>=2.6.0 # MIT
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
rsd-lib<=0.3.1
|
||||
rsd-lib>=1.0.0
|
||||
nova<=19.0.0
|
||||
|
@ -45,8 +45,7 @@ import rsd_lib
|
||||
from rsd_lib.resources.v2_1.chassis import chassis
|
||||
from rsd_lib.resources.v2_2.system import system
|
||||
|
||||
from rsd_lib.resources.v2_3.node import node
|
||||
from rsd_lib.resources.v2_3.node import node as v2_3_node
|
||||
from rsd_lib.resources.v2_3 import node as v2_3_node
|
||||
|
||||
from sushy import connector
|
||||
|
||||
@ -54,14 +53,14 @@ from sushy import connector
|
||||
class FakeInstance(object):
|
||||
"""A class to fake out nova instances."""
|
||||
|
||||
def __init__(self, name, state, uuid, new_flavor, node):
|
||||
def __init__(self, name, state, uuid, new_flavor, new_node):
|
||||
"""Initialize the variables for fake instances."""
|
||||
self.name = name
|
||||
self.power_state = state
|
||||
self.uuid = uuid
|
||||
self.display_description = None
|
||||
self.flavor = new_flavor
|
||||
self.node = node
|
||||
self.node = new_node
|
||||
|
||||
def __getitem__(self, key):
|
||||
"""Method to retrieve fake instance variables."""
|
||||
@ -133,14 +132,14 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
'r') as f:
|
||||
self.root_conn.get.return_value.json.return_value = json.loads(
|
||||
f.read())
|
||||
self.node_collection = node.NodeCollection(
|
||||
self.node_collection = v2_3_node.NodeCollection(
|
||||
self.root_conn, '/redfish/v1/Nodes', redfish_version='1.0.2')
|
||||
|
||||
with open('rsd_virt_for_nova/tests/json_samples/node.json',
|
||||
'r') as f:
|
||||
self.root_conn.get.return_value.json.return_value = json.loads(
|
||||
f.read())
|
||||
self.node_inst = node.Node(
|
||||
self.node_inst = v2_3_node.Node(
|
||||
self.root_conn, '/redfish/v1/Nodes/Node1',
|
||||
redfish_version='1.0.2')
|
||||
|
||||
@ -148,7 +147,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
'r') as f:
|
||||
self.root_conn.get.return_value.json.return_value = json.loads(
|
||||
f.read())
|
||||
self.node_ass_inst = node.Node(
|
||||
self.node_ass_inst = v2_3_node.Node(
|
||||
self.root_conn, '/redfish/v1/Nodes/Node1',
|
||||
redfish_version='1.0.2')
|
||||
|
||||
@ -172,9 +171,9 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
self.RSD = driver.RSDDriver(fake.FakeVirtAPI())
|
||||
|
||||
# Create Fake flavors and instances
|
||||
gb = self.system_inst.memory_summary.size_gib
|
||||
gb = self.system_inst.memory_summary.total_system_memory_gib
|
||||
mem = self.RSD.conv_GiB_to_MiB(gb)
|
||||
proc = self.system_inst.processors.summary.count
|
||||
proc = self.system_inst.json['ProcessorSummary']['Count']
|
||||
flav_id = str(mem) + 'MB-' + str(proc) + 'vcpus'
|
||||
res = fields.ResourceClass.normalize_name(self.system_inst.identity)
|
||||
spec = 'resources:' + res
|
||||
@ -242,10 +241,11 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
def test_get_info_valid(self, info):
|
||||
"""Test getting information for a valid instance."""
|
||||
# Run test
|
||||
self.RSD.get_info(self.inst1)
|
||||
hw_info = self.RSD.get_info(self.inst1)
|
||||
|
||||
# Confirm that the correct hardware info os collected
|
||||
info.assert_called_once_with(state=self.inst1.power_state)
|
||||
self.assertEquals(hw_info, info.return_value)
|
||||
|
||||
@mock.patch.object(hardware, 'InstanceInfo')
|
||||
def test_get_info_invalid(self, info):
|
||||
@ -256,22 +256,26 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
|
||||
info.assert_not_called()
|
||||
|
||||
def test_get_available_nodes_false_refresh(self):
|
||||
@mock.patch.object(driver.RSDDriver, '_init_nodes')
|
||||
def test_get_available_nodes_false_refresh(self, init_nodes):
|
||||
"""Test getting a list of the available nodes, no refresh."""
|
||||
# Run test checking the list of available nodes
|
||||
nodes = self.RSD.get_available_nodes(refresh=False)
|
||||
|
||||
# Confirm that the correst functions are called and all of the correct
|
||||
# nodes are available
|
||||
init_nodes.assert_called_once()
|
||||
self.assertEqual(nodes, self.RSD._nodes)
|
||||
|
||||
def test_get_available_nodes_true_refresh(self):
|
||||
@mock.patch.object(driver.RSDDriver, '_init_nodes')
|
||||
def test_get_available_nodes_true_refresh(self, init_nodes):
|
||||
"""Test getting a list of the available nodes, with refresh."""
|
||||
# Run test checking the list of available nodes, refresh
|
||||
nodes = self.RSD.get_available_nodes(refresh=True)
|
||||
|
||||
# Confirm that the correst functions are called and all of the correct
|
||||
# nodes are available
|
||||
init_nodes.assert_called_once()
|
||||
self.assertEqual(nodes, self.RSD._nodes)
|
||||
|
||||
@mock.patch.object(driver.RSDDriver, 'get_available_nodes')
|
||||
@ -282,7 +286,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
|
||||
# Confirm the correct functions are called and confirm that the
|
||||
# node being checked is not available
|
||||
getNodes.assert_called()
|
||||
getNodes.assert_called_with(refresh=True)
|
||||
self.assertEqual(self.RSD.instance_node, None)
|
||||
self.assertEqual(avail, False)
|
||||
|
||||
@ -316,13 +320,13 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
node_col = self.RSD.driver.PODM.get_node_collection.return_value
|
||||
node_col.members_identities = ['/redfish/v1/Nodes/Node1']
|
||||
self.RSD.driver.PODM.get_node.return_value = self.node_ass_inst
|
||||
node = self.RSD.driver.PODM.get_node.return_value
|
||||
mock_context = context.get_admin_context()
|
||||
self.RSD.rsd_flavors = {
|
||||
self.flavor.flavorid: {
|
||||
'id': 'flav_id',
|
||||
'rsd_systems': {
|
||||
'/redfish/v1/Chassis/Chassis1':
|
||||
self.system_inst.identity
|
||||
self.system_inst.path
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,8 +340,24 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
self.RSD.driver.PODM.get_node_collection.assert_called_once()
|
||||
self.RSD.driver.PODM.get_node.assert_called_with(
|
||||
'/redfish/v1/Nodes/Node1')
|
||||
self.assertEquals(node.composed_node_state.lower(), 'assembled')
|
||||
self.assertEquals(node.power_state.lower(), 'off')
|
||||
self.assertEquals(self.inst1.display_description,
|
||||
json.dumps({"node_identity": "/redfish/v1/Nodes/Node1",
|
||||
"node_uuid": node.uuid}))
|
||||
power_on.assert_called_once_with(mock_context, self.inst1, None)
|
||||
|
||||
@mock.patch.object(driver.RSDDriver, 'power_on')
|
||||
def test_spawn_failure(self, power_on):
|
||||
"""Test spawning an instance failure."""
|
||||
mock_context = context.get_admin_context()
|
||||
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
||||
# Run spawning test
|
||||
self.assertRaises(
|
||||
Exception, self.RSD.spawn, mock_context, self.inst1,
|
||||
image_meta, [], None, {})
|
||||
power_on.assert_not_called()
|
||||
|
||||
@mock.patch.object(v2_3_node, 'Node', autospec=True)
|
||||
def test_destroy_success(self, mock_node):
|
||||
"""Test destroying an instance and deleting the composed node."""
|
||||
@ -351,6 +371,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
self.RSD.destroy("context", self.inst1, network_info=None)
|
||||
|
||||
# Confirm that the instance has been delete from the list of instances
|
||||
self.assertIn(self.inst1.uuid, self.RSD._composed_nodes)
|
||||
mock_node.delete_node.assert_called_once()
|
||||
node_collection.assert_called_once()
|
||||
node_collection.return_value.compose_node.assert_called_once()
|
||||
@ -370,6 +391,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
|
||||
# Confirm that the instance failed to delete and a new node was not
|
||||
# created to replace it
|
||||
self.assertNotIn(self.inst1.uuid, self.RSD._composed_nodes)
|
||||
mock_node.delete_node.assert_not_called()
|
||||
self.RSD.driver.PODM.get_node_collection.assert_not_called()
|
||||
node_collection.return_value.compose_node.assert_not_called()
|
||||
@ -391,6 +413,8 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
self.RSD._nodes = [chas_str]
|
||||
sys_col = self.RSD.driver.PODM.get_system_collection.return_value
|
||||
chas_col = self.RSD.driver.PODM.get_chassis_collection.return_value
|
||||
|
||||
# Run test
|
||||
resources = self.RSD.get_available_resource(chas_str)
|
||||
|
||||
# Perform checks on all methods called on a successful run
|
||||
@ -418,6 +442,34 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
'vcpus': proc_info.return_value,
|
||||
'vcpus_used': 0}, resources)
|
||||
|
||||
@mock.patch.object(driver.RSDDriver, '_create_flavors')
|
||||
@mock.patch.object(driver.RSDDriver, 'check_flavors')
|
||||
@mock.patch.object(driver.RSDDriver, 'check_chassis_systems')
|
||||
@mock.patch.object(versionutils, 'convert_version_to_int')
|
||||
@mock.patch.object(driver.RSDDriver, 'get_sys_proc_info')
|
||||
@mock.patch.object(driver.RSDDriver, 'get_sys_memory_info')
|
||||
def test_get_available_resource_failure(self, mem_info, proc_info, conv_v,
|
||||
check_chas, check_flav,
|
||||
create_flav):
|
||||
"""Test failure to get available resources for a node."""
|
||||
# Mock out required variables
|
||||
chas_col = self.RSD.driver.PODM.get_chassis_collection.return_value
|
||||
|
||||
# Run test
|
||||
resources = self.RSD.get_available_resource('/invalid/mock/node')
|
||||
|
||||
# Confirm none of the functionality is called
|
||||
self.RSD.driver.PODM.get_chassis_collection.assert_not_called()
|
||||
self.RSD.driver.PODM.get_system_collection.assert_not_called()
|
||||
chas_col.get_member.assert_not_called()
|
||||
check_chas.assert_not_called()
|
||||
check_flav.assert_not_called()
|
||||
create_flav.assert_not_called()
|
||||
mem_info.assert_not_called()
|
||||
proc_info.assert_not_called()
|
||||
conv_v.assert_not_called()
|
||||
self.assertEqual({}, resources)
|
||||
|
||||
@mock.patch.object(driver.RSDDriver, 'create_child_inventory')
|
||||
@mock.patch.object(driver.RSDDriver, 'create_inventory')
|
||||
@mock.patch.object(driver.RSDDriver, 'check_chassis_systems')
|
||||
@ -485,13 +537,17 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
"""Test succeeding in getting sys_proc info."""
|
||||
# Set up for a successful test for getting system processor information
|
||||
sys_col = self.RSD.driver.PODM.get_system_collection.return_value
|
||||
sys_col.get_member.return_value = self.system_inst
|
||||
self.RSD.driver.composed_nodes = {
|
||||
self.node_inst.links.computer_system: self.node_inst.identity}
|
||||
cpus = self.RSD.get_sys_proc_info(['/redfish/v1/Systems/System1'])
|
||||
|
||||
# Confirm that the relavant functions fail when called
|
||||
# And correct proccessor information is calculated
|
||||
self.RSD.driver.PODM.get_system_collection.assert_called_once()
|
||||
sys_col.get_member.assert_called_with('/redfish/v1/Systems/System1')
|
||||
self.assertEqual(cpus, self.system_inst.processors.summary.count)
|
||||
self.assertEqual(cpus,
|
||||
self.system_inst.json['ProcessorSummary']['Count'])
|
||||
|
||||
@mock.patch.object(driver.RSDDriver, 'conv_GiB_to_MiB')
|
||||
def test_get_sys_memory_info_failure(self, conv_mem):
|
||||
@ -514,19 +570,20 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
sys_col.members_identities = ['/redfish/v1/Systems/System1']
|
||||
sys_col.get_member.return_value = self.system_inst
|
||||
self.RSD.driver.composed_nodes = {
|
||||
self.node_inst.system.identity: self.node_inst.identity}
|
||||
self.node_inst.links.computer_system: self.node_inst.identity}
|
||||
# Run the test and get the result
|
||||
mem_mb = self.RSD.get_sys_memory_info(['/redfish/v1/Systems/System1'])
|
||||
|
||||
total_sys_mem = self.system_inst.memory_summary.total_system_memory_gib
|
||||
# Confirm that the relavant functions fail when called
|
||||
self.RSD.driver.PODM.get_system_collection.assert_called_once()
|
||||
sys_col.get_member.assert_called_once_with(
|
||||
'/redfish/v1/Systems/System1')
|
||||
conv_mem.assert_called_with(self.system_inst.memory_summary.size_gib)
|
||||
conv_mem.assert_called_with(total_sys_mem)
|
||||
# Confirm the result is as to be expected
|
||||
self.assertEqual(
|
||||
mem_mb,
|
||||
conv_mem(self.system_inst.memory_summary.size_gib).__radd__())
|
||||
conv_mem(total_sys_mem).__radd__())
|
||||
|
||||
def test_conv_GiB_to_MiB(self):
|
||||
"""Test the conversion of GiB to MiB."""
|
||||
@ -558,7 +615,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
|
||||
# Confirm that the composed node instance is in the shutdown state
|
||||
self.assertEqual(self.inst1.power_state, power_state.SHUTDOWN)
|
||||
mock_node.reset_node.assert_called_once_with('graceful shutdown')
|
||||
mock_node.reset_node.assert_called_once_with('GracefulShutdown')
|
||||
|
||||
@mock.patch.object(v2_3_node, 'Node', autospec=True)
|
||||
def test_invalid_power_on(self, mock_node):
|
||||
@ -580,7 +637,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
|
||||
# Confirm that the composed node instance is in the running state
|
||||
self.assertEqual(self.inst1.power_state, power_state.RUNNING)
|
||||
mock_node.reset_node.assert_called_once_with('force on')
|
||||
mock_node.reset_node.assert_called_once_with('On')
|
||||
|
||||
@mock.patch.object(v2_3_node, 'Node', autospec=True)
|
||||
def test_invalid_reboot(self, mock_node):
|
||||
@ -602,7 +659,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
self.RSD.reboot(mock.MagicMock(), self.inst1, 'network_info', 'HARD')
|
||||
|
||||
# Confirm the correct reset action is called
|
||||
mock_node.reset_node.assert_called_with('force restart')
|
||||
mock_node.reset_node.assert_called_with('ForceRestart')
|
||||
|
||||
@mock.patch.object(v2_3_node, 'Node', autospec=True)
|
||||
def test_valid_soft_reboot(self, mock_node):
|
||||
@ -614,17 +671,19 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
self.RSD.reboot(mock.MagicMock(), self.inst1, 'network_info', 'SOFT')
|
||||
|
||||
# Confirm the correct reset action is called
|
||||
mock_node.reset_node.assert_called_with('graceful restart')
|
||||
mock_node.reset_node.assert_called_with('GracefulRestart')
|
||||
|
||||
@mock.patch.object(driver.RSDDriver, 'conv_GiB_to_MiB')
|
||||
@mock.patch.object(driver.RSDDriver, 'get_sys_memory_info')
|
||||
@mock.patch.object(driver.RSDDriver, 'get_sys_proc_info')
|
||||
def test_create_inventory_success(self, sys_proc_info, sys_mem_info,
|
||||
conv_mem):
|
||||
def test_create_inventory(self, sys_proc_info, sys_mem_info,
|
||||
conv_mem):
|
||||
"""Test creating a inventory for a provider tree."""
|
||||
# Setup test to successfully create inventory
|
||||
sys_mem_info.return_value = self.system_inst.memory_summary.size_gib
|
||||
sys_proc_info.return_value = self.system_inst.processors.summary.count
|
||||
sys_mem_info.return_value = \
|
||||
self.system_inst.memory_summary.total_system_memory_gib
|
||||
sys_proc_info.return_value = \
|
||||
self.system_inst.json['ProcessorSummary']['Count']
|
||||
inv = self.RSD.create_inventory([self.system_inst.identity])
|
||||
|
||||
# Check that the correct functions are called and the inventory
|
||||
@ -641,8 +700,8 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
},
|
||||
'VCPU': {
|
||||
'reserved': 0,
|
||||
'total': 1,
|
||||
'max_unit': 1,
|
||||
'total': sys_proc_info.return_value,
|
||||
'max_unit': sys_proc_info.return_value,
|
||||
'min_unit': 1,
|
||||
'step_size': 1,
|
||||
'allocation_ratio': 1}
|
||||
@ -656,7 +715,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
sys_col = self.RSD.driver.PODM.get_system_collection.return_value
|
||||
sys_col.get_member.return_value = self.system_inst
|
||||
mem = conv_mem.return_value - 512
|
||||
proc = self.system_inst.processors.summary.count
|
||||
proc = self.system_inst.json['ProcessorSummary']['Count']
|
||||
flav_id = str(mem) + 'MB-' + str(proc) + 'vcpus'
|
||||
child_inv = self.RSD.create_child_inventory(
|
||||
'/redfish/v1/Systems/System1')
|
||||
@ -667,7 +726,7 @@ class TestRSDDriver(base.BaseTestCase):
|
||||
sys_col.get_member.assert_called_once_with(
|
||||
'/redfish/v1/Systems/System1')
|
||||
conv_mem.assert_called_once_with(
|
||||
self.system_inst.memory_summary.size_gib)
|
||||
self.system_inst.memory_summary.total_system_memory_gib)
|
||||
norm_name.assert_called_once_with(flav_id)
|
||||
self.assertEqual(child_inv, {norm_name.return_value: {
|
||||
'total': 1,
|
||||
|
@ -54,9 +54,15 @@ class PODM_connection(object):
|
||||
COMPOSED_NODE_COL = self.PODM.get_node_collection()
|
||||
|
||||
for s in SYSTEMS:
|
||||
system = SYS_COL.get_member(s)
|
||||
processors = system.processors.members_identities
|
||||
# Allocate the resources for all of the systems availablea
|
||||
try:
|
||||
node = COMPOSED_NODE_COL.compose_node()
|
||||
proc = processors[0]
|
||||
data = {
|
||||
'Resource': {
|
||||
"@odata.id": proc}}
|
||||
node = COMPOSED_NODE_COL.compose_node(processor_req=[data])
|
||||
except Exception as ex:
|
||||
LOG.warn("Node is already allocated: %s", ex)
|
||||
|
||||
@ -73,9 +79,9 @@ class PODM_connection(object):
|
||||
|
||||
try:
|
||||
node = COMPOSED_NODE_COL.get_member(cn)
|
||||
if node.system.identity not in self._RSD_NODES:
|
||||
self._RSD_NODES.append(node.system.identity)
|
||||
self.composed_nodes[node.system.identity] = cn
|
||||
if node.links.computer_system not in self._RSD_NODES:
|
||||
self._RSD_NODES.append(node.links.computer_system)
|
||||
self.composed_nodes[node.links.computer_system] = cn
|
||||
|
||||
except Exception as ce:
|
||||
LOG.warn("Failed to establish a connection to the PODM.%s", ce)
|
||||
|
@ -136,18 +136,20 @@ class RSDDriver(driver.ComputeDriver):
|
||||
LOG.warn("Malformed composed node instance:%s", ex)
|
||||
|
||||
if node_inst is not None:
|
||||
node_state = node_inst.composed_node_state
|
||||
p_state = node_inst.power_state
|
||||
if node_state == 'assembled' and p_state == 'off':
|
||||
node_state = node_inst.composed_node_state.lower()
|
||||
p_state = node_inst.power_state.lower()
|
||||
if node_state == 'assembled':
|
||||
# Provide nova instance with composed node info
|
||||
node_sys_id = node_inst.system.identity
|
||||
node_sys_id = node_inst.links.computer_system
|
||||
|
||||
if node_sys_id in sys_list:
|
||||
self.instances[uuid] = instance
|
||||
self._composed_nodes[uuid] = node_inst
|
||||
instance.display_description = \
|
||||
json.dumps({"node_identity": n,
|
||||
"node_uuid": node_inst.uuid})
|
||||
self.power_on(context, instance, network_info)
|
||||
if p_state == 'off':
|
||||
self.power_on(context, instance, network_info)
|
||||
return
|
||||
raise Exception("Failed to assign composed node for instance.")
|
||||
|
||||
@ -287,8 +289,9 @@ class RSDDriver(driver.ComputeDriver):
|
||||
cpus = 0
|
||||
for s in systems:
|
||||
ss = SYSTEM_COL.get_member(s)
|
||||
if ss.identity in self.driver.composed_nodes.keys():
|
||||
cpus = cpus + ss.processors.summary.count
|
||||
if ss.path in self.driver.composed_nodes.keys():
|
||||
proc = ss.json['ProcessorSummary']['Count']
|
||||
cpus = cpus + proc
|
||||
except Exception as ex:
|
||||
LOG.info("Failed to get processor info: %s", ex)
|
||||
return cpus
|
||||
@ -301,8 +304,8 @@ class RSDDriver(driver.ComputeDriver):
|
||||
ram = 0
|
||||
for s in systems:
|
||||
ss = SYSTEM_COL.get_member(s)
|
||||
if ss.identity in self.driver.composed_nodes.keys():
|
||||
mem = ss.memory_summary.size_gib
|
||||
if ss.path in self.driver.composed_nodes.keys():
|
||||
mem = ss.memory_summary.total_system_memory_gib
|
||||
ram = \
|
||||
ram + self.conv_GiB_to_MiB(mem)
|
||||
except Exception as ex:
|
||||
@ -327,7 +330,7 @@ class RSDDriver(driver.ComputeDriver):
|
||||
LOG.info("Powering off composed node: %s", key)
|
||||
self.instances[instance.uuid].power_state = power_state.SHUTDOWN
|
||||
node_inst = self._composed_nodes[key]
|
||||
node_inst.reset_node('graceful shutdown')
|
||||
node_inst.reset_node('GracefulShutdown')
|
||||
|
||||
def power_on(self, context, instance, network_info,
|
||||
block_device_info=None):
|
||||
@ -340,7 +343,7 @@ class RSDDriver(driver.ComputeDriver):
|
||||
LOG.info("Powering on composed node: %s", key)
|
||||
self.instances[instance.uuid].power_state = power_state.RUNNING
|
||||
node_inst = self._composed_nodes[key]
|
||||
node_inst.reset_node('force on')
|
||||
node_inst.reset_node('On')
|
||||
|
||||
def reboot(self, context, instance, network_info, reboot_type,
|
||||
block_device_info=None, bad_volumes_callback=None):
|
||||
@ -364,10 +367,10 @@ class RSDDriver(driver.ComputeDriver):
|
||||
if reboot_type == 'HARD':
|
||||
LOG.info(
|
||||
"Force restart composed node for a hard reboot: %s", key)
|
||||
node_inst.reset_node('force restart')
|
||||
node_inst.reset_node('ForceRestart')
|
||||
else:
|
||||
LOG.info("Graceful restart composed node for reboot: %s", key)
|
||||
node_inst.reset_node('graceful restart')
|
||||
node_inst.reset_node('GracefulRestart')
|
||||
|
||||
def create_inventory(self, system):
|
||||
"""Function to create provider tree inventory."""
|
||||
@ -401,8 +404,9 @@ class RSDDriver(driver.ComputeDriver):
|
||||
"""Create custom resources for all of the child RP's."""
|
||||
SYSTEM_COL = self.driver.PODM.get_system_collection()
|
||||
sys = SYSTEM_COL.get_member(system)
|
||||
mem = self.conv_GiB_to_MiB(sys.memory_summary.size_gib) - 512
|
||||
proc = sys.processors.summary.count
|
||||
mem = self.conv_GiB_to_MiB(
|
||||
sys.memory_summary.total_system_memory_gib) - 512
|
||||
proc = sys.json['ProcessorSummary']['Count']
|
||||
flav_id = str(mem) + 'MB-' + str(proc) + 'vcpus'
|
||||
res = fields.ResourceClass.normalize_name(flav_id)
|
||||
return {
|
||||
@ -418,7 +422,11 @@ class RSDDriver(driver.ComputeDriver):
|
||||
|
||||
def check_chassis_systems(self, chassis):
|
||||
"""Check the chassis for linked systems."""
|
||||
systems = chassis.json['Links']['ComputerSystems']
|
||||
try:
|
||||
systems = chassis.json['Links']['ComputerSystems']
|
||||
except KeyError as ke:
|
||||
LOG.debug("No valid compute systems: %s", ke)
|
||||
systems = []
|
||||
cha_sys = []
|
||||
for s in systems:
|
||||
cha_sys += s.values()
|
||||
@ -434,8 +442,9 @@ class RSDDriver(driver.ComputeDriver):
|
||||
|
||||
for s in cha_sys:
|
||||
sys = SYSTEM_COL.get_member(s)
|
||||
mem = self.conv_GiB_to_MiB(sys.memory_summary.size_gib) - 512
|
||||
proc = sys.processors.summary.count
|
||||
mem = self.conv_GiB_to_MiB(
|
||||
sys.memory_summary.total_system_memory_gib) - 512
|
||||
proc = sys.json['ProcessorSummary']['Count']
|
||||
flav_id = str(mem) + 'MB-' + str(proc) + 'vcpus'
|
||||
res = fields.ResourceClass.normalize_name(flav_id)
|
||||
spec = str('resources:' + res)
|
||||
@ -465,26 +474,25 @@ class RSDDriver(driver.ComputeDriver):
|
||||
requests.post(
|
||||
update_url, data=json.dumps(extra_pay),
|
||||
headers=self.headers)
|
||||
self.chas_systems[str(chas.path)] = [
|
||||
str(sys.path)]
|
||||
self.rsd_flavors[flav_id] = {
|
||||
'id': flav_id,
|
||||
'rsd_systems': {
|
||||
str(chas.path): str(sys.identity)}
|
||||
}
|
||||
'rsd_systems': self.chas_systems}
|
||||
except Exception as ex:
|
||||
LOG.warn("Failed to add extra_specs:%s", ex)
|
||||
else:
|
||||
chassis_ = self.rsd_flavors[flav_id]['rsd_systems']
|
||||
if str(chas.path) not in chassis_.keys():
|
||||
self.chas_systems[str(chas.path)] = [
|
||||
str(sys.identity)]
|
||||
str(sys.path)]
|
||||
self.rsd_flavors[flav_id] = {
|
||||
'rsd_systems': self.chas_systems
|
||||
}
|
||||
else:
|
||||
systems = self.rsd_flavors[
|
||||
flav_id]['rsd_systems'][str(chas.path)]
|
||||
if str(sys.identity) not in systems:
|
||||
systems.append(str(sys.identity))
|
||||
flav_id]['rsd_systems'][str(chas.path)]
|
||||
if str(sys.path) not in systems:
|
||||
systems.append(str(sys.path))
|
||||
self.chas_systems[str(chas.path)] = systems
|
||||
self.rsd_flavors[flav_id] = {
|
||||
'rsd_systems': self.chas_systems
|
||||
@ -497,9 +505,10 @@ class RSDDriver(driver.ComputeDriver):
|
||||
LOG.debug("Checking existing flavors.")
|
||||
for s in systems:
|
||||
sys = collection.get_member(s)
|
||||
sys_ids.append(sys.identity)
|
||||
mem = self.conv_GiB_to_MiB(sys.memory_summary.size_gib) - 512
|
||||
proc = sys.processors.summary.count
|
||||
sys_ids.append(sys.path)
|
||||
mem = self.conv_GiB_to_MiB(
|
||||
sys.memory_summary.total_system_memory_gib) - 512
|
||||
proc = sys.json['ProcessorSummary']['Count']
|
||||
flav_id = str(mem) + 'MB-' + str(proc) + 'vcpus'
|
||||
flav_ids.append(flav_id)
|
||||
|
||||
@ -516,21 +525,19 @@ class RSDDriver(driver.ComputeDriver):
|
||||
if f['id'] not in flav_ids:
|
||||
del_url = self.flavor_manager._create_request_url(
|
||||
f['id'], 'delete')
|
||||
fla_del = requests.delete(del_url, headers=self.headers)
|
||||
requests.delete(del_url, headers=self.headers)
|
||||
|
||||
for k in list(self.rsd_flavors):
|
||||
for k in self.rsd_flavors.keys():
|
||||
rsd_id = self.rsd_flavors[k]
|
||||
sys_list = self.rsd_flavors[k]['rsd_systems'].values()
|
||||
for s in sys_list:
|
||||
if s not in sys_ids:
|
||||
rsd_id = self.rsd_flavors[k]['id']
|
||||
del_url = self.flavor_manager._create_request_url(
|
||||
rsd_id, 'delete')
|
||||
try:
|
||||
LOG.debug("Deleting flavor for removed systems: %s", k)
|
||||
fla_del = requests.delete(del_url,
|
||||
headers=self.headers)
|
||||
LOG.debug("Deleting flavor for systems: %s", k)
|
||||
requests.delete(del_url, headers=self.headers)
|
||||
del self.rsd_flavors[k]
|
||||
except Exception as ex:
|
||||
LOG.warn("Failed to delete flavor: %s, %s",
|
||||
json.loads(fla_del.text), ex)
|
||||
LOG.warn("Failed to delete flavor: %s", ex)
|
||||
return
|
||||
|
@ -12,8 +12,6 @@ classifier =
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.5
|
||||
|
||||
|
@ -14,5 +14,5 @@ flake8
|
||||
pycodestyle
|
||||
wsgi-intercept>=1.4.1 # MIT License
|
||||
sushy>=1.7.0 # Apache-2.0
|
||||
|
||||
-e git+https://github.com/openstack/nova.git#egg=nova # Apache-2.0
|
||||
nova<=19.0.0
|
||||
#-e git+https://github.com/openstack/nova.git#egg=nova # Apache-2.0
|
||||
|
7
tox.ini
7
tox.ini
@ -5,7 +5,7 @@
|
||||
|
||||
[tox]
|
||||
minversion = 2.0
|
||||
envlist = py27,py36,pep8
|
||||
envlist = py36,pep8
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
@ -44,11 +44,6 @@ commands =
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
|
||||
[testenv:py27]
|
||||
basepython = python2.7
|
||||
commands =
|
||||
stestr run {posargs}
|
||||
|
||||
[testenv:py36]
|
||||
commands =
|
||||
stestr run {posargs}
|
||||
|
Loading…
Reference in New Issue
Block a user