Fix inconsistent hostnames

This change ensures that the hostname is used consistently throughout
the Hyper-V driver.

This fixes a VM port binding issue in case of failovers.

Conflicts:
        hyperv/nova/cluster/clusterops.py

Change-Id: Ic1c9644721dad451fb68131bdc5f9b3397d5e267
Closes-Bug: #1694238
(cherry picked from commit 2205dc79e0)
This commit is contained in:
Lucian Petrut 2017-05-29 13:06:48 +03:00 committed by Claudiu Belu
parent c11cbd0ad4
commit 2391aa47e4
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):