blob: d85d343729e5210f3b9d12ebb18e4ad0fa19cd2e [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 Glass4b07b382016-07-13 19:14:02 +000016from tempest.lib.auth import KeystoneAuthProvider
Paul Glassd56330a2016-06-13 21:03:33 +000017from tempest.lib.auth import KeystoneV2AuthProvider
Paul Glass4b07b382016-07-13 19:14:02 +000018from tempest.lib.auth import KeystoneV3AuthProvider
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010019
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010020from designate_tempest_plugin.services.dns.v1.json.domains_client import \
21 DomainsClient
22from designate_tempest_plugin.services.dns.v1.json.records_client import \
23 RecordsClient
24from designate_tempest_plugin.services.dns.v1.json.servers_client import \
25 ServersClient
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010026from designate_tempest_plugin.services.dns.v2.json.zones_client import \
27 ZonesClient
sonu.kumaraec952a2016-04-20 10:08:46 +090028from designate_tempest_plugin.services.dns.v2.json.zone_imports_client import \
29 ZoneImportsClient
Paul Glass8abae332016-04-21 15:34:09 +000030from designate_tempest_plugin.services.dns.v2.json.blacklists_client import \
31 BlacklistsClient
Graham Hayesc8114982016-07-04 17:46:08 +010032from designate_tempest_plugin.services.dns.v2.json.quotas_client import \
Paul Glass89edc112016-04-21 17:06:33 +000033 QuotasClient
sonu.kumarc8f7a702016-04-29 21:07:16 +090034from designate_tempest_plugin.services.dns.v2.json.zone_exports_client import \
35 ZoneExportsClient
sonu.kumarde24d962016-05-05 00:28:00 +090036from designate_tempest_plugin.services.dns.v2.json.recordset_client import \
37 RecordsetClient
sonu.kumar4beb93c2016-05-05 01:12:43 +090038from designate_tempest_plugin.services.dns.v2.json.pool_client import \
39 PoolClient
sonu.kumar2de01be2016-05-05 10:07:28 +090040from designate_tempest_plugin.services.dns.v2.json.tld_client import \
41 TldClient
Graham Hayesc8114982016-07-04 17:46:08 +010042from designate_tempest_plugin.services.dns.admin.json.quotas_client import \
43 QuotasClient as AdminQuotaClient
Paul Glasscf98c262016-05-13 19:34:37 +000044from designate_tempest_plugin.services.dns.query.query_client import \
45 QueryClient
sonu.kumare9785c92016-05-17 10:56:47 +090046from designate_tempest_plugin.services.dns.v2.json.transfer_request_client \
47 import TransferRequestClient
sonu.kumarea0ba082016-05-16 14:13:47 +090048from designate_tempest_plugin.services.dns.v2.json.transfer_accepts_client \
49 import TransferAcceptClient
sonu.kumarc3110862016-05-27 14:48:04 +090050from designate_tempest_plugin.services.dns.v2.json.tsigkey_client \
51 import TsigkeyClient
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010052
53CONF = config.CONF
54
55
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010056class ManagerV1(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000057
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010058 def __init__(self, credentials=None, service=None):
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010059 super(ManagerV1, self).__init__(credentials, service)
Paul Glassd56330a2016-06-13 21:03:33 +000060 self._init_clients(self._get_params())
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010061
Paul Glassd56330a2016-06-13 21:03:33 +000062 def _init_clients(self, params):
63 self.domains_client = DomainsClient(**params)
64 self.records_client = RecordsClient(**params)
65 self.servers_client = ServersClient(**params)
66
67 def _get_params(self):
68 params = dict(self.default_params)
69 params.update({
70 'auth_provider': self.auth_provider,
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010071 'service': CONF.dns.catalog_type,
72 'region': CONF.identity.region,
73 'endpoint_type': CONF.dns.endpoint_type,
74 'build_interval': CONF.dns.build_interval,
75 'build_timeout': CONF.dns.build_timeout
Paul Glassd56330a2016-06-13 21:03:33 +000076 })
77 return params
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010078
79
80class ManagerV2(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000081
Kiall Mac Innes8ae796c2016-04-21 13:47:25 +010082 def __init__(self, credentials=None, service=None):
83 super(ManagerV2, self).__init__(credentials, service)
Paul Glassd56330a2016-06-13 21:03:33 +000084 self._init_clients(self._get_params())
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010085
Paul Glassd56330a2016-06-13 21:03:33 +000086 def _init_clients(self, params):
87 self.zones_client = ZonesClient(**params)
88 self.zone_imports_client = ZoneImportsClient(**params)
89 self.blacklists_client = BlacklistsClient(**params)
90 self.quotas_client = QuotasClient(**params)
91 self.zone_exports_client = ZoneExportsClient(**params)
92 self.recordset_client = RecordsetClient(**params)
93 self.pool_client = PoolClient(**params)
94 self.tld_client = TldClient(**params)
95 self.transfer_request_client = TransferRequestClient(**params)
96 self.transfer_accept_client = TransferAcceptClient(**params)
97 self.tsigkey_client = TsigkeyClient(**params)
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010098
Paul Glasscf98c262016-05-13 19:34:37 +000099 self.query_client = QueryClient(
100 nameservers=CONF.dns.nameservers,
101 query_timeout=CONF.dns.query_timeout,
102 build_interval=CONF.dns.build_interval,
103 build_timeout=CONF.dns.build_timeout,
104 )
Paul Glassd56330a2016-06-13 21:03:33 +0000105
106 def _get_params(self):
107 params = dict(self.default_params)
108 params.update({
109 'auth_provider': self.auth_provider,
110 'service': CONF.dns.catalog_type,
111 'region': CONF.identity.region,
112 'endpoint_type': CONF.dns.endpoint_type,
113 'build_interval': CONF.dns.build_interval,
114 'build_timeout': CONF.dns.build_timeout
115 })
116 return params
117
118
Graham Hayesc8114982016-07-04 17:46:08 +0100119class ManagerAdmin(clients.Manager):
120
121 def __init__(self, credentials=None, service=None):
122 super(ManagerAdmin, self).__init__(credentials, service)
123 self._init_clients(self._get_params())
124
125 def _init_clients(self, params):
126 self.quotas_client = AdminQuotaClient(**params)
127
128 def _get_params(self):
129 params = dict(self.default_params)
130 params.update({
131 'auth_provider': self.auth_provider,
132 'service': CONF.dns.catalog_type,
133 'region': CONF.identity.region,
134 'endpoint_type': CONF.dns.endpoint_type,
135 'build_interval': CONF.dns.build_interval,
136 'build_timeout': CONF.dns.build_timeout
137 })
138 return params
139
140
Paul Glassd56330a2016-06-13 21:03:33 +0000141class ManagerV2Unauthed(ManagerV2):
142
143 def __init__(self, credentials=None, service=None):
144 super(ManagerV2Unauthed, self).__init__(credentials, service)
Paul Glass4b07b382016-07-13 19:14:02 +0000145 self.auth_provider = self._auth_provider_class()(
Paul Glassd56330a2016-06-13 21:03:33 +0000146 credentials=self.auth_provider.credentials,
147 auth_url=self.auth_provider.auth_client.auth_url,
148 disable_ssl_certificate_validation=self.auth_provider.dscv,
149 ca_certs=self.auth_provider.ca_certs,
150 trace_requests=self.auth_provider.trace_requests,
151 )
152 self._init_clients(self._get_params())
153
Paul Glass4b07b382016-07-13 19:14:02 +0000154 def _auth_provider_class(self):
155 if CONF.identity.auth_version == 'v3':
156 return KeystoneV3UnauthedProvider
157 else:
158 return KeystoneV2UnauthedProvider
Paul Glassd56330a2016-06-13 21:03:33 +0000159
Paul Glass4b07b382016-07-13 19:14:02 +0000160
161class BaseUnauthedProvider(KeystoneAuthProvider):
Paul Glassd56330a2016-06-13 21:03:33 +0000162
163 def _decorate_request(self, filters, method, url, headers=None, body=None,
164 auth_data=None):
Paul Glass4b07b382016-07-13 19:14:02 +0000165 result = super(BaseUnauthedProvider, self)._decorate_request(
Paul Glassd56330a2016-06-13 21:03:33 +0000166 filters, method, url, headers=headers, body=body,
167 auth_data=auth_data)
168 url, headers, body = result
169 try:
170 del headers['X-Auth-Token']
171 except KeyError:
172 pass
173 return url, headers, body
Paul Glass4b07b382016-07-13 19:14:02 +0000174
175
176class KeystoneV2UnauthedProvider(KeystoneV2AuthProvider, BaseUnauthedProvider):
177
178 def _decorate_request(self, *args, **kwargs):
179 return BaseUnauthedProvider._decorate_request(self, *args, **kwargs)
180
181
182class KeystoneV3UnauthedProvider(KeystoneV3AuthProvider, BaseUnauthedProvider):
183
184 def _decorate_request(self, *args, **kwargs):
185 return BaseUnauthedProvider._decorate_request(self, *args, **kwargs)