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
This commit is contained in:
Zane Bitter 2019-01-29 19:45:48 +13:00
parent 2c9f7781cc
commit 8c79ae0aeb
1 changed files with 4 additions and 4 deletions

View File

@ -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)