Merge "Use flavor object in compute manager"
This commit is contained in:
@@ -276,12 +276,12 @@ class MoveClaim(Claim):
|
||||
|
||||
@property
|
||||
def disk_gb(self):
|
||||
return (self.instance_type['root_gb'] +
|
||||
self.instance_type['ephemeral_gb'])
|
||||
return (self.instance_type.root_gb +
|
||||
self.instance_type.ephemeral_gb)
|
||||
|
||||
@property
|
||||
def memory_mb(self):
|
||||
return self.instance_type['memory_mb'] + self.overhead['memory_mb']
|
||||
return self.instance_type.memory_mb + self.overhead['memory_mb']
|
||||
|
||||
@property
|
||||
def numa_topology(self):
|
||||
|
||||
+10
-10
@@ -3417,11 +3417,11 @@ class ComputeManager(manager.Manager):
|
||||
old_vm_state = sys_meta.pop('old_vm_state', vm_states.ACTIVE)
|
||||
|
||||
instance.system_metadata = sys_meta
|
||||
instance.memory_mb = instance_type['memory_mb']
|
||||
instance.vcpus = instance_type['vcpus']
|
||||
instance.root_gb = instance_type['root_gb']
|
||||
instance.ephemeral_gb = instance_type['ephemeral_gb']
|
||||
instance.instance_type_id = instance_type['id']
|
||||
instance.memory_mb = instance_type.memory_mb
|
||||
instance.vcpus = instance_type.vcpus
|
||||
instance.root_gb = instance_type.root_gb
|
||||
instance.ephemeral_gb = instance_type.ephemeral_gb
|
||||
instance.instance_type_id = instance_type.id
|
||||
instance.host = migration.source_compute
|
||||
instance.node = migration.source_node
|
||||
instance.save()
|
||||
@@ -3686,11 +3686,11 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
@staticmethod
|
||||
def _set_instance_info(instance, instance_type):
|
||||
instance.instance_type_id = instance_type['id']
|
||||
instance.memory_mb = instance_type['memory_mb']
|
||||
instance.vcpus = instance_type['vcpus']
|
||||
instance.root_gb = instance_type['root_gb']
|
||||
instance.ephemeral_gb = instance_type['ephemeral_gb']
|
||||
instance.instance_type_id = instance_type.id
|
||||
instance.memory_mb = instance_type.memory_mb
|
||||
instance.vcpus = instance_type.vcpus
|
||||
instance.root_gb = instance_type.root_gb
|
||||
instance.ephemeral_gb = instance_type.ephemeral_gb
|
||||
instance.set_flavor(instance_type)
|
||||
|
||||
def _finish_resize(self, context, instance, migration, disk_info,
|
||||
|
||||
@@ -170,7 +170,7 @@ class ResourceTracker(object):
|
||||
# get memory overhead required to build this instance:
|
||||
overhead = self.driver.estimate_instance_overhead(instance_type)
|
||||
LOG.debug("Memory overhead for %(flavor)d MB instance; %(overhead)d "
|
||||
"MB", {'flavor': instance_type['memory_mb'],
|
||||
"MB", {'flavor': instance_type.memory_mb,
|
||||
'overhead': overhead['memory_mb']})
|
||||
|
||||
claim = claims.MoveClaim(context, instance, instance_type,
|
||||
@@ -200,7 +200,7 @@ class ResourceTracker(object):
|
||||
migration.dest_node = self.nodename
|
||||
migration.dest_host = self.driver.get_host_ip_addr()
|
||||
migration.old_instance_type_id = instance.flavor.id
|
||||
migration.new_instance_type_id = instance_type['id']
|
||||
migration.new_instance_type_id = instance_type.id
|
||||
migration.status = 'pre-migrating'
|
||||
migration.instance_uuid = instance.uuid
|
||||
migration.source_compute = instance.host
|
||||
@@ -247,7 +247,7 @@ class ResourceTracker(object):
|
||||
instance['system_metadata'])
|
||||
|
||||
if (instance_type is not None and
|
||||
instance_type['id'] == itype['id']):
|
||||
instance_type.id == itype['id']):
|
||||
numa_topology = hardware.numa_get_constraints(
|
||||
itype, image_meta)
|
||||
usage = self._get_usage_dict(
|
||||
|
||||
@@ -36,7 +36,7 @@ class FakeResourceHandler(object):
|
||||
|
||||
def test_resources(self, usage, limits):
|
||||
self.test_called = True
|
||||
self.usage_is_itype = usage.get('name') is 'fakeitype'
|
||||
self.usage_is_itype = usage.get('name') == 'fakeitype'
|
||||
return []
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class ClaimTestCase(test.NoDBTestCase):
|
||||
'ephemeral_gb': 2
|
||||
}
|
||||
instance_type.update(**kwargs)
|
||||
return instance_type
|
||||
return objects.Flavor(**instance_type)
|
||||
|
||||
def _fake_resources(self, values=None):
|
||||
resources = {
|
||||
|
||||
@@ -395,6 +395,7 @@ class BaseTestCase(test.TestCase):
|
||||
'extra_specs': {},
|
||||
}
|
||||
instance_type.update(**kwargs)
|
||||
instance_type = objects.Flavor(**instance_type)
|
||||
|
||||
id_ = instance_type['id']
|
||||
self._instance_types[id_] = instance_type
|
||||
|
||||
@@ -1148,7 +1148,7 @@ class TestMoveClaim(BaseTestCase):
|
||||
self.rt.compute_node = copy.deepcopy(_COMPUTE_NODE_FIXTURES[0])
|
||||
|
||||
self.instance = _INSTANCE_FIXTURES[0].obj_clone()
|
||||
self.flavor = _INSTANCE_TYPE_FIXTURES[1]
|
||||
self.flavor = _INSTANCE_TYPE_OBJ_FIXTURES[1]
|
||||
self.limits = {}
|
||||
|
||||
# not using mock.sentinel.ctx because resize_claim calls #elevated
|
||||
@@ -1244,7 +1244,7 @@ class TestMoveClaim(BaseTestCase):
|
||||
with mock.patch.object(self.rt, '_create_migration') as migr_mock:
|
||||
migr_mock.return_value = migr_obj
|
||||
claim = self.rt.resize_claim(self.ctx, self.instance,
|
||||
_INSTANCE_TYPE_FIXTURES[1], None)
|
||||
_INSTANCE_TYPE_OBJ_FIXTURES[1], None)
|
||||
|
||||
self.audit(self.rt, [self.instance], [migr_obj], self.instance)
|
||||
self.assertNotEqual(expected, self.rt.compute_node)
|
||||
|
||||
Reference in New Issue
Block a user