blob: 6fbfc054fc6e538a3a882a0ef6cfa57075a911b0 [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
Cao Xuan Hoanga585e942016-08-29 14:52:30 +070016from tempest.lib import auth
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
Graham Hayesc8114982016-07-04 17:46:08 +010030from designate_tempest_plugin.services.dns.v2.json.quotas_client import \
Paul Glass89edc112016-04-21 17:06:33 +000031 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
Graham Hayesc8114982016-07-04 17:46:08 +010040from designate_tempest_plugin.services.dns.admin.json.quotas_client import \
41 QuotasClient as AdminQuotaClient
Paul Glasscf98c262016-05-13 19:34:37 +000042from designate_tempest_plugin.services.dns.query.query_client import \
43 QueryClient
sonu.kumare9785c92016-05-17 10:56:47 +090044from designate_tempest_plugin.services.dns.v2.json.transfer_request_client \
45 import TransferRequestClient
sonu.kumarea0ba082016-05-16 14:13:47 +090046from designate_tempest_plugin.services.dns.v2.json.transfer_accepts_client \
47 import TransferAcceptClient
sonu.kumarc3110862016-05-27 14:48:04 +090048from designate_tempest_plugin.services.dns.v2.json.tsigkey_client \
49 import TsigkeyClient
Arkady Shtempler5e9466d2021-03-15 12:56:30 +020050from designate_tempest_plugin.services.dns.v2.json.service_client \
51 import SevriceClient
Arkady Shtempler868a8402021-03-16 13:28:19 +020052from designate_tempest_plugin.services.dns.v2.json.designate_limit_client \
53 import DesignateLimitClient
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010054
55CONF = config.CONF
56
57
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010058class ManagerV1(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000059
Graham Hayesc1978262017-01-11 17:17:32 +000060 def __init__(self, credentials=None):
61 super(ManagerV1, self).__init__(credentials)
Paul Glassd56330a2016-06-13 21:03:33 +000062 self._init_clients(self._get_params())
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010063
Paul Glassd56330a2016-06-13 21:03:33 +000064 def _init_clients(self, params):
65 self.domains_client = DomainsClient(**params)
66 self.records_client = RecordsClient(**params)
67 self.servers_client = ServersClient(**params)
68
69 def _get_params(self):
70 params = dict(self.default_params)
71 params.update({
72 'auth_provider': self.auth_provider,
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010073 'service': CONF.dns.catalog_type,
74 'region': CONF.identity.region,
75 'endpoint_type': CONF.dns.endpoint_type,
76 'build_interval': CONF.dns.build_interval,
77 'build_timeout': CONF.dns.build_timeout
Paul Glassd56330a2016-06-13 21:03:33 +000078 })
79 return params
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010080
81
82class ManagerV2(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000083
Graham Hayesc1978262017-01-11 17:17:32 +000084 def __init__(self, credentials=None):
85 super(ManagerV2, self).__init__(credentials)
Paul Glassd56330a2016-06-13 21:03:33 +000086 self._init_clients(self._get_params())
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010087
Paul Glassd56330a2016-06-13 21:03:33 +000088 def _init_clients(self, params):
89 self.zones_client = ZonesClient(**params)
90 self.zone_imports_client = ZoneImportsClient(**params)
91 self.blacklists_client = BlacklistsClient(**params)
92 self.quotas_client = QuotasClient(**params)
93 self.zone_exports_client = ZoneExportsClient(**params)
94 self.recordset_client = RecordsetClient(**params)
95 self.pool_client = PoolClient(**params)
96 self.tld_client = TldClient(**params)
97 self.transfer_request_client = TransferRequestClient(**params)
98 self.transfer_accept_client = TransferAcceptClient(**params)
99 self.tsigkey_client = TsigkeyClient(**params)
Arkady Shtempler5e9466d2021-03-15 12:56:30 +0200100 self.service_client = SevriceClient(**params)
Arkady Shtempler868a8402021-03-16 13:28:19 +0200101 self.designate_limit_client = DesignateLimitClient(**params)
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +0100102
Paul Glasscf98c262016-05-13 19:34:37 +0000103 self.query_client = QueryClient(
104 nameservers=CONF.dns.nameservers,
105 query_timeout=CONF.dns.query_timeout,
106 build_interval=CONF.dns.build_interval,
107 build_timeout=CONF.dns.build_timeout,
108 )
Paul Glassd56330a2016-06-13 21:03:33 +0000109
110 def _get_params(self):
111 params = dict(self.default_params)
112 params.update({
113 'auth_provider': self.auth_provider,
114 'service': CONF.dns.catalog_type,
115 'region': CONF.identity.region,
116 'endpoint_type': CONF.dns.endpoint_type,
117 'build_interval': CONF.dns.build_interval,
118 'build_timeout': CONF.dns.build_timeout
119 })
120 return params
121
122
Graham Hayesc8114982016-07-04 17:46:08 +0100123class ManagerAdmin(clients.Manager):
124
Graham Hayesc1978262017-01-11 17:17:32 +0000125 def __init__(self, credentials=None):
126 super(ManagerAdmin, self).__init__(credentials)
Graham Hayesc8114982016-07-04 17:46:08 +0100127 self._init_clients(self._get_params())
128
129 def _init_clients(self, params):
130 self.quotas_client = AdminQuotaClient(**params)
131
132 def _get_params(self):
133 params = dict(self.default_params)
134 params.update({
135 'auth_provider': self.auth_provider,
136 'service': CONF.dns.catalog_type,
137 'region': CONF.identity.region,
138 'endpoint_type': CONF.dns.endpoint_type,
139 'build_interval': CONF.dns.build_interval,
140 'build_timeout': CONF.dns.build_timeout
141 })
142 return params
143
144
Paul Glassd56330a2016-06-13 21:03:33 +0000145class ManagerV2Unauthed(ManagerV2):
146
Graham Hayesc1978262017-01-11 17:17:32 +0000147 def __init__(self, credentials=None):
148 super(ManagerV2Unauthed, self).__init__(credentials)
Paul Glass4b07b382016-07-13 19:14:02 +0000149 self.auth_provider = self._auth_provider_class()(
Paul Glassd56330a2016-06-13 21:03:33 +0000150 credentials=self.auth_provider.credentials,
151 auth_url=self.auth_provider.auth_client.auth_url,
152 disable_ssl_certificate_validation=self.auth_provider.dscv,
153 ca_certs=self.auth_provider.ca_certs,
154 trace_requests=self.auth_provider.trace_requests,
155 )
156 self._init_clients(self._get_params())
157
Paul Glass4b07b382016-07-13 19:14:02 +0000158 def _auth_provider_class(self):
159 if CONF.identity.auth_version == 'v3':
160 return KeystoneV3UnauthedProvider
161 else:
162 return KeystoneV2UnauthedProvider
Paul Glassd56330a2016-06-13 21:03:33 +0000163
Paul Glass4b07b382016-07-13 19:14:02 +0000164
Cao Xuan Hoanga585e942016-08-29 14:52:30 +0700165class BaseUnauthedProvider(auth.KeystoneAuthProvider):
Paul Glassd56330a2016-06-13 21:03:33 +0000166
167 def _decorate_request(self, filters, method, url, headers=None, body=None,
168 auth_data=None):
Paul Glass4b07b382016-07-13 19:14:02 +0000169 result = super(BaseUnauthedProvider, self)._decorate_request(
Paul Glassd56330a2016-06-13 21:03:33 +0000170 filters, method, url, headers=headers, body=body,
171 auth_data=auth_data)
172 url, headers, body = result
173 try:
174 del headers['X-Auth-Token']
175 except KeyError:
176 pass
177 return url, headers, body
Paul Glass4b07b382016-07-13 19:14:02 +0000178
179
Cao Xuan Hoanga585e942016-08-29 14:52:30 +0700180class KeystoneV2UnauthedProvider(auth.KeystoneV2AuthProvider,
181 BaseUnauthedProvider):
Paul Glass4b07b382016-07-13 19:14:02 +0000182
183 def _decorate_request(self, *args, **kwargs):
184 return BaseUnauthedProvider._decorate_request(self, *args, **kwargs)
185
186
Cao Xuan Hoanga585e942016-08-29 14:52:30 +0700187class KeystoneV3UnauthedProvider(auth.KeystoneV3AuthProvider,
188 BaseUnauthedProvider):
Paul Glass4b07b382016-07-13 19:14:02 +0000189
190 def _decorate_request(self, *args, **kwargs):
191 return BaseUnauthedProvider._decorate_request(self, *args, **kwargs)