Fix _build_instance_node for building Compute CDM
As of Nova API microversion 2.47, response of GET /servers/detail has flavor which contains a subset of the actual flavor information used to create the server instance, represented as a nested dictionary. Since current watcher nova default api version is 2.53(Pike), This patch follows the API response change. Change-Id: Ia575950f0702afa1d093f03ca8ddedd3c410b7de Closes-Bug: #1722462
This commit is contained in:
@@ -70,9 +70,6 @@ class NovaHelper(object):
|
|||||||
def get_service(self, service_id):
|
def get_service(self, service_id):
|
||||||
return self.nova.services.find(id=service_id)
|
return self.nova.services.find(id=service_id)
|
||||||
|
|
||||||
def get_flavor(self, flavor_id):
|
|
||||||
return self.nova.flavors.get(flavor_id)
|
|
||||||
|
|
||||||
def get_aggregate_list(self):
|
def get_aggregate_list(self):
|
||||||
return self.nova.aggregates.list()
|
return self.nova.aggregates.list()
|
||||||
|
|
||||||
|
|||||||
@@ -227,14 +227,14 @@ class ModelBuilder(object):
|
|||||||
:param instance: Nova VM object.
|
:param instance: Nova VM object.
|
||||||
:return: A instance node for the graph.
|
:return: A instance node for the graph.
|
||||||
"""
|
"""
|
||||||
flavor = self.nova_helper.get_flavor(instance.flavor["id"])
|
flavor = instance.flavor
|
||||||
instance_attributes = {
|
instance_attributes = {
|
||||||
"uuid": instance.id,
|
"uuid": instance.id,
|
||||||
"human_id": instance.human_id,
|
"human_id": instance.human_id,
|
||||||
"memory": flavor.ram,
|
"memory": flavor["ram"],
|
||||||
"disk": flavor.disk,
|
"disk": flavor["disk"],
|
||||||
"disk_capacity": flavor.disk,
|
"disk_capacity": flavor["disk"],
|
||||||
"vcpus": flavor.vcpus,
|
"vcpus": flavor["vcpus"],
|
||||||
"state": getattr(instance, "OS-EXT-STS:vm_state"),
|
"state": getattr(instance, "OS-EXT-STS:vm_state"),
|
||||||
"metadata": instance.metadata}
|
"metadata": instance.metadata}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from watcher.common import nova_helper
|
from watcher.common import nova_helper
|
||||||
from watcher.common import utils
|
|
||||||
from watcher.decision_engine.model.collector import nova
|
from watcher.decision_engine.model.collector import nova
|
||||||
from watcher.tests import base
|
from watcher.tests import base
|
||||||
from watcher.tests import conf_fixture
|
from watcher.tests import conf_fixture
|
||||||
@@ -62,9 +61,6 @@ class TestNovaClusterDataModelCollector(base.TestCase):
|
|||||||
# m_nova_helper.get_instances_by_node.return_value = [fake_instance]
|
# m_nova_helper.get_instances_by_node.return_value = [fake_instance]
|
||||||
m_nova_helper.get_instance_list.return_value = [fake_instance]
|
m_nova_helper.get_instance_list.return_value = [fake_instance]
|
||||||
|
|
||||||
m_nova_helper.get_flavor.return_value = utils.Struct(**{
|
|
||||||
'ram': 333, 'disk': 222, 'vcpus': 4})
|
|
||||||
|
|
||||||
m_config = mock.Mock()
|
m_config = mock.Mock()
|
||||||
m_osc = mock.Mock()
|
m_osc = mock.Mock()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user