From 8c79ae0aeb8f937f45d94f5f549de344d7ea5817 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 29 Jan 2019 19:45:48 +1300 Subject: [PATCH] Fix Designate Zone lookup by name Zones are a concept of the Designate v2 API. Since v1 is still the default, we need to explicitly use v2 when doing anything to do with Zones. We were doing this when looking up a zone directly, but not when falling back to listing all zones and going through them by name. This meant that designate.zone constraint validation would fail (including on the 'zone' property of OS::Designate::RecordSet) when the zone was specified by name rather than UUID. Change-Id: Id4194a74398488813f901b255f312f7ac962a426 Task: #29162 --- heat/engine/clients/os/designate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heat/engine/clients/os/designate.py b/heat/engine/clients/os/designate.py index 6df4785a26..3989e98b55 100644 --- a/heat/engine/clients/os/designate.py +++ b/heat/engine/clients/os/designate.py @@ -57,14 +57,14 @@ class DesignateClientPlugin(client_plugin.ClientPlugin): name=domain_id_or_name) def get_zone_id(self, zone_id_or_name): + client = self.client(version=self.V2) try: - zone_obj = self.client(version=self.V2).zones.get(zone_id_or_name) + zone_obj = client.zones.get(zone_id_or_name) return zone_obj['id'] except exceptions.NotFound: - zones = self.client().zones.list( - criterion=dict(name=zone_id_or_name)) + zones = client.zones.list(criterion=dict(name=zone_id_or_name)) if len(zones) == 1: - return zones[0]['id'] + return zones[0]['id'] raise heat_exception.EntityNotFound(entity='Designate Zone', name=zone_id_or_name)