From 54533ffe541531c04525c14e7d715a07efb133c6 Mon Sep 17 00:00:00 2001 From: Senthilnathan Murugappan Date: Mon, 6 Nov 2017 12:08:11 -0800 Subject: [PATCH] fix matching on host-fqname while retrieving hostname from nova obj Needed for RHOSP installation where nova services are registered with host-fqdn and contrail uses hostname Closes-Bug: #1730492 Change-Id: I1a149eb083f17b7d9a39c8ad75bca6e47623ba07 --- fixtures/nova_test.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fixtures/nova_test.py b/fixtures/nova_test.py index acc918724..d83da2137 100644 --- a/fixtures/nova_test.py +++ b/fixtures/nova_test.py @@ -691,6 +691,15 @@ def get_vm_list(self, name_pattern='', project_id=None): # end get_vm_list + def get_host_name(self, host_name): + for host in self.inputs.compute_names: + if host_name == host: + return host_name + if host in host_name.split('.'): + return host + else: + return host_name + def get_nova_host_of_vm(self, vm_obj): if 'OS-EXT-SRV-ATTR:hypervisor_hostname' not in vm_obj.__dict__: vm_obj = self.admin_obj.get_vm_by_id(vm_obj.id) @@ -701,7 +710,7 @@ def get_nova_host_of_vm(self, vm_obj): if hypervisor.hypervisor_type == 'QEMU' or \ hypervisor.hypervisor_type == 'docker': host_name = vm_obj.__dict__['OS-EXT-SRV-ATTR:host'] - return host_name + return self.get_host_name(host_name) if 'VMware' in hypervisor.hypervisor_type: host_name = vcenter_libs.get_contrail_vm_by_vm_uuid(self.inputs,vm_obj.id) return host_name