Add get_compute_node_by_uuid
We want to set the value of uuid field of Watcher ComputeNode to hypversion id(as uuid). So we need to get hypervisor information by uuid. Change-Id: I752fbfa560313e28e87d83e46431c283b4db4f23 Related-Bug: #1835192
This commit is contained in:
@@ -86,6 +86,14 @@ class NovaHelper(object):
|
||||
LOG.exception(exc)
|
||||
raise exception.ComputeNodeNotFound(name=node_hostname)
|
||||
|
||||
def get_compute_node_by_uuid(self, node_uuid):
|
||||
"""Get compute node by uuid
|
||||
|
||||
:param node_uuid: hypervisor id as uuid after microversion 2.53
|
||||
:returns: novaclient.v2.hypervisors.Hypervisor object if found
|
||||
"""
|
||||
return self.nova.hypervisors.get(node_uuid)
|
||||
|
||||
def get_instance_list(self, filters=None, marker=None, limit=-1):
|
||||
"""List servers for all tenants with details.
|
||||
|
||||
|
||||
@@ -162,6 +162,18 @@ class TestNovaHelper(base.TestCase):
|
||||
result = nova_util.get_compute_node_by_hostname(name)
|
||||
self.assertIs(nodes[index], result)
|
||||
|
||||
def test_get_compute_node_by_uuid(
|
||||
self, mock_glance, mock_cinder, mock_neutron, mock_nova):
|
||||
nova_util = nova_helper.NovaHelper()
|
||||
hypervisor_id = utils.generate_uuid()
|
||||
hypervisor_name = "fake_hypervisor_1"
|
||||
hypervisor = self.fake_hypervisor(hypervisor_id, hypervisor_name)
|
||||
nova_util.nova.hypervisors.get.return_value = hypervisor
|
||||
# verify that the compute node can be obtained normally by id
|
||||
self.assertEqual(
|
||||
nova_util.get_compute_node_by_uuid(hypervisor_id),
|
||||
hypervisor)
|
||||
|
||||
def test_get_instance_list(self, *args):
|
||||
nova_util = nova_helper.NovaHelper()
|
||||
# Call it once with no filters.
|
||||
|
||||
Reference in New Issue
Block a user