Functional tests: configure putting the version in the url

Change-Id: Id7432f1570d8bedabbd78bfb4cbc8ee7e6531a42
This commit is contained in:
Paul Glass 2015-09-23 20:08:38 +00:00
parent 750646c86d
commit edccfaa473
10 changed files with 41 additions and 41 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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