Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2012 OpenStack, LLC |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 18 | import ConfigParser |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 19 | import logging |
| 20 | import os |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 21 | |
kavan-patil | 4ea2efb | 2011-12-09 08:58:50 +0000 | [diff] [blame] | 22 | from tempest.common.utils import data_utils |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 23 | |
| 24 | LOG = logging.getLogger(__name__) |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 25 | |
| 26 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 27 | class BaseConfig(object): |
| 28 | |
| 29 | SECTION_NAME = None |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 30 | |
| 31 | def __init__(self, conf): |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 32 | self.conf = conf |
| 33 | |
donald-ngo | 7fb1efa | 2011-12-13 17:17:36 -0800 | [diff] [blame] | 34 | def get(self, item_name, default_value=None): |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 35 | try: |
Rohit Karajgi | cfc0c02 | 2012-07-17 23:11:38 -0700 | [diff] [blame] | 36 | return self.conf.get(self.SECTION_NAME, item_name, raw=True) |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 37 | except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): |
| 38 | return default_value |
| 39 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 40 | |
| 41 | class IdentityConfig(BaseConfig): |
| 42 | |
| 43 | """Provides configuration information for authenticating with Keystone.""" |
| 44 | |
| 45 | SECTION_NAME = "identity" |
| 46 | |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 47 | @property |
chris fattarsi | 8ed39ac | 2012-04-30 14:11:27 -0700 | [diff] [blame] | 48 | def catalog_type(self): |
| 49 | """Catalog type of the Identity service.""" |
| 50 | return self.get("catalog_type", 'identity') |
| 51 | |
| 52 | @property |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame] | 53 | def host(self): |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 54 | """Host IP for making Identity API requests.""" |
donald-ngo | 7fb1efa | 2011-12-13 17:17:36 -0800 | [diff] [blame] | 55 | return self.get("host", "127.0.0.1") |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame] | 56 | |
| 57 | @property |
| 58 | def port(self): |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 59 | """Port for the Identity service.""" |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame] | 60 | return self.get("port", "8773") |
| 61 | |
| 62 | @property |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 63 | def api_version(self): |
| 64 | """Version of the Identity API""" |
| 65 | return self.get("api_version", "v1.1") |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame] | 66 | |
| 67 | @property |
| 68 | def path(self): |
| 69 | """Path of API request""" |
| 70 | return self.get("path", "/") |
| 71 | |
kavan-patil | 4ea2efb | 2011-12-09 08:58:50 +0000 | [diff] [blame] | 72 | @property |
| 73 | def auth_url(self): |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 74 | """The Identity URL (derived)""" |
kavan-patil | 4ea2efb | 2011-12-09 08:58:50 +0000 | [diff] [blame] | 75 | auth_url = data_utils.build_url(self.host, |
| 76 | self.port, |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 77 | self.api_version, |
donald-ngo | 7fb1efa | 2011-12-13 17:17:36 -0800 | [diff] [blame] | 78 | self.path, |
| 79 | use_ssl=self.use_ssl) |
kavan-patil | 4ea2efb | 2011-12-09 08:58:50 +0000 | [diff] [blame] | 80 | return auth_url |
| 81 | |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 82 | @property |
donald-ngo | 7fb1efa | 2011-12-13 17:17:36 -0800 | [diff] [blame] | 83 | def use_ssl(self): |
| 84 | """Specifies if we are using https.""" |
Dan Prince | 9519592 | 2012-03-12 15:14:51 -0400 | [diff] [blame] | 85 | return self.get("use_ssl", 'false').lower() != 'false' |
donald-ngo | 7fb1efa | 2011-12-13 17:17:36 -0800 | [diff] [blame] | 86 | |
| 87 | @property |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 88 | def strategy(self): |
| 89 | """Which auth method does the environment use? (basic|keystone)""" |
| 90 | return self.get("strategy", 'keystone') |
| 91 | |
| 92 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 93 | class IdentityAdminConfig(BaseConfig): |
| 94 | |
| 95 | SECTION_NAME = "identity-admin" |
| 96 | |
| 97 | @property |
| 98 | def username(self): |
| 99 | """Username to use for Identity Admin API requests""" |
| 100 | return self.get("username", "admin") |
| 101 | |
| 102 | @property |
| 103 | def tenant_name(self): |
| 104 | """Tenant name to use for Identity Admin API requests""" |
| 105 | return self.get("tenant_name", "admin") |
| 106 | |
| 107 | @property |
| 108 | def password(self): |
| 109 | """API key to use for Identity Admin API requests""" |
| 110 | return self.get("password", "pass") |
| 111 | |
| 112 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 113 | class ComputeConfig(BaseConfig): |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 114 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 115 | SECTION_NAME = "compute" |
| 116 | |
| 117 | @property |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 118 | def allow_tenant_isolation(self): |
| 119 | """ |
| 120 | Allows test cases to create/destroy tenants and users. This option |
| 121 | enables isolated test cases and better parallel execution, |
| 122 | but also requires that OpenStack Identity API admin credentials |
| 123 | are known. |
| 124 | """ |
| 125 | return self.get("allow_tenant_isolation", 'false').lower() != 'false' |
| 126 | |
| 127 | @property |
Dan Smith | d6ff6b7 | 2012-08-23 10:29:41 -0700 | [diff] [blame] | 128 | def allow_tenant_reuse(self): |
| 129 | """ |
| 130 | If allow_tenant_isolation is True and a tenant that would be created |
| 131 | for a given test already exists (such as from a previously-failed run), |
| 132 | re-use that tenant instead of failing because of the conflict. Note |
| 133 | that this would result in the tenant being deleted at the end of a |
| 134 | subsequent successful run. |
| 135 | """ |
| 136 | return self.get("allow_tenant_reuse", 'true').lower() != 'false' |
| 137 | |
| 138 | @property |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 139 | def username(self): |
| 140 | """Username to use for Nova API requests.""" |
| 141 | return self.get("username", "demo") |
| 142 | |
| 143 | @property |
| 144 | def tenant_name(self): |
| 145 | """Tenant name to use for Nova API requests.""" |
| 146 | return self.get("tenant_name", "demo") |
| 147 | |
| 148 | @property |
| 149 | def password(self): |
| 150 | """API key to use when authenticating.""" |
| 151 | return self.get("password", "pass") |
| 152 | |
| 153 | @property |
| 154 | def alt_username(self): |
| 155 | """Username of alternate user to use for Nova API requests.""" |
David Kranz | 7490e95 | 2012-04-02 13:28:27 -0400 | [diff] [blame] | 156 | return self.get("alt_username") |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 157 | |
| 158 | @property |
| 159 | def alt_tenant_name(self): |
| 160 | """Alternate user's Tenant name to use for Nova API requests.""" |
David Kranz | 7490e95 | 2012-04-02 13:28:27 -0400 | [diff] [blame] | 161 | return self.get("alt_tenant_name") |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 162 | |
| 163 | @property |
| 164 | def alt_password(self): |
| 165 | """API key to use when authenticating as alternate user.""" |
David Kranz | 7490e95 | 2012-04-02 13:28:27 -0400 | [diff] [blame] | 166 | return self.get("alt_password") |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 167 | |
| 168 | @property |
| 169 | def image_ref(self): |
| 170 | """Valid primary image to use in tests.""" |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 171 | return self.get("image_ref", "{$IMAGE_ID}") |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 172 | |
| 173 | @property |
| 174 | def image_ref_alt(self): |
| 175 | """Valid secondary image reference to be used in tests.""" |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 176 | return self.get("image_ref_alt", "{$IMAGE_ID_ALT}") |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 177 | |
| 178 | @property |
| 179 | def flavor_ref(self): |
| 180 | """Valid primary flavor to use in tests.""" |
| 181 | return self.get("flavor_ref", 1) |
| 182 | |
| 183 | @property |
| 184 | def flavor_ref_alt(self): |
| 185 | """Valid secondary flavor to be used in tests.""" |
| 186 | return self.get("flavor_ref_alt", 2) |
| 187 | |
| 188 | @property |
| 189 | def resize_available(self): |
| 190 | """Does the test environment support resizing?""" |
Dan Prince | 9519592 | 2012-03-12 15:14:51 -0400 | [diff] [blame] | 191 | return self.get("resize_available", 'false').lower() != 'false' |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 192 | |
| 193 | @property |
David Kranz | f97d5fd | 2012-07-30 13:46:45 -0400 | [diff] [blame] | 194 | def change_password_available(self): |
| 195 | """Does the test environment support changing the admin password?""" |
| 196 | return self.get("change_password_available", 'false').lower() != \ |
| 197 | 'false' |
| 198 | |
| 199 | @property |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 200 | def create_image_enabled(self): |
| 201 | """Does the test environment support snapshots?""" |
Dan Prince | 9519592 | 2012-03-12 15:14:51 -0400 | [diff] [blame] | 202 | return self.get("create_image_enabled", 'false').lower() != 'false' |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 203 | |
| 204 | @property |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 205 | def build_interval(self): |
| 206 | """Time in seconds between build status checks.""" |
| 207 | return float(self.get("build_interval", 10)) |
| 208 | |
| 209 | @property |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 210 | def build_timeout(self): |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 211 | """Timeout in seconds to wait for an instance to build.""" |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 212 | return float(self.get("build_timeout", 300)) |
| 213 | |
Daryl Walleck | 4aa82a9 | 2012-02-14 15:45:46 -0600 | [diff] [blame] | 214 | @property |
Daryl Walleck | 6b9b288 | 2012-04-08 21:43:39 -0500 | [diff] [blame] | 215 | def run_ssh(self): |
| 216 | """Does the test environment support snapshots?""" |
| 217 | return self.get("run_ssh", 'false').lower() != 'false' |
| 218 | |
| 219 | @property |
| 220 | def ssh_user(self): |
| 221 | """User name used to authenticate to an instance.""" |
| 222 | return self.get("ssh_user", "root") |
| 223 | |
| 224 | @property |
| 225 | def ssh_timeout(self): |
| 226 | """Timeout in seconds to wait for authentcation to succeed.""" |
| 227 | return float(self.get("ssh_timeout", 300)) |
| 228 | |
| 229 | @property |
| 230 | def network_for_ssh(self): |
| 231 | """Network used for SSH connections.""" |
| 232 | return self.get("network_for_ssh", "public") |
| 233 | |
| 234 | @property |
| 235 | def ip_version_for_ssh(self): |
| 236 | """IP version used for SSH connections.""" |
| 237 | return int(self.get("ip_version_for_ssh", 4)) |
| 238 | |
| 239 | @property |
Daryl Walleck | b90a1a6 | 2012-02-27 11:23:10 -0600 | [diff] [blame] | 240 | def catalog_type(self): |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 241 | """Catalog type of the Compute service.""" |
Daryl Walleck | b90a1a6 | 2012-02-27 11:23:10 -0600 | [diff] [blame] | 242 | return self.get("catalog_type", 'compute') |
Daryl Walleck | 4aa82a9 | 2012-02-14 15:45:46 -0600 | [diff] [blame] | 243 | |
David Kranz | 180fed1 | 2012-03-27 14:31:29 -0400 | [diff] [blame] | 244 | @property |
| 245 | def log_level(self): |
| 246 | """Level for logging compute API calls.""" |
| 247 | return self.get("log_level", 'ERROR') |
| 248 | |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 249 | @property |
| 250 | def whitebox_enabled(self): |
| 251 | """Does the test environment support whitebox tests for Compute?""" |
| 252 | return self.get("whitebox_enabled", 'false').lower() != 'false' |
| 253 | |
| 254 | @property |
| 255 | def db_uri(self): |
| 256 | """Connection string to the database of Compute service""" |
| 257 | return self.get("db_uri", None) |
| 258 | |
| 259 | @property |
| 260 | def source_dir(self): |
| 261 | """Path of nova source directory""" |
| 262 | return self.get("source_dir", "/opt/stack/nova") |
| 263 | |
| 264 | @property |
| 265 | def config_path(self): |
| 266 | """Path of nova configuration file""" |
| 267 | return self.get("config_path", "/etc/nova/nova.conf") |
| 268 | |
| 269 | @property |
| 270 | def bin_dir(self): |
| 271 | """Directory containing nova binaries such as nova-manage""" |
| 272 | return self.get("bin_dir", "/usr/local/bin/") |
| 273 | |
| 274 | @property |
| 275 | def path_to_private_key(self): |
| 276 | """Path to a private key file for SSH access to remote hosts""" |
| 277 | return self.get("path_to_private_key") |
| 278 | |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 279 | |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 280 | class ComputeAdminConfig(BaseConfig): |
| 281 | |
| 282 | SECTION_NAME = "compute-admin" |
| 283 | |
| 284 | @property |
| 285 | def username(self): |
| 286 | """Administrative Username to use for Nova API requests.""" |
| 287 | return self.get("username", "admin") |
| 288 | |
| 289 | @property |
| 290 | def tenant_name(self): |
| 291 | """Administrative Tenant name to use for Nova API requests.""" |
| 292 | return self.get("tenant_name", "admin") |
| 293 | |
| 294 | @property |
| 295 | def password(self): |
| 296 | """API key to use when authenticating as admin.""" |
| 297 | return self.get("password", "pass") |
| 298 | |
| 299 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 300 | class ImagesConfig(BaseConfig): |
| 301 | |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 302 | """ |
| 303 | Provides configuration information for connecting to an |
| 304 | OpenStack Images service. |
| 305 | """ |
| 306 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 307 | SECTION_NAME = "image" |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 308 | |
| 309 | @property |
| 310 | def host(self): |
| 311 | """Host IP for making Images API requests. Defaults to '127.0.0.1'.""" |
| 312 | return self.get("host", "127.0.0.1") |
| 313 | |
| 314 | @property |
| 315 | def port(self): |
| 316 | """Listen port of the Images service.""" |
| 317 | return int(self.get("port", "9292")) |
| 318 | |
| 319 | @property |
| 320 | def api_version(self): |
| 321 | """Version of the API""" |
| 322 | return self.get("api_version", "1") |
| 323 | |
| 324 | @property |
| 325 | def username(self): |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 326 | """Username to use for Images API requests. Defaults to 'demo'.""" |
Julien Danjou | 75a677e | 2012-04-11 15:49:15 +0200 | [diff] [blame] | 327 | return self.get("username", "demo") |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 328 | |
| 329 | @property |
| 330 | def password(self): |
| 331 | """Password for user""" |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 332 | return self.get("password", "pass") |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 333 | |
| 334 | @property |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 335 | def tenant_name(self): |
| 336 | """Tenant to use for Images API requests. Defaults to 'demo'.""" |
| 337 | return self.get("tenant_name", "demo") |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 338 | |
| 339 | |
Unmesh Gurjar | 4498683 | 2012-05-08 19:57:10 +0530 | [diff] [blame] | 340 | class NetworkConfig(BaseConfig): |
| 341 | """Provides configuration information for connecting to an OpenStack |
| 342 | Network Service. |
| 343 | """ |
| 344 | |
| 345 | SECTION_NAME = "network" |
| 346 | |
| 347 | @property |
| 348 | def catalog_type(self): |
| 349 | """Catalog type of the Quantum service.""" |
| 350 | return self.get("catalog_type", 'network') |
| 351 | |
| 352 | @property |
| 353 | def api_version(self): |
| 354 | """Version of Quantum API""" |
| 355 | return self.get("api_version", "v1.1") |
| 356 | |
| 357 | |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 358 | class VolumeConfig(BaseConfig): |
| 359 | """Provides configuration information for connecting to an OpenStack Block |
| 360 | Storage Service. |
| 361 | """ |
| 362 | |
| 363 | SECTION_NAME = "volume" |
| 364 | |
| 365 | @property |
| 366 | def build_interval(self): |
| 367 | """Time in seconds between volume availability checks.""" |
| 368 | return float(self.get("build_interval", 10)) |
| 369 | |
| 370 | @property |
| 371 | def build_timeout(self): |
| 372 | """Timeout in seconds to wait for a volume to become available.""" |
| 373 | return float(self.get("build_timeout", 300)) |
| 374 | |
| 375 | @property |
| 376 | def catalog_type(self): |
| 377 | """Catalog type of the Volume Service""" |
| 378 | return self.get("catalog_type", 'volume') |
| 379 | |
| 380 | |
| 381 | # TODO(jaypipes): Move this to a common utils (not data_utils...) |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 382 | def singleton(cls): |
| 383 | """Simple wrapper for classes that should only have a single instance""" |
| 384 | instances = {} |
| 385 | |
| 386 | def getinstance(): |
| 387 | if cls not in instances: |
| 388 | instances[cls] = cls() |
| 389 | return instances[cls] |
| 390 | return getinstance |
| 391 | |
| 392 | |
| 393 | @singleton |
| 394 | class TempestConfig: |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 395 | """Provides OpenStack configuration information.""" |
| 396 | |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 397 | DEFAULT_CONFIG_DIR = os.path.join( |
| 398 | os.path.abspath( |
| 399 | os.path.dirname( |
| 400 | os.path.dirname(__file__))), |
| 401 | "etc") |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 402 | |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 403 | DEFAULT_CONFIG_FILE = "tempest.conf" |
| 404 | |
| 405 | def __init__(self): |
| 406 | """Initialize a configuration from a conf directory and conf file.""" |
| 407 | |
| 408 | # Environment variables override defaults... |
| 409 | conf_dir = os.environ.get('TEMPEST_CONFIG_DIR', |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 410 | self.DEFAULT_CONFIG_DIR) |
| 411 | conf_file = os.environ.get('TEMPEST_CONFIG', self.DEFAULT_CONFIG_FILE) |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 412 | |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 413 | path = os.path.join(conf_dir, conf_file) |
| 414 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 415 | LOG.info("Using tempest config file %s" % path) |
| 416 | |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 417 | if not os.path.exists(path): |
| 418 | msg = "Config file %(path)s not found" % locals() |
| 419 | raise RuntimeError(msg) |
| 420 | |
| 421 | self._conf = self.load_config(path) |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 422 | self.compute = ComputeConfig(self._conf) |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 423 | self.compute_admin = ComputeAdminConfig(self._conf) |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 424 | self.identity = IdentityConfig(self._conf) |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 425 | self.identity_admin = IdentityAdminConfig(self._conf) |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 426 | self.images = ImagesConfig(self._conf) |
Unmesh Gurjar | 4498683 | 2012-05-08 19:57:10 +0530 | [diff] [blame] | 427 | self.network = NetworkConfig(self._conf) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 428 | self.volume = VolumeConfig(self._conf) |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 429 | |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 430 | def load_config(self, path): |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 431 | """Read configuration from given path and return a config object.""" |
| 432 | config = ConfigParser.SafeConfigParser() |
| 433 | config.read(path) |
| 434 | return config |