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 | |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 16 | from tempest.lib.services.compute import keypairs_client |
| 17 | from tempest.lib.services.compute import servers_client |
Ken'ichi Ohmichi | b35c6cd | 2016-06-30 12:19:37 -0700 | [diff] [blame] | 18 | from tempest.lib.services.identity.v2 import tenants_client |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 19 | from tempest import manager |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 20 | |
| 21 | from neutron.tests.tempest import config |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 22 | from neutron.tests.tempest.services.network.json import network_client |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 23 | |
| 24 | CONF = config.CONF |
| 25 | |
| 26 | |
| 27 | class Manager(manager.Manager): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 28 | """ |
| 29 | Top level manager for OpenStack tempest clients |
| 30 | """ |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 31 | default_params = { |
| 32 | 'disable_ssl_certificate_validation': |
| 33 | CONF.identity.disable_ssl_certificate_validation, |
| 34 | 'ca_certs': CONF.identity.ca_certificates_file, |
| 35 | 'trace_requests': CONF.debug.trace_requests |
| 36 | } |
| 37 | |
| 38 | # NOTE: Tempest uses timeout values of compute API if project specific |
| 39 | # timeout values don't exist. |
| 40 | default_params_with_timeout_values = { |
| 41 | 'build_interval': CONF.compute.build_interval, |
| 42 | 'build_timeout': CONF.compute.build_timeout |
| 43 | } |
| 44 | default_params_with_timeout_values.update(default_params) |
| 45 | |
| 46 | def __init__(self, credentials=None, service=None): |
| 47 | super(Manager, self).__init__(credentials=credentials) |
| 48 | |
| 49 | self._set_identity_clients() |
| 50 | |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 51 | self.network_client = network_client.NetworkClientJSON( |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 52 | self.auth_provider, |
| 53 | CONF.network.catalog_type, |
| 54 | CONF.network.region or CONF.identity.region, |
| 55 | endpoint_type=CONF.network.endpoint_type, |
| 56 | build_interval=CONF.network.build_interval, |
| 57 | build_timeout=CONF.network.build_timeout, |
| 58 | **self.default_params) |
| 59 | |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 60 | params = { |
| 61 | 'service': CONF.compute.catalog_type, |
| 62 | 'region': CONF.compute.region or CONF.identity.region, |
| 63 | 'endpoint_type': CONF.compute.endpoint_type, |
| 64 | 'build_interval': CONF.compute.build_interval, |
| 65 | 'build_timeout': CONF.compute.build_timeout |
| 66 | } |
| 67 | params.update(self.default_params) |
| 68 | |
| 69 | self.servers_client = servers_client.ServersClient( |
| 70 | self.auth_provider, |
| 71 | enable_instance_password=CONF.compute_feature_enabled |
| 72 | .enable_instance_password, |
| 73 | **params) |
| 74 | self.keypairs_client = keypairs_client.KeyPairsClient( |
| 75 | self.auth_provider, **params) |
| 76 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 77 | def _set_identity_clients(self): |
| 78 | params = { |
| 79 | 'service': CONF.identity.catalog_type, |
| 80 | 'region': CONF.identity.region |
| 81 | } |
| 82 | params.update(self.default_params_with_timeout_values) |
| 83 | params_v2_admin = params.copy() |
| 84 | params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type |
| 85 | # Client uses admin endpoint type of Keystone API v2 |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 86 | self.tenants_client = tenants_client.TenantsClient(self.auth_provider, |
| 87 | **params_v2_admin) |