Make resource_tracker use Flavor object
This makes the resource_tracker use the Flavor object for getting information about an instance's flavor instead of a raw call to conductor. Related to blueprint compute-manager-objects Change-Id: Ida93eeed9b8f8f5da267cff6a6b38f6661479b36
This commit is contained in:
parent
b26559fac7
commit
bb4a7e007b
|
@ -30,6 +30,7 @@ from nova import conductor
|
|||
from nova import context
|
||||
from nova import exception
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import flavor as flavor_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import migration as migration_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
@ -689,7 +690,7 @@ class ResourceTracker(object):
|
|||
def _get_instance_type(self, context, instance, prefix,
|
||||
instance_type_id=None):
|
||||
"""Get the instance type from sys metadata if it's stashed. If not,
|
||||
fall back to fetching it via the conductor API.
|
||||
fall back to fetching it via the object API.
|
||||
|
||||
See bug 1164110
|
||||
"""
|
||||
|
@ -699,5 +700,5 @@ class ResourceTracker(object):
|
|||
try:
|
||||
return flavors.extract_flavor(instance, prefix)
|
||||
except KeyError:
|
||||
return self.conductor_api.instance_type_get(context,
|
||||
instance_type_id)
|
||||
return flavor_obj.Flavor.get_by_id(context,
|
||||
instance_type_id)
|
||||
|
|
|
@ -260,6 +260,12 @@ class BaseTestCase(test.TestCase):
|
|||
def _fake_flavor_create(self, **kwargs):
|
||||
instance_type = {
|
||||
'id': 1,
|
||||
'created_at': None,
|
||||
'updated_at': None,
|
||||
'deleted_at': None,
|
||||
'deleted': False,
|
||||
'disabled': False,
|
||||
'is_public': True,
|
||||
'name': 'fakeitype',
|
||||
'memory_mb': FAKE_VIRT_MEMORY_MB,
|
||||
'vcpus': FAKE_VIRT_VCPUS,
|
||||
|
@ -268,7 +274,8 @@ class BaseTestCase(test.TestCase):
|
|||
'swap': 0,
|
||||
'rxtx_factor': 1.0,
|
||||
'vcpu_weight': 1,
|
||||
'flavorid': 'fakeflavor'
|
||||
'flavorid': 'fakeflavor',
|
||||
'extra_specs': {},
|
||||
}
|
||||
instance_type.update(**kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue