Merge "Make ironic driver use flavor fields instead of legacy ones"
This commit is contained in:
@@ -916,19 +916,20 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
node=node.uuid)
|
||||
image_meta = ironic_utils.get_test_image_meta()
|
||||
flavor = ironic_utils.get_test_flavor()
|
||||
instance.flavor = flavor
|
||||
self.driver._add_driver_fields(node, instance, image_meta, flavor)
|
||||
expected_patch = [{'path': '/instance_info/image_source', 'op': 'add',
|
||||
'value': image_meta.id},
|
||||
{'path': '/instance_info/root_gb', 'op': 'add',
|
||||
'value': str(instance.root_gb)},
|
||||
'value': str(instance.flavor.root_gb)},
|
||||
{'path': '/instance_info/swap_mb', 'op': 'add',
|
||||
'value': str(flavor['swap'])},
|
||||
{'path': '/instance_info/display_name',
|
||||
'value': instance.display_name, 'op': 'add'},
|
||||
{'path': '/instance_info/vcpus', 'op': 'add',
|
||||
'value': str(instance.vcpus)},
|
||||
'value': str(instance.flavor.vcpus)},
|
||||
{'path': '/instance_info/memory_mb', 'op': 'add',
|
||||
'value': str(instance.memory_mb)},
|
||||
'value': str(instance.flavor.memory_mb)},
|
||||
{'path': '/instance_info/local_gb', 'op': 'add',
|
||||
'value': str(node.properties.get('local_gb', 0))},
|
||||
{'path': '/instance_uuid', 'op': 'add',
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests.unit.virt.ironic import utils as ironic_utils
|
||||
@@ -32,6 +33,7 @@ class IronicDriverFieldsTestCase(test.NoDBTestCase):
|
||||
self.flavor = ironic_utils.get_test_flavor()
|
||||
self.ctx = nova_context.get_admin_context()
|
||||
self.instance = fake_instance.fake_instance_obj(self.ctx)
|
||||
self.instance.flavor = self.flavor
|
||||
self.node = ironic_utils.get_test_node(driver='fake')
|
||||
# Generic expected patches
|
||||
self._expected_deploy_patch = [
|
||||
@@ -39,7 +41,7 @@ class IronicDriverFieldsTestCase(test.NoDBTestCase):
|
||||
'value': self.image_meta.id,
|
||||
'op': 'add'},
|
||||
{'path': '/instance_info/root_gb',
|
||||
'value': str(self.instance['root_gb']),
|
||||
'value': str(self.instance.flavor.root_gb),
|
||||
'op': 'add'},
|
||||
{'path': '/instance_info/swap_mb',
|
||||
'value': str(self.flavor['swap']),
|
||||
@@ -48,10 +50,10 @@ class IronicDriverFieldsTestCase(test.NoDBTestCase):
|
||||
'value': self.instance['display_name'],
|
||||
'op': 'add'},
|
||||
{'path': '/instance_info/vcpus',
|
||||
'value': str(self.instance['vcpus']),
|
||||
'value': str(self.instance.flavor.vcpus),
|
||||
'op': 'add'},
|
||||
{'path': '/instance_info/memory_mb',
|
||||
'value': str(self.instance['memory_mb']),
|
||||
'value': str(self.instance.flavor.memory_mb),
|
||||
'op': 'add'},
|
||||
{'path': '/instance_info/local_gb',
|
||||
'value': str(self.node.properties.get('local_gb', 0)),
|
||||
@@ -105,12 +107,14 @@ class IronicDriverFieldsTestCase(test.NoDBTestCase):
|
||||
def test_generic_get_deploy_patch_ephemeral(self):
|
||||
CONF.set_override('default_ephemeral_format', 'testfmt')
|
||||
node = ironic_utils.get_test_node(driver='fake')
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
ephemeral_gb=10)
|
||||
instance = fake_instance.fake_instance_obj(
|
||||
self.ctx,
|
||||
flavor=objects.Flavor(root_gb=1, vcpus=1,
|
||||
memory_mb=1, ephemeral_gb=10))
|
||||
patch = patcher.create(node).get_deploy_patch(
|
||||
instance, self.image_meta, self.flavor)
|
||||
expected = [{'path': '/instance_info/ephemeral_gb',
|
||||
'value': str(instance.ephemeral_gb),
|
||||
'value': str(instance.flavor.ephemeral_gb),
|
||||
'op': 'add'},
|
||||
{'path': '/instance_info/ephemeral_format',
|
||||
'value': 'testfmt',
|
||||
|
||||
@@ -87,6 +87,9 @@ def get_test_flavor(**kw):
|
||||
flavor = {'name': kw.get('name', 'fake.flavor'),
|
||||
'extra_specs': kw.get('extra_specs', default_extra_specs),
|
||||
'swap': kw.get('swap', 0),
|
||||
'root_gb': 1,
|
||||
'memory_mb': 1,
|
||||
'vcpus': 1,
|
||||
'ephemeral_gb': kw.get('ephemeral_gb', 0)}
|
||||
return objects.Flavor(**flavor)
|
||||
|
||||
|
||||
@@ -58,22 +58,22 @@ class GenericDriverFields(object):
|
||||
patch.append({'path': '/instance_info/image_source', 'op': 'add',
|
||||
'value': image_meta.id})
|
||||
patch.append({'path': '/instance_info/root_gb', 'op': 'add',
|
||||
'value': str(instance.root_gb)})
|
||||
'value': str(instance.flavor.root_gb)})
|
||||
patch.append({'path': '/instance_info/swap_mb', 'op': 'add',
|
||||
'value': str(flavor['swap'])})
|
||||
patch.append({'path': '/instance_info/display_name',
|
||||
'op': 'add', 'value': instance.display_name})
|
||||
patch.append({'path': '/instance_info/vcpus', 'op': 'add',
|
||||
'value': str(instance.vcpus)})
|
||||
'value': str(instance.flavor.vcpus)})
|
||||
patch.append({'path': '/instance_info/memory_mb', 'op': 'add',
|
||||
'value': str(instance.memory_mb)})
|
||||
'value': str(instance.flavor.memory_mb)})
|
||||
patch.append({'path': '/instance_info/local_gb', 'op': 'add',
|
||||
'value': str(self.node.properties.get('local_gb', 0))})
|
||||
|
||||
if instance.ephemeral_gb:
|
||||
if instance.flavor.ephemeral_gb:
|
||||
patch.append({'path': '/instance_info/ephemeral_gb',
|
||||
'op': 'add',
|
||||
'value': str(instance.ephemeral_gb)})
|
||||
'value': str(instance.flavor.ephemeral_gb)})
|
||||
if CONF.default_ephemeral_format:
|
||||
patch.append({'path': '/instance_info/ephemeral_format',
|
||||
'op': 'add',
|
||||
|
||||
Reference in New Issue
Block a user