Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame^] | 1 | # Copyright 2012 OpenStack Foundation |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | from tempest import manager |
| 17 | from tempest.services.identity.v2.json.tenants_client import \ |
| 18 | TenantsClient |
| 19 | |
| 20 | from neutron.tests.tempest import config |
| 21 | from neutron.tests.tempest.services.network.json.network_client import \ |
| 22 | NetworkClientJSON |
| 23 | |
| 24 | |
| 25 | CONF = config.CONF |
| 26 | |
| 27 | |
| 28 | class Manager(manager.Manager): |
| 29 | |
| 30 | """ |
| 31 | Top level manager for OpenStack tempest clients |
| 32 | """ |
| 33 | |
| 34 | default_params = { |
| 35 | 'disable_ssl_certificate_validation': |
| 36 | CONF.identity.disable_ssl_certificate_validation, |
| 37 | 'ca_certs': CONF.identity.ca_certificates_file, |
| 38 | 'trace_requests': CONF.debug.trace_requests |
| 39 | } |
| 40 | |
| 41 | # NOTE: Tempest uses timeout values of compute API if project specific |
| 42 | # timeout values don't exist. |
| 43 | default_params_with_timeout_values = { |
| 44 | 'build_interval': CONF.compute.build_interval, |
| 45 | 'build_timeout': CONF.compute.build_timeout |
| 46 | } |
| 47 | default_params_with_timeout_values.update(default_params) |
| 48 | |
| 49 | def __init__(self, credentials=None, service=None): |
| 50 | super(Manager, self).__init__(credentials=credentials) |
| 51 | |
| 52 | self._set_identity_clients() |
| 53 | |
| 54 | self.network_client = NetworkClientJSON( |
| 55 | self.auth_provider, |
| 56 | CONF.network.catalog_type, |
| 57 | CONF.network.region or CONF.identity.region, |
| 58 | endpoint_type=CONF.network.endpoint_type, |
| 59 | build_interval=CONF.network.build_interval, |
| 60 | build_timeout=CONF.network.build_timeout, |
| 61 | **self.default_params) |
| 62 | |
| 63 | def _set_identity_clients(self): |
| 64 | params = { |
| 65 | 'service': CONF.identity.catalog_type, |
| 66 | 'region': CONF.identity.region |
| 67 | } |
| 68 | params.update(self.default_params_with_timeout_values) |
| 69 | params_v2_admin = params.copy() |
| 70 | params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type |
| 71 | # Client uses admin endpoint type of Keystone API v2 |
| 72 | self.tenants_client = TenantsClient(self.auth_provider, |
| 73 | **params_v2_admin) |