Merge "Fix inconsistent hostnames" into stable/ocata

This commit is contained in:
Jenkins 2017-06-14 14:43:57 +00:00 committed by Gerrit Code Review
commit b5566ac4c9
3 changed files with 9 additions and 3 deletions

View File

@ -32,6 +32,7 @@ from oslo_config import cfg
from oslo_log import log as logging
from hyperv.i18n import _LI, _LE
from hyperv.nova import hostops
from hyperv.nova import serialconsoleops
from hyperv.nova import vmops
@ -54,7 +55,7 @@ class ClusterOps(object):
self._clustutils.check_cluster_state()
self._instance_map = {}
self._this_node = self._clustutils.get_node_name()
self._this_node = hostops.HostOps.get_hostname()
self._context = context.get_admin_context()
self._network_api = network.API()

View File

@ -150,6 +150,10 @@ class HostOps(object):
return objects.NUMATopology(cells=cells)
@staticmethod
def get_hostname():
return platform.node()
def get_available_resource(self):
"""Retrieve resource info.
@ -182,7 +186,7 @@ class HostOps(object):
'local_gb_used': used_hdd_gb,
'hypervisor_type': "hyperv",
'hypervisor_version': self._get_hypervisor_version(),
'hypervisor_hostname': platform.node(),
'hypervisor_hostname': self.get_hostname(),
'vcpus_used': 0,
'cpu_info': jsonutils.dumps(cpu_info),
'supported_instances': [

View File

@ -174,7 +174,8 @@ class ClusterOpsTestCase(test_base.HyperVBaseTestCase):
mock.sentinel.old_host,
mock.sentinel.new_host)
instance.host.upper.assert_called_with()
self.assertFalse(
self.clusterops._network_api.get_instance_nw_info.called)
@mock.patch.object(clusterops.ClusterOps, '_get_instance_by_name')
def test_failover_migrate_at_source_node(self, mock_get_instance_by_name):