| 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 |
import ast |
| 14 |
|
| 15 |
from tempest import config |
| 16 |
|
| 17 |
|
| 18 |
CONF = config.CONF |
| 19 |
|
| 20 |
|
| 21 |
class Config(object): |
| 22 |
|
| 23 |
"""Parses configuration to attributes required for auth and test data""" |
| 24 |
|
| 25 |
@classmethod |
| 26 |
def set_admin_creds(cls, config): |
| 27 |
cls.admin_user = CONF.auth.admin_username |
| 28 |
cls.admin_passwd = CONF.auth.admin_password |
| 29 |
cls.admin_tenant = CONF.auth.admin_project_name |
| 30 |
|
| 31 |
@classmethod |
| 32 |
def set_user_creds(cls, config): |
| 33 |
# normal user creds |
| 34 |
# Fixme(eliqiao): this is quick workaround to passing tempest |
| 35 |
# legacy credentials provider is removed by tempest |
| 36 |
# I8c24cd17f643083dde71ab2bd2a38417c54aeccb. |
| 37 |
# TODO(eliqiao): find a way to using an accounts.yaml file |
| 38 |
# check Ia5132c5cb32355d6f26b8acdd92a0e55a2c19f41 |
| 39 |
cls.user = CONF.auth.admin_username |
| 40 |
cls.passwd = CONF.auth.admin_password |
| 41 |
cls.tenant = CONF.auth.admin_project_name |
| 42 |
|
| 43 |
@classmethod |
| 44 |
def set_auth_version(cls, config): |
| 45 |
# auth version for client authentication |
| 46 |
cls.auth_version = CONF.identity.auth_version |
| 47 |
|
| 48 |
@classmethod |
| 49 |
def set_auth_url(cls, config): |
| 50 |
# auth_url for client authentication |
| 51 |
if cls.auth_version == 'v3': |
| 52 |
cls.auth_v3_url = CONF.identity.uri_v3 |
| 53 |
else: |
| 54 |
if 'uri' not in CONF.identity: |
| 55 |
raise Exception('config missing auth_url key') |
| 56 |
cls.auth_url = CONF.identity.uri |
| 57 |
|
| 58 |
@classmethod |
| 59 |
def set_admin_role(cls, config): |
| 60 |
# admin_role for client authentication |
| 61 |
if cls.auth_version == 'v3': |
| 62 |
cls.admin_role = CONF.identity.admin_role |
| 63 |
else: |
| 64 |
cls.admin_role = 'admin' |
| 65 |
|
| 66 |
@classmethod |
| 67 |
def set_docker_storage_driver(cls, config): |
| 68 |
cls.docker_storage_driver = CONF.magnum.get('docker_storage_driver') |
| 69 |
|
| 70 |
@classmethod |
| 71 |
def set_region(cls, config): |
| 72 |
if 'region' in CONF.identity: |
| 73 |
cls.region = CONF.identity.region |
| 74 |
else: |
| 75 |
cls.region = 'RegionOne' |
| 76 |
|
| 77 |
@classmethod |
| 78 |
def set_image_id(cls, config): |
| 79 |
if 'image_id' not in CONF.magnum: |
| 80 |
raise Exception('config missing image_id key') |
| 81 |
cls.image_id = CONF.magnum.image_id |
| 82 |
|
| 83 |
@classmethod |
| 84 |
def set_nic_id(cls, config): |
| 85 |
if 'nic_id' not in CONF.magnum: |
| 86 |
raise Exception('config missing nic_id key') |
| 87 |
cls.nic_id = CONF.magnum.nic_id |
| 88 |
|
| 89 |
@classmethod |
| 90 |
def set_keypair_name(cls, config): |
| 91 |
if 'keypair_name' not in CONF.magnum: |
| 92 |
raise Exception('config missing keypair_name key') |
| 93 |
cls.keypair_name = CONF.magnum.keypair_name |
| 94 |
|
| 95 |
@classmethod |
| 96 |
def set_flavor_id(cls, config): |
| 97 |
if 'flavor_id' not in CONF.magnum: |
| 98 |
raise Exception('config missing flavor_id key') |
| 99 |
cls.flavor_id = CONF.magnum.flavor_id |
| 100 |
|
| 101 |
@classmethod |
| 102 |
def set_magnum_url(cls, config): |
| 103 |
cls.magnum_url = CONF.magnum.get('magnum_url', None) |
| 104 |
|
| 105 |
@classmethod |
| 106 |
def set_master_flavor_id(cls, config): |
| 107 |
if 'master_flavor_id' not in CONF.magnum: |
| 108 |
raise Exception('config missing master_flavor_id key') |
| 109 |
cls.master_flavor_id = CONF.magnum.master_flavor_id |
| 110 |
|
| 111 |
@classmethod |
| 112 |
def set_dns_nameserver(cls, config): |
| 113 |
if 'dns_nameserver' not in CONF.magnum: |
| 114 |
raise Exception('config missing dns_nameserver') |
| 115 |
cls.dns_nameserver = CONF.magnum.dns_nameserver |
| 116 |
|
| 117 |
@classmethod |
| 118 |
def set_copy_logs(cls, config): |
| 119 |
cls.copy_logs = CONF.magnum.get('copy_logs', True) |
| 120 |
cls.copy_logs_success = CONF.magnum.get('copy_logs_success', True) |
| 121 |
|
| 122 |
@classmethod |
| 123 |
def set_coe(cls, config): |
| 124 |
cls.coe = CONF.magnum.coe |
| 125 |
|
| 126 |
@classmethod |
| 127 |
def set_network_driver(cls, config): |
| 128 |
cls.network_driver = CONF.magnum.network_driver |
| 129 |
|
| 130 |
@classmethod |
| 131 |
def set_cluster_template_id(cls, config): |
| 132 |
cls.cluster_template_id = CONF.magnum.cluster_template_id |
| 133 |
|
| 134 |
@classmethod |
| 135 |
def set_cluster_creation_timeout(cls, config): |
| 136 |
cls.cluster_creation_timeout = CONF.magnum.cluster_creation_timeout |
| 137 |
|
| 138 |
@classmethod |
| 139 |
def set_labels(cls, config): |
| 140 |
cls.labels = ast.literal_eval(CONF.magnum.labels) |
| 141 |
|
| 142 |
@classmethod |
| 143 |
def setUp(cls): |
| 144 |
cls.set_admin_creds(config) |
| 145 |
cls.set_user_creds(config) |
| 146 |
cls.set_auth_version(config) |
| 147 |
cls.set_auth_url(config) |
| 148 |
cls.set_admin_role(config) |
| 149 |
|
| 150 |
cls.set_docker_storage_driver(config) |
| 151 |
cls.set_region(config) |
| 152 |
cls.set_image_id(config) |
| 153 |
cls.set_nic_id(config) |
| 154 |
cls.set_keypair_name(config) |
| 155 |
cls.set_flavor_id(config) |
| 156 |
cls.set_magnum_url(config) |
| 157 |
cls.set_master_flavor_id(config) |
| 158 |
cls.set_dns_nameserver(config) |
| 159 |
cls.set_copy_logs(config) |
| 160 |
cls.set_coe(config) |
| 161 |
cls.set_network_driver(config) |
| 162 |
cls.set_cluster_template_id(config) |
| 163 |
cls.set_cluster_creation_timeout(config) |
| 164 |
cls.set_labels(config) |