blob: 5f4f7281f0ef23dfefd55f69654b3e120cefe559 [file] [log] [blame]
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +01001# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14from tempest import clients
15from tempest import config
Paul Glassd56330a2016-06-13 21:03:33 +000016from tempest.lib.auth import KeystoneV2AuthProvider
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010017
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010018from designate_tempest_plugin.services.dns.v1.json.domains_client import \
19 DomainsClient
20from designate_tempest_plugin.services.dns.v1.json.records_client import \
21 RecordsClient
22from designate_tempest_plugin.services.dns.v1.json.servers_client import \
23 ServersClient
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010024from designate_tempest_plugin.services.dns.v2.json.zones_client import \
25 ZonesClient
sonu.kumaraec952a2016-04-20 10:08:46 +090026from designate_tempest_plugin.services.dns.v2.json.zone_imports_client import \
27 ZoneImportsClient
Paul Glass8abae332016-04-21 15:34:09 +000028from designate_tempest_plugin.services.dns.v2.json.blacklists_client import \
29 BlacklistsClient
Paul Glass89edc112016-04-21 17:06:33 +000030from designate_tempest_plugin.services.dns.admin.json.quotas_client import \
31 QuotasClient
sonu.kumarc8f7a702016-04-29 21:07:16 +090032from designate_tempest_plugin.services.dns.v2.json.zone_exports_client import \
33 ZoneExportsClient
sonu.kumarde24d962016-05-05 00:28:00 +090034from designate_tempest_plugin.services.dns.v2.json.recordset_client import \
35 RecordsetClient
sonu.kumar4beb93c2016-05-05 01:12:43 +090036from designate_tempest_plugin.services.dns.v2.json.pool_client import \
37 PoolClient
sonu.kumar2de01be2016-05-05 10:07:28 +090038from designate_tempest_plugin.services.dns.v2.json.tld_client import \
39 TldClient
Paul Glasscf98c262016-05-13 19:34:37 +000040from designate_tempest_plugin.services.dns.query.query_client import \
41 QueryClient
sonu.kumare9785c92016-05-17 10:56:47 +090042from designate_tempest_plugin.services.dns.v2.json.transfer_request_client \
43 import TransferRequestClient
sonu.kumarea0ba082016-05-16 14:13:47 +090044from designate_tempest_plugin.services.dns.v2.json.transfer_accepts_client \
45 import TransferAcceptClient
sonu.kumarc3110862016-05-27 14:48:04 +090046from designate_tempest_plugin.services.dns.v2.json.tsigkey_client \
47 import TsigkeyClient
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010048
49CONF = config.CONF
50
51
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010052class ManagerV1(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000053
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010054 def __init__(self, credentials=None, service=None):
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010055 super(ManagerV1, self).__init__(credentials, service)
Paul Glassd56330a2016-06-13 21:03:33 +000056 self._init_clients(self._get_params())
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010057
Paul Glassd56330a2016-06-13 21:03:33 +000058 def _init_clients(self, params):
59 self.domains_client = DomainsClient(**params)
60 self.records_client = RecordsClient(**params)
61 self.servers_client = ServersClient(**params)
62
63 def _get_params(self):
64 params = dict(self.default_params)
65 params.update({
66 'auth_provider': self.auth_provider,
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010067 'service': CONF.dns.catalog_type,
68 'region': CONF.identity.region,
69 'endpoint_type': CONF.dns.endpoint_type,
70 'build_interval': CONF.dns.build_interval,
71 'build_timeout': CONF.dns.build_timeout
Paul Glassd56330a2016-06-13 21:03:33 +000072 })
73 return params
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010074
75
76class ManagerV2(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000077
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010078 def __init__(self, credentials=None, service=None):
79 super(ManagerV2, self).__init__(credentials, service)
Paul Glassd56330a2016-06-13 21:03:33 +000080 self._init_clients(self._get_params())
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010081
Paul Glassd56330a2016-06-13 21:03:33 +000082 def _init_clients(self, params):
83 self.zones_client = ZonesClient(**params)
84 self.zone_imports_client = ZoneImportsClient(**params)
85 self.blacklists_client = BlacklistsClient(**params)
86 self.quotas_client = QuotasClient(**params)
87 self.zone_exports_client = ZoneExportsClient(**params)
88 self.recordset_client = RecordsetClient(**params)
89 self.pool_client = PoolClient(**params)
90 self.tld_client = TldClient(**params)
91 self.transfer_request_client = TransferRequestClient(**params)
92 self.transfer_accept_client = TransferAcceptClient(**params)
93 self.tsigkey_client = TsigkeyClient(**params)
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010094
Paul Glasscf98c262016-05-13 19:34:37 +000095 self.query_client = QueryClient(
96 nameservers=CONF.dns.nameservers,
97 query_timeout=CONF.dns.query_timeout,
98 build_interval=CONF.dns.build_interval,
99 build_timeout=CONF.dns.build_timeout,
100 )
Paul Glassd56330a2016-06-13 21:03:33 +0000101
102 def _get_params(self):
103 params = dict(self.default_params)
104 params.update({
105 'auth_provider': self.auth_provider,
106 'service': CONF.dns.catalog_type,
107 'region': CONF.identity.region,
108 'endpoint_type': CONF.dns.endpoint_type,
109 'build_interval': CONF.dns.build_interval,
110 'build_timeout': CONF.dns.build_timeout
111 })
112 return params
113
114
115class ManagerV2Unauthed(ManagerV2):
116
117 def __init__(self, credentials=None, service=None):
118 super(ManagerV2Unauthed, self).__init__(credentials, service)
119 self.auth_provider = KeystoneV2UnauthedProvider(
120 credentials=self.auth_provider.credentials,
121 auth_url=self.auth_provider.auth_client.auth_url,
122 disable_ssl_certificate_validation=self.auth_provider.dscv,
123 ca_certs=self.auth_provider.ca_certs,
124 trace_requests=self.auth_provider.trace_requests,
125 )
126 self._init_clients(self._get_params())
127
128
129class KeystoneV2UnauthedProvider(KeystoneV2AuthProvider):
130 """This auth provider will ensure requests are made without a token"""
131
132 def _decorate_request(self, filters, method, url, headers=None, body=None,
133 auth_data=None):
134 result = super(KeystoneV2UnauthedProvider, self)._decorate_request(
135 filters, method, url, headers=headers, body=body,
136 auth_data=auth_data)
137 url, headers, body = result
138 try:
139 del headers['X-Auth-Token']
140 except KeyError:
141 pass
142 return url, headers, body