| 1 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 |
# not use this file except in compliance with the License. You may obtain |
| 3 |
# a copy of the License at |
| 4 |
# |
| 5 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 |
# |
| 7 |
# Unless required by applicable law or agreed to in writing, software |
| 8 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 |
# License for the specific language governing permissions and limitations |
| 11 |
# under the License. |
| 12 |
|
| 13 |
from tempest import clients |
| 14 |
from tempest.common import credentials_factory as common_creds |
| 15 |
|
| 16 |
from magnum_tempest_plugin.common import client |
| 17 |
from magnum_tempest_plugin.common import config |
| 18 |
from magnum_tempest_plugin.tests.api.v1.clients import cert_client |
| 19 |
from magnum_tempest_plugin.tests.api.v1.clients import cluster_client |
| 20 |
from magnum_tempest_plugin.tests.api.v1.clients import cluster_template_client |
| 21 |
from magnum_tempest_plugin.tests.api.v1.clients import magnum_service_client |
| 22 |
|
| 23 |
|
| 24 |
class Manager(clients.Manager): |
| 25 |
def __init__(self, credentials=None, request_type=None): |
| 26 |
if not credentials: |
| 27 |
credentials = common_creds.get_configured_credentials( |
| 28 |
'identity_admin') |
| 29 |
super(Manager, self).__init__(credentials) |
| 30 |
self.auth_provider.orig_base_url = self.auth_provider.base_url |
| 31 |
self.auth_provider.base_url = self.bypassed_base_url |
| 32 |
auth = self.auth_provider |
| 33 |
if request_type == 'cert': |
| 34 |
self.client = cert_client.CertClient(auth) |
| 35 |
elif request_type == 'cluster_template': |
| 36 |
self.client = cluster_template_client.ClusterTemplateClient(auth) |
| 37 |
elif request_type == 'cluster': |
| 38 |
self.client = cluster_client.ClusterClient(auth) |
| 39 |
elif request_type == 'service': |
| 40 |
self.client = magnum_service_client.MagnumServiceClient(auth) |
| 41 |
else: |
| 42 |
self.client = client.MagnumClient(auth) |
| 43 |
|
| 44 |
def bypassed_base_url(self, filters, auth_data=None): |
| 45 |
if (config.Config.magnum_url |
| 46 |
and filters['service'] == 'container-infra'): |
| 47 |
return config.Config.magnum_url |
| 48 |
return self.auth_provider.orig_base_url(filters, auth_data=auth_data) |
| 49 |
|
| 50 |
|
| 51 |
class DefaultManager(Manager): |
| 52 |
def __init__(self, credentials, request_type=None): |
| 53 |
super(DefaultManager, self).__init__(credentials, request_type) |
| 54 |
|
| 55 |
|
| 56 |
class AltManager(Manager): |
| 57 |
def __init__(self, credentials, request_type=None): |
| 58 |
super(AltManager, self).__init__(credentials, request_type) |
| 59 |
|
| 60 |
|
| 61 |
class AdminManager(Manager): |
| 62 |
def __init__(self, credentials, request_type=None): |
| 63 |
super(AdminManager, self).__init__(credentials, request_type) |