Merge "Add get_available_node_uuids() to virt driver"
This commit is contained in:
commit
98daf501eb
|
@ -693,6 +693,7 @@ class SubclassSignatureTestCase(testtools.TestCase, metaclass=abc.ABCMeta):
|
|||
raise NotImplementedError()
|
||||
|
||||
def setUp(self):
|
||||
self.useFixture(nova_fixtures.ConfFixture(CONF))
|
||||
self.base = self._get_base_class()
|
||||
|
||||
super(SubclassSignatureTestCase, self).setUp()
|
||||
|
|
|
@ -248,6 +248,7 @@ class IronicResourceTrackerTest(test.TestCase):
|
|||
'numa_topology': None,
|
||||
'resource_class': None, # Act like admin hasn't set yet...
|
||||
'stats': stats,
|
||||
'uuid': str(getattr(uuids, nodename)),
|
||||
}
|
||||
self.rt.update_available_resource(self.ctx, nodename)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import io
|
|||
from unittest import mock
|
||||
|
||||
import fixtures
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
|
||||
from nova import conf
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
@ -177,7 +178,9 @@ class ServersTestBase(integrated_helpers._IntegratedTestBase):
|
|||
self.assertNotIn(hostname, self.computes)
|
||||
self.assertNotIn(hostname, self.compute_rp_uuids)
|
||||
|
||||
self.computes[hostname] = _start_compute(hostname, host_info)
|
||||
with mock.patch('nova.virt.node.get_local_node_uuid') as m:
|
||||
m.return_value = str(getattr(uuids, 'node_%s' % hostname))
|
||||
self.computes[hostname] = _start_compute(hostname, host_info)
|
||||
|
||||
self.compute_rp_uuids[hostname] = self.placement.get(
|
||||
'/resource_providers?name=%s' % hostname).body[
|
||||
|
|
|
@ -415,7 +415,9 @@ class _LibvirtEvacuateTest(integrated_helpers.InstanceHelperMixin):
|
|||
|
||||
with mock.patch.object(fakelibvirt.Connection, 'getHostname',
|
||||
return_value=name):
|
||||
compute = self.start_service('compute', host=name)
|
||||
with mock.patch('nova.virt.node.get_local_node_uuid') as m:
|
||||
m.return_value = str(getattr(uuids, 'node_%s' % name))
|
||||
compute = self.start_service('compute', host=name)
|
||||
|
||||
compute.driver._host.get_connection().getHostname = lambda: name
|
||||
return compute
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
# under the License.
|
||||
|
||||
import fixtures
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
|
||||
from nova import objects
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
@ -99,7 +101,9 @@ class VPMEMTestBase(integrated_helpers.LibvirtProviderUsageBaseTestCase):
|
|||
cpu_cores=2, cpu_threads=2),
|
||||
hostname=hostname)
|
||||
self.mock_conn.return_value = fake_connection
|
||||
compute = self._start_compute(host=hostname)
|
||||
with mock.patch('nova.virt.node.get_local_node_uuid') as m:
|
||||
m.return_value = str(getattr(uuids, 'node_%s' % hostname))
|
||||
compute = self._start_compute(host=hostname)
|
||||
|
||||
# Ensure populating the existing pmems correctly.
|
||||
vpmems = compute.driver._vpmems_by_name
|
||||
|
|
|
@ -34,6 +34,7 @@ from nova import context as nova_context
|
|||
from nova.i18n import _
|
||||
from nova import objects
|
||||
from nova.virt import event as virtevent
|
||||
import nova.virt.node
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -1595,6 +1596,9 @@ class ComputeDriver(object):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_available_node_uuids(self, refresh=False):
|
||||
return [nova.virt.node.get_local_node_uuid()]
|
||||
|
||||
def node_is_available(self, nodename):
|
||||
"""Return whether this compute service manages a particular node."""
|
||||
if nodename in self.get_available_nodes():
|
||||
|
|
|
@ -32,6 +32,7 @@ import fixtures
|
|||
import os_resource_classes as orc
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import versionutils
|
||||
|
||||
from nova.compute import power_state
|
||||
|
@ -160,8 +161,8 @@ class FakeDriver(driver.ComputeDriver):
|
|||
self._host = host
|
||||
# NOTE(gibi): this is unnecessary complex and fragile but this is
|
||||
# how many current functional sample tests expect the node name.
|
||||
self._nodes = (['fake-mini'] if self._host == 'compute'
|
||||
else [self._host])
|
||||
self._set_nodes(['fake-mini'] if self._host == 'compute'
|
||||
else [self._host])
|
||||
|
||||
def _set_nodes(self, nodes):
|
||||
# NOTE(gibi): this is not part of the driver interface but used
|
||||
|
@ -646,6 +647,9 @@ class FakeDriver(driver.ComputeDriver):
|
|||
def get_available_nodes(self, refresh=False):
|
||||
return self._nodes
|
||||
|
||||
def get_available_node_uuids(self, refresh=False):
|
||||
return [str(getattr(uuids, n)) for n in self.get_available_nodes()]
|
||||
|
||||
def instance_on_disk(self, instance):
|
||||
return False
|
||||
|
||||
|
@ -764,7 +768,7 @@ class PredictableNodeUUIDDriver(SmallFakeDriver):
|
|||
PredictableNodeUUIDDriver, self).get_available_resource(nodename)
|
||||
# This is used in ComputeNode.update_from_virt_driver which is called
|
||||
# from the ResourceTracker when creating a ComputeNode.
|
||||
resources['uuid'] = uuid.uuid5(uuid.NAMESPACE_DNS, nodename)
|
||||
resources['uuid'] = str(uuid.uuid5(uuid.NAMESPACE_DNS, nodename))
|
||||
return resources
|
||||
|
||||
|
||||
|
|
|
@ -839,6 +839,9 @@ class IronicDriver(virt_driver.ComputeDriver):
|
|||
|
||||
return node_uuids
|
||||
|
||||
def get_available_node_uuids(self, refresh=False):
|
||||
return self.get_available_nodes(refresh=refresh)
|
||||
|
||||
def update_provider_tree(self, provider_tree, nodename, allocations=None):
|
||||
"""Update a ProviderTree object with current resource provider and
|
||||
inventory information.
|
||||
|
|
|
@ -11310,6 +11310,9 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
def get_available_nodes(self, refresh=False):
|
||||
return [self._host.get_hostname()]
|
||||
|
||||
def get_available_node_uuids(self, refresh=False):
|
||||
return [self._host.get_node_uuid()]
|
||||
|
||||
def get_host_cpu_stats(self):
|
||||
"""Return the current CPU state of the host."""
|
||||
return self._host.get_cpu_stats()
|
||||
|
|
|
@ -66,6 +66,7 @@ from nova.virt.libvirt import event as libvirtevent
|
|||
from nova.virt.libvirt import guest as libvirt_guest
|
||||
from nova.virt.libvirt import migration as libvirt_migrate
|
||||
from nova.virt.libvirt import utils as libvirt_utils
|
||||
import nova.virt.node # noqa
|
||||
|
||||
if ty.TYPE_CHECKING:
|
||||
import libvirt
|
||||
|
@ -138,6 +139,7 @@ class Host(object):
|
|||
self._caps = None
|
||||
self._domain_caps = None
|
||||
self._hostname = None
|
||||
self._node_uuid = None
|
||||
|
||||
self._wrapped_conn = None
|
||||
self._wrapped_conn_lock = threading.Lock()
|
||||
|
@ -1059,6 +1061,12 @@ class Host(object):
|
|||
{'old': self._hostname, 'new': hostname})
|
||||
return self._hostname
|
||||
|
||||
def get_node_uuid(self):
|
||||
"""Returns the UUID of this node."""
|
||||
if not self._node_uuid:
|
||||
self._node_uuid = nova.virt.node.get_local_node_uuid()
|
||||
return self._node_uuid
|
||||
|
||||
def find_secret(self, usage_type, usage_id):
|
||||
"""Find a secret.
|
||||
|
||||
|
|
Loading…
Reference in New Issue