Merge "Remove unused method _parse_node_instance_info"
This commit is contained in:
commit
04d6ed8d69
|
@ -445,38 +445,6 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(expected_props, parsed)
|
||||
self.assertEqual(4, mock_warning.call_count)
|
||||
|
||||
@mock.patch.object(ironic_driver.LOG, 'warning')
|
||||
def test__parse_node_instance_info(self, mock_warning):
|
||||
props = _get_properties()
|
||||
instance_info = _get_instance_info()
|
||||
node = ironic_utils.get_test_node(
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
instance_info=instance_info)
|
||||
parsed = self.driver._parse_node_instance_info(node, props)
|
||||
|
||||
self.assertEqual(instance_info, parsed)
|
||||
self.assertFalse(mock_warning.called)
|
||||
|
||||
@mock.patch.object(ironic_driver.LOG, 'warning')
|
||||
def test__parse_node_instance_info_bad_values(self, mock_warning):
|
||||
props = _get_properties()
|
||||
instance_info = _get_instance_info()
|
||||
instance_info['vcpus'] = 'bad-value'
|
||||
instance_info['memory_mb'] = 'bad-value'
|
||||
instance_info['local_gb'] = 'bad-value'
|
||||
node = ironic_utils.get_test_node(
|
||||
uuid=uuidutils.generate_uuid(),
|
||||
instance_info=instance_info)
|
||||
parsed = self.driver._parse_node_instance_info(node, props)
|
||||
|
||||
expected = {
|
||||
'vcpus': props['cpus'],
|
||||
'memory_mb': props['memory_mb'],
|
||||
'local_gb': props['local_gb']
|
||||
}
|
||||
self.assertEqual(expected, parsed)
|
||||
self.assertEqual(3, mock_warning.call_count)
|
||||
|
||||
@mock.patch.object(ironic_driver.LOG, 'warning')
|
||||
def test__parse_node_properties_canonicalize_cpu_arch(self, mock_warning):
|
||||
props = _get_properties()
|
||||
|
|
|
@ -251,33 +251,6 @@ class IronicDriver(virt_driver.ComputeDriver):
|
|||
properties['capabilities'] = node.properties.get('capabilities')
|
||||
return properties
|
||||
|
||||
def _parse_node_instance_info(self, node, props):
|
||||
"""Helper method to parse the node's instance info.
|
||||
|
||||
If a property cannot be looked up via instance_info, use the original
|
||||
value from the properties dict. This is most likely to be correct;
|
||||
it should only be incorrect if the properties were changed directly
|
||||
in Ironic while an instance was deployed.
|
||||
"""
|
||||
instance_info = {}
|
||||
|
||||
# add this key because it's different in instance_info for some reason
|
||||
props['vcpus'] = props['cpus']
|
||||
for prop in ('vcpus', 'memory_mb', 'local_gb'):
|
||||
original = props[prop]
|
||||
try:
|
||||
instance_info[prop] = int(node.instance_info.get(prop,
|
||||
original))
|
||||
except (TypeError, ValueError):
|
||||
LOG.warning('Node %(uuid)s has a malformed "%(prop)s". '
|
||||
'It should be an integer but its value '
|
||||
'is "%(value)s".',
|
||||
{'uuid': node.uuid, 'prop': prop,
|
||||
'value': node.instance_info.get(prop)})
|
||||
instance_info[prop] = original
|
||||
|
||||
return instance_info
|
||||
|
||||
def _node_resource(self, node):
|
||||
"""Helper method to create resource dict from node stats."""
|
||||
properties = self._parse_node_properties(node)
|
||||
|
|
Loading…
Reference in New Issue