From dac09241947e993fb7b37e5d88def3219697c580 Mon Sep 17 00:00:00 2001 From: aditi Date: Fri, 28 Jul 2017 03:49:56 +0000 Subject: [PATCH] Fix Hardcoded availability zone in nova-helper This patch fixes the hardcoded value of availability zone in nova-helper, Now nova api is used to get the availability zone of destination node Change-Id: I4c5a34946ed404df5bbfe34ce99873d32772dbf4 --- watcher/common/nova_helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index 325daa82f..85252a86e 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -787,6 +787,9 @@ class NovaHelper(object): net_obj = {"net-id": nic_id} net_list.append(net_obj) + # get availability zone of destination host + azone = self.nova.services.list(host=node_id, + binary='nova-compute')[0].zone instance = self.nova.servers.create( inst_name, image, flavor=flavor, @@ -794,7 +797,7 @@ class NovaHelper(object): security_groups=sec_group_list, nics=net_list, block_device_mapping_v2=block_device_mapping_v2, - availability_zone="nova:%s" % node_id) + availability_zone="%s:%s" % (azone, node_id)) # Poll at 5 second intervals, until the status is no longer 'BUILD' if instance: