From edccfaa473fb09683294af417e30152e0c8210ff Mon Sep 17 00:00:00 2001 From: Paul Glass Date: Wed, 23 Sep 2015 20:08:38 +0000 Subject: [PATCH] Functional tests: configure putting the version in the url Change-Id: Id7432f1570d8bedabbd78bfb4cbc8ee7e6531a42 --- .../api/v2/clients/blacklist_client.py | 5 +---- functionaltests/api/v2/clients/pool_client.py | 5 +---- .../api/v2/clients/recordset_client.py | 6 ++---- .../api/v2/clients/transfer_accepts_client.py | 10 ++++------ .../api/v2/clients/transfer_requests_client.py | 16 ++++++++-------- functionaltests/api/v2/clients/zone_client.py | 5 +---- .../api/v2/clients/zone_export_client.py | 16 ++++++++++------ .../api/v2/clients/zone_import_client.py | 5 +---- functionaltests/common/client.py | 10 ++++++++++ functionaltests/common/config.py | 4 +++- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/functionaltests/api/v2/clients/blacklist_client.py b/functionaltests/api/v2/clients/blacklist_client.py index 077e1915..36ae4ba7 100644 --- a/functionaltests/api/v2/clients/blacklist_client.py +++ b/functionaltests/api/v2/clients/blacklist_client.py @@ -23,10 +23,7 @@ class BlacklistClient(ClientMixin): @classmethod def blacklists_uri(cls, filters=None): - url = "/v2/blacklists" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/blacklists", filters=filters) @classmethod def blacklist_uri(cls, blacklist_id): diff --git a/functionaltests/api/v2/clients/pool_client.py b/functionaltests/api/v2/clients/pool_client.py index 9f0619a4..29dc8e5f 100644 --- a/functionaltests/api/v2/clients/pool_client.py +++ b/functionaltests/api/v2/clients/pool_client.py @@ -23,10 +23,7 @@ class PoolClient(ClientMixin): @classmethod def pools_uri(cls, filters=None): - url = "/v2/pools" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/pools", filters=filters) @classmethod def pool_uri(cls, pool_id): diff --git a/functionaltests/api/v2/clients/recordset_client.py b/functionaltests/api/v2/clients/recordset_client.py index 3ed36769..b3bb6ea6 100644 --- a/functionaltests/api/v2/clients/recordset_client.py +++ b/functionaltests/api/v2/clients/recordset_client.py @@ -26,10 +26,8 @@ class RecordsetClient(ClientMixin): @classmethod def recordsets_uri(cls, zone_id, filters=None): - url = "/v2/zones/{0}/recordsets".format(zone_id) - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/zones/{0}/recordsets".format(zone_id), + filters=filters) @classmethod def recordset_uri(cls, zone_id, recordset_id): diff --git a/functionaltests/api/v2/clients/transfer_accepts_client.py b/functionaltests/api/v2/clients/transfer_accepts_client.py index ab1d16ef..804bfe09 100644 --- a/functionaltests/api/v2/clients/transfer_accepts_client.py +++ b/functionaltests/api/v2/clients/transfer_accepts_client.py @@ -25,15 +25,13 @@ class TransferAcceptClient(ClientMixin): @classmethod def transfer_accepts_uri(cls, filters=None): - url = "/v2/zones/tasks/transfer_accepts" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/zones/tasks/transfer_accepts", + filters=filters) @classmethod def transfer_accept_uri(cls, transfer_request_id): - return "/v2/zones/tasks/transfer_accepts/{1}".format( - transfer_request_id) + return "{0}/{1}".format(cls.transfer_accepts_uri(), + transfer_request_id) def list_transfer_accepts(self, zone_id, filters=None, **kwargs): resp, body = self.client.get( diff --git a/functionaltests/api/v2/clients/transfer_requests_client.py b/functionaltests/api/v2/clients/transfer_requests_client.py index 98ca9aca..3abe1484 100644 --- a/functionaltests/api/v2/clients/transfer_requests_client.py +++ b/functionaltests/api/v2/clients/transfer_requests_client.py @@ -25,17 +25,17 @@ class TransferRequestClient(ClientMixin): @classmethod def create_transfer_requests_uri(cls, zone_id, filters=None): - url = "/v2/zones/{0}/tasks/transfer_requests".format(zone_id) - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri( + "/zones/{0}/tasks/transfer_requests".format(zone_id), + filters=filters, + ) @classmethod def transfer_requests_uri(cls, filters=None): - url = "/v2/zones/tasks/transfer_requests" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri( + "/zones/tasks/transfer_requests", + filters=filters, + ) @classmethod def transfer_request_uri(cls, transfer_request_id): diff --git a/functionaltests/api/v2/clients/zone_client.py b/functionaltests/api/v2/clients/zone_client.py index c491560a..a122b40a 100644 --- a/functionaltests/api/v2/clients/zone_client.py +++ b/functionaltests/api/v2/clients/zone_client.py @@ -26,10 +26,7 @@ class ZoneClient(ClientMixin): @classmethod def zones_uri(cls, filters=None): - url = "/v2/zones" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/zones", filters=filters) @classmethod def zone_uri(cls, id): diff --git a/functionaltests/api/v2/clients/zone_export_client.py b/functionaltests/api/v2/clients/zone_export_client.py index ce548b8c..92f61d7e 100644 --- a/functionaltests/api/v2/clients/zone_export_client.py +++ b/functionaltests/api/v2/clients/zone_export_client.py @@ -24,10 +24,14 @@ class ZoneExportClient(ClientMixin): @classmethod def zone_exports_uri(cls, filters=None): - url = "/v2/zones/tasks/exports" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/zones/tasks/exports", filters=filters) + + @classmethod + def create_zone_export_uri(cls, zone_id, filters=None): + return cls.create_uri( + "/zones/{0}/tasks/export".format(zone_id), + filters=filters, + ) @classmethod def zone_export_uri(cls, id): @@ -43,7 +47,7 @@ class ZoneExportClient(ClientMixin): return self.deserialize(resp, body, ZoneExportModel) def get_exported_zone(self, id, **kwargs): - uri = "/v2/zones/tasks/exports/{0}/export".format(id) + uri = "{0}/export".format(self.zone_export_uri(id)) headers = {'Accept': 'text/dns'} resp, body = self.client.get(uri, headers=headers) if resp.status < 400: @@ -51,7 +55,7 @@ class ZoneExportClient(ClientMixin): return resp, body def post_zone_export(self, zone_id, **kwargs): - uri = "/v2/zones/{0}/tasks/export".format(zone_id) + uri = self.create_zone_export_uri(zone_id) resp, body = self.client.post(uri, body='', **kwargs) return self.deserialize(resp, body, ZoneExportModel) diff --git a/functionaltests/api/v2/clients/zone_import_client.py b/functionaltests/api/v2/clients/zone_import_client.py index 332469f0..74a32fd9 100644 --- a/functionaltests/api/v2/clients/zone_import_client.py +++ b/functionaltests/api/v2/clients/zone_import_client.py @@ -23,10 +23,7 @@ class ZoneImportClient(ClientMixin): @classmethod def zone_imports_uri(cls, filters=None): - url = "/v2/zones/tasks/imports" - if filters: - url = cls.add_filters(url, filters) - return url + return cls.create_uri("/zones/tasks/imports", filters=filters) @classmethod def zone_import_uri(cls, id): diff --git a/functionaltests/common/client.py b/functionaltests/common/client.py index 045564bc..c51127b3 100644 --- a/functionaltests/common/client.py +++ b/functionaltests/common/client.py @@ -184,3 +184,13 @@ class ClientMixin(object): ) first = False return url + + @classmethod + def create_uri(cls, path, filters=None): + if cfg.CONF.identity.append_version_to_url: + uri = "/v2/{0}".format(path) + else: + uri = path + if filters: + uri = cls.add_filters(uri, filters) + return uri diff --git a/functionaltests/common/config.py b/functionaltests/common/config.py index 31a600bd..a87c1f66 100644 --- a/functionaltests/common/config.py +++ b/functionaltests/common/config.py @@ -29,11 +29,13 @@ cfg.CONF.register_group(cfg.OptGroup( cfg.CONF.register_opts([ cfg.StrOpt('designate_override_url', help="Use this instead of the endpoint in the service catalog"), + cfg.BoolOpt('append_version_to_url', default=True, + help="Post to url + /v2/zones instead of url + /zones"), cfg.StrOpt('uri', help="The Keystone v2 endpoint"), cfg.StrOpt('uri_v3', help="The Keystone v3 endpoint"), cfg.StrOpt('auth_version', default='v2'), - cfg.StrOpt('region', default='RegionOne'), + cfg.StrOpt('region', default=None), cfg.StrOpt('username'), cfg.StrOpt('tenant_name'),