blob: 59d6888eb23962b69efb10b568f38a15825f9f2b [file] [log] [blame]
Jay Pipes3f981df2012-03-27 18:59:44 -04001# 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
Jay Pipes7f757632011-12-02 15:53:32 -050018import os
Attila Fazekas5abb2532012-12-04 11:30:49 +010019import sys
Jay Pipes3f981df2012-03-27 18:59:44 -040020
Matthew Treinish90aedd12013-02-25 17:56:49 -050021from oslo.config import cfg
22
Mitsuhiko Yamazaki46818aa2013-04-18 17:49:17 +090023from tempest.common import log as logging
Attila Fazekas3e1b6742013-01-28 16:30:35 +010024from tempest.common.utils.misc import singleton
Jay Pipes7f757632011-12-02 15:53:32 -050025
26LOG = logging.getLogger(__name__)
Daryl Walleck1465d612011-11-02 02:22:15 -050027
Matthew Treinish39e48ef2012-12-21 13:36:15 -050028identity_group = cfg.OptGroup(name='identity',
29 title="Keystone Configuration Options")
Daryl Walleck1465d612011-11-02 02:22:15 -050030
Matthew Treinish39e48ef2012-12-21 13:36:15 -050031IdentityGroup = [
32 cfg.StrOpt('catalog_type',
33 default='identity',
34 help="Catalog type of the Identity service."),
Jay Pipescd8eaec2013-01-16 21:03:48 -050035 cfg.BoolOpt('disable_ssl_certificate_validation',
36 default=False,
37 help="Set to True if using self-signed SSL certificates."),
Jay Pipes7c88eb22013-01-16 21:32:43 -050038 cfg.StrOpt('uri',
39 default=None,
40 help="Full URI of the OpenStack Identity API (Keystone)"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -050041 cfg.StrOpt('strategy',
42 default='keystone',
43 help="Which auth method does the environment use? "
44 "(basic|keystone)"),
45 cfg.StrOpt('region',
Attila Fazekascadcb1f2013-01-21 23:10:53 +010046 default='RegionOne',
Matthew Treinish39e48ef2012-12-21 13:36:15 -050047 help="The identity region name to use."),
Attila Fazekascadcb1f2013-01-21 23:10:53 +010048 cfg.StrOpt('username',
49 default='demo',
50 help="Username to use for Nova API requests."),
51 cfg.StrOpt('tenant_name',
52 default='demo',
53 help="Tenant name to use for Nova API requests."),
54 cfg.StrOpt('password',
55 default='pass',
56 help="API key to use when authenticating.",
57 secret=True),
58 cfg.StrOpt('alt_username',
59 default=None,
60 help="Username of alternate user to use for Nova API "
61 "requests."),
62 cfg.StrOpt('alt_tenant_name',
63 default=None,
64 help="Alternate user's Tenant name to use for Nova API "
65 "requests."),
66 cfg.StrOpt('alt_password',
67 default=None,
68 help="API key to use when authenticating as alternate user.",
69 secret=True),
70 cfg.StrOpt('admin_username',
71 default='admin',
72 help="Administrative Username to use for"
73 "Keystone API requests."),
74 cfg.StrOpt('admin_tenant_name',
75 default='admin',
76 help="Administrative Tenant name to use for Keystone API "
77 "requests."),
78 cfg.StrOpt('admin_password',
79 default='pass',
80 help="API key to use when authenticating as admin.",
81 secret=True),
Matthew Treinish39e48ef2012-12-21 13:36:15 -050082]
Jay Pipes3f981df2012-03-27 18:59:44 -040083
Daryl Walleck1465d612011-11-02 02:22:15 -050084
Matthew Treinish39e48ef2012-12-21 13:36:15 -050085def register_identity_opts(conf):
86 conf.register_group(identity_group)
87 for opt in IdentityGroup:
88 conf.register_opt(opt, group='identity')
Daryl Walleck1465d612011-11-02 02:22:15 -050089
Jay Pipes3f981df2012-03-27 18:59:44 -040090
Matthew Treinish39e48ef2012-12-21 13:36:15 -050091compute_group = cfg.OptGroup(name='compute',
92 title='Compute Service Options')
Rohit Karajgie1b050d2011-12-02 16:13:18 -080093
Matthew Treinish39e48ef2012-12-21 13:36:15 -050094ComputeGroup = [
95 cfg.BoolOpt('allow_tenant_isolation',
96 default=False,
97 help="Allows test cases to create/destroy tenants and "
98 "users. This option enables isolated test cases and "
99 "better parallel execution, but also requires that "
100 "OpenStack Identity API admin credentials are known."),
101 cfg.BoolOpt('allow_tenant_reuse',
102 default=True,
103 help="If allow_tenant_isolation is True and a tenant that "
104 "would be created for a given test already exists (such "
105 "as from a previously-failed run), re-use that tenant "
106 "instead of failing because of the conflict. Note that "
107 "this would result in the tenant being deleted at the "
108 "end of a subsequent successful run."),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500109 cfg.StrOpt('image_ref',
110 default="{$IMAGE_ID}",
111 help="Valid secondary image reference to be used in tests."),
112 cfg.StrOpt('image_ref_alt',
113 default="{$IMAGE_ID_ALT}",
114 help="Valid secondary image reference to be used in tests."),
115 cfg.IntOpt('flavor_ref',
116 default=1,
117 help="Valid primary flavor to use in tests."),
118 cfg.IntOpt('flavor_ref_alt',
119 default=2,
120 help='Valid secondary flavor to be used in tests.'),
121 cfg.BoolOpt('resize_available',
122 default=False,
123 help="Does the test environment support resizing?"),
124 cfg.BoolOpt('live_migration_available',
125 default=False,
126 help="Does the test environment support live migration "
127 "available?"),
128 cfg.BoolOpt('use_block_migration_for_live_migration',
129 default=False,
130 help="Does the test environment use block devices for live "
131 "migration"),
Bob Ballc078be92013-04-09 14:25:00 +0100132 cfg.BoolOpt('block_migrate_supports_cinder_iscsi',
133 default=False,
134 help="Does the test environment block migration support "
135 "cinder iSCSI volumes"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500136 cfg.BoolOpt('change_password_available',
137 default=False,
138 help="Does the test environment support changing the admin "
139 "password?"),
140 cfg.BoolOpt('create_image_enabled',
141 default=False,
142 help="Does the test environment support snapshots?"),
143 cfg.IntOpt('build_interval',
144 default=10,
145 help="Time in seconds between build status checks."),
146 cfg.IntOpt('build_timeout',
147 default=300,
148 help="Timeout in seconds to wait for an instance to build."),
149 cfg.BoolOpt('run_ssh',
150 default=False,
151 help="Does the test environment support snapshots?"),
152 cfg.StrOpt('ssh_user',
153 default='root',
154 help="User name used to authenticate to an instance."),
155 cfg.IntOpt('ssh_timeout',
156 default=300,
Chris Yeoh76916042013-02-27 16:25:25 +1030157 help="Timeout in seconds to wait for authentication to "
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500158 "succeed."),
Chris Yeoh76916042013-02-27 16:25:25 +1030159 cfg.IntOpt('ssh_channel_timeout',
160 default=60,
161 help="Timeout in seconds to wait for output from ssh "
162 "channel."),
Attila Fazekasb0661652013-05-08 13:01:36 +0200163 cfg.StrOpt('fixed_network_name',
164 default='private',
165 help="Visible fixed network name "),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500166 cfg.StrOpt('network_for_ssh',
167 default='public',
168 help="Network used for SSH connections."),
169 cfg.IntOpt('ip_version_for_ssh',
170 default=4,
171 help="IP version used for SSH connections."),
172 cfg.StrOpt('catalog_type',
173 default='compute',
174 help="Catalog type of the Compute service."),
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100175 cfg.StrOpt('path_to_private_key',
176 default=None,
177 help="Path to a private key file for SSH access to remote "
178 "hosts"),
179 cfg.BoolOpt('disk_config_enabled_override',
180 default=True,
181 help="If false, skip config tests regardless of the "
182 "extension status"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500183]
Rohit Karajgie1b050d2011-12-02 16:13:18 -0800184
Rohit Karajgie1b050d2011-12-02 16:13:18 -0800185
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500186def register_compute_opts(conf):
187 conf.register_group(compute_group)
188 for opt in ComputeGroup:
189 conf.register_opt(opt, group='compute')
kavan-patil4ea2efb2011-12-09 08:58:50 +0000190
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500191compute_admin_group = cfg.OptGroup(name='compute-admin',
192 title="Compute Admin Options")
donald-ngo7fb1efa2011-12-13 17:17:36 -0800193
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500194ComputeAdminGroup = [
195 cfg.StrOpt('username',
196 default='admin',
197 help="Administrative Username to use for Nova API requests."),
198 cfg.StrOpt('tenant_name',
199 default='admin',
200 help="Administrative Tenant name to use for Nova API "
201 "requests."),
202 cfg.StrOpt('password',
203 default='pass',
204 help="API key to use when authenticating as admin.",
205 secret=True),
206]
Daryl Walleck587385b2012-03-03 13:00:26 -0600207
K Jonathan Harkerd6ba4b42012-12-18 13:50:47 -0800208
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500209def register_compute_admin_opts(conf):
210 conf.register_group(compute_admin_group)
211 for opt in ComputeAdminGroup:
212 conf.register_opt(opt, group='compute-admin')
Daryl Walleck587385b2012-03-03 13:00:26 -0600213
Jay Pipesf38eaac2012-06-21 13:37:35 -0400214
Attila Fazekas3ca1fb32013-01-21 23:10:53 +0100215whitebox_group = cfg.OptGroup(name='whitebox',
216 title="Whitebox Options")
217
218WhiteboxGroup = [
219 cfg.BoolOpt('whitebox_enabled',
220 default=False,
221 help="Does the test environment support whitebox tests for "
222 "Compute?"),
223 cfg.StrOpt('db_uri',
224 default=None,
225 help="Connection string to the database of Compute service"),
226 cfg.StrOpt('source_dir',
227 default="/opt/stack/nova",
228 help="Path of nova source directory"),
229 cfg.StrOpt('config_path',
230 default='/etc/nova/nova.conf',
231 help="Path of nova configuration file"),
232 cfg.StrOpt('bin_dir',
233 default="/usr/local/bin/",
234 help="Directory containing nova binaries such as nova-manage"),
235]
236
237
238def register_whitebox_opts(conf):
239 conf.register_group(whitebox_group)
240 for opt in WhiteboxGroup:
241 conf.register_opt(opt, group='whitebox')
242
243
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500244image_group = cfg.OptGroup(name='image',
245 title="Image Service Options")
Jay Pipesf38eaac2012-06-21 13:37:35 -0400246
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500247ImageGroup = [
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500248 cfg.StrOpt('api_version',
249 default='1',
250 help="Version of the API"),
Matthew Treinish72ea4422013-02-07 14:42:49 -0500251 cfg.StrOpt('catalog_type',
252 default='image',
Sean Dague83401992013-05-06 17:46:36 -0400253 help='Catalog type of the Image service.'),
254 cfg.StrOpt('http_image',
255 default='http://download.cirros-cloud.net/0.3.1/'
256 'cirros-0.3.1-x86_64-uec.tar.gz',
257 help='http accessable image')
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500258]
Jay Pipesf38eaac2012-06-21 13:37:35 -0400259
Jay Pipesf38eaac2012-06-21 13:37:35 -0400260
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500261def register_image_opts(conf):
262 conf.register_group(image_group)
263 for opt in ImageGroup:
264 conf.register_opt(opt, group='image')
Jay Pipesf38eaac2012-06-21 13:37:35 -0400265
266
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500267network_group = cfg.OptGroup(name='network',
268 title='Network Service Options')
Daryl Walleck587385b2012-03-03 13:00:26 -0600269
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500270NetworkGroup = [
271 cfg.StrOpt('catalog_type',
272 default='network',
273 help='Catalog type of the Quantum service.'),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500274 cfg.StrOpt('tenant_network_cidr',
275 default="10.100.0.0/16",
276 help="The cidr block to allocate tenant networks from"),
277 cfg.IntOpt('tenant_network_mask_bits',
278 default=29,
279 help="The mask bits for tenant networks"),
280 cfg.BoolOpt('tenant_networks_reachable',
281 default=False,
282 help="Whether tenant network connectivity should be "
283 "evaluated directly"),
284 cfg.StrOpt('public_network_id',
285 default="",
286 help="Id of the public network that provides external "
287 "connectivity"),
288 cfg.StrOpt('public_router_id',
289 default="",
290 help="Id of the public router that provides external "
291 "connectivity"),
Dan Smithd6c1f882013-02-26 15:50:11 -0500292 cfg.BoolOpt('quantum_available',
293 default=False,
294 help="Whether or not quantum is expected to be available"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500295]
Jay Pipes3f981df2012-03-27 18:59:44 -0400296
Jay Pipesf38eaac2012-06-21 13:37:35 -0400297
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500298def register_network_opts(conf):
299 conf.register_group(network_group)
300 for opt in NetworkGroup:
301 conf.register_opt(opt, group='network')
Dan Smithd6ff6b72012-08-23 10:29:41 -0700302
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500303volume_group = cfg.OptGroup(name='volume',
304 title='Block Storage Options')
Daryl Walleck587385b2012-03-03 13:00:26 -0600305
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500306VolumeGroup = [
307 cfg.IntOpt('build_interval',
308 default=10,
309 help='Time in seconds between volume availability checks.'),
310 cfg.IntOpt('build_timeout',
311 default=300,
312 help='Timeout in seconds to wait for a volume to become'
313 'available.'),
314 cfg.StrOpt('catalog_type',
315 default='Volume',
316 help="Catalog type of the Volume Service"),
Jérôme Gallard86551ce2013-03-08 11:41:26 +0100317 cfg.BoolOpt('multi_backend_enabled',
318 default=False,
319 help="Runs Cinder multi-backend test (requires 2 backend)"),
320 cfg.StrOpt('backend1_name',
321 default='LVM_iSCSI',
322 help="Name of the backend1 (must be declared in cinder.conf)"),
323 cfg.StrOpt('backend2_name',
324 default='LVM_iSCSI_1',
325 help="Name of the backend2 (must be declared in cinder.conf)"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500326]
K Jonathan Harkerd6ba4b42012-12-18 13:50:47 -0800327
Daryl Walleck587385b2012-03-03 13:00:26 -0600328
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500329def register_volume_opts(conf):
330 conf.register_group(volume_group)
331 for opt in VolumeGroup:
332 conf.register_opt(opt, group='volume')
Attila Fazekasa23f5002012-10-23 19:32:45 +0200333
Attila Fazekasa23f5002012-10-23 19:32:45 +0200334
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500335object_storage_group = cfg.OptGroup(name='object-storage',
336 title='Object Storage Service Options')
Attila Fazekasa23f5002012-10-23 19:32:45 +0200337
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500338ObjectStoreConfig = [
339 cfg.StrOpt('catalog_type',
340 default='object-store',
341 help="Catalog type of the Object-Storage service."),
nayna-patelb4989b32013-01-09 06:25:13 +0000342 cfg.StrOpt('container_sync_timeout',
343 default=120,
344 help="Number of seconds to time on waiting for a container"
345 "to container synchronization complete."),
346 cfg.StrOpt('container_sync_interval',
347 default=5,
348 help="Number of seconds to wait while looping to check the"
349 "status of a container to container synchronization"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500350]
Attila Fazekasa23f5002012-10-23 19:32:45 +0200351
Attila Fazekasa23f5002012-10-23 19:32:45 +0200352
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500353def register_object_storage_opts(conf):
354 conf.register_group(object_storage_group)
355 for opt in ObjectStoreConfig:
356 conf.register_opt(opt, group='object-storage')
Attila Fazekasa23f5002012-10-23 19:32:45 +0200357
Steve Bakerc60e4e32013-05-06 15:22:41 +1200358
359orchestration_group = cfg.OptGroup(name='orchestration',
360 title='Orchestration Service Options')
361
362OrchestrationGroup = [
363 cfg.StrOpt('catalog_type',
364 default='orchestration',
365 help="Catalog type of the Orchestration service."),
366 cfg.BoolOpt('allow_tenant_isolation',
367 default=False,
368 help="Allows test cases to create/destroy tenants and "
369 "users. This option enables isolated test cases and "
370 "better parallel execution, but also requires that "
371 "OpenStack Identity API admin credentials are known."),
372 cfg.IntOpt('build_interval',
373 default=1,
374 help="Time in seconds between build status checks."),
375 cfg.IntOpt('build_timeout',
376 default=300,
377 help="Timeout in seconds to wait for a stack to build."),
378 cfg.BoolOpt('heat_available',
379 default=False,
380 help="Whether or not Heat is expected to be available"),
381 cfg.StrOpt('instance_type',
382 default='m1.tiny',
383 help="Instance type for tests. Needs to be big enough for a "
384 "full OS plus the test workload"),
385 cfg.StrOpt('image_ref',
386 default=None,
387 help="Name of heat-cfntools enabled image to use when "
388 "launching test instances."),
389 cfg.StrOpt('keypair_name',
390 default=None,
391 help="Name of existing keypair to launch servers with."),
392]
393
394
395def register_orchestration_opts(conf):
396 conf.register_group(orchestration_group)
397 for opt in OrchestrationGroup:
398 conf.register_opt(opt, group='orchestration')
399
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500400boto_group = cfg.OptGroup(name='boto',
401 title='EC2/S3 options')
402BotoConfig = [
403 cfg.StrOpt('ec2_url',
404 default="http://localhost:8773/services/Cloud",
405 help="EC2 URL"),
406 cfg.StrOpt('s3_url',
407 default="http://localhost:8080",
408 help="S3 URL"),
409 cfg.StrOpt('aws_secret',
410 default=None,
411 help="AWS Secret Key",
412 secret=True),
413 cfg.StrOpt('aws_access',
414 default=None,
415 help="AWS Access Key"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500416 cfg.StrOpt('s3_materials_path',
417 default="/opt/stack/devstack/files/images/"
418 "s3-materials/cirros-0.3.0",
419 help="S3 Materials Path"),
420 cfg.StrOpt('ari_manifest',
421 default="cirros-0.3.0-x86_64-initrd.manifest.xml",
422 help="ARI Ramdisk Image manifest"),
423 cfg.StrOpt('ami_manifest',
424 default="cirros-0.3.0-x86_64-blank.img.manifest.xml",
425 help="AMI Machine Image manifest"),
426 cfg.StrOpt('aki_manifest',
427 default="cirros-0.3.0-x86_64-vmlinuz.manifest.xml",
428 help="AKI Kernel Image manifest"),
429 cfg.StrOpt('instance_type',
430 default="m1.tiny",
431 help="Instance type"),
432 cfg.IntOpt('http_socket_timeout',
433 default=3,
434 help="boto Http socket timeout"),
435 cfg.IntOpt('num_retries',
436 default=1,
437 help="boto num_retries on error"),
438 cfg.IntOpt('build_timeout',
439 default=60,
440 help="Status Change Timeout"),
441 cfg.IntOpt('build_interval',
442 default=1,
443 help="Status Change Test Interval"),
444]
Attila Fazekasf7f2d932012-12-13 09:14:38 +0100445
Attila Fazekasa23f5002012-10-23 19:32:45 +0200446
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500447def register_boto_opts(conf):
448 conf.register_group(boto_group)
449 for opt in BotoConfig:
450 conf.register_opt(opt, group='boto')
Attila Fazekasa23f5002012-10-23 19:32:45 +0200451
Matthew Treinish615ea6a2013-02-25 17:26:59 -0500452stress_group = cfg.OptGroup(name='stress', title='Stress Test Options')
453
454StressGroup = [
455 cfg.StrOpt('nova_logdir',
456 default=None,
457 help='Directory containing log files on the compute nodes'),
458 cfg.IntOpt('max_instances',
459 default=16,
460 help='Maximum number of instances to create during test.'),
461 cfg.StrOpt('controller',
462 default=None,
David Kranzb9d97502013-05-01 15:55:04 -0400463 help='Controller host.'),
464 # new stress options
465 cfg.StrOpt('target_controller',
466 default=None,
467 help='Controller host.'),
468 cfg.StrOpt('target_ssh_user',
469 default=None,
470 help='ssh user.'),
471 cfg.StrOpt('target_private_key_path',
472 default=None,
473 help='Path to private key.'),
474 cfg.StrOpt('target_logfiles',
475 default=None,
476 help='regexp for list of log files.'),
477 cfg.StrOpt('log_check_interval',
478 default=60,
479 help='time between log file error checks.')
Matthew Treinish615ea6a2013-02-25 17:26:59 -0500480]
481
482
483def register_stress_opts(conf):
484 conf.register_group(stress_group)
485 for opt in StressGroup:
486 conf.register_opt(opt, group='stress')
487
Attila Fazekasa23f5002012-10-23 19:32:45 +0200488
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900489scenario_group = cfg.OptGroup(name='scenario', title='Scenario Test Options')
490
491ScenarioGroup = [
492 cfg.StrOpt('img_dir',
493 default='/opt/stack/new/devstack/files/images/'
494 'cirros-0.3.1-x86_64-uec',
495 help='Directory containing image files'),
496 cfg.StrOpt('ami_img_file',
497 default='cirros-0.3.1-x86_64-blank.img',
498 help='AMI image file name'),
499 cfg.StrOpt('ari_img_file',
500 default='cirros-0.3.1-x86_64-initrd',
501 help='ARI image file name'),
502 cfg.StrOpt('aki_img_file',
503 default='cirros-0.3.1-x86_64-vmlinuz',
504 help='AKI image file name'),
505 cfg.StrOpt('ssh_user',
506 default='cirros',
507 help='ssh username for the image file')
508]
509
510
511def register_scenario_opts(conf):
512 conf.register_group(scenario_group)
513 for opt in ScenarioGroup:
514 conf.register_opt(opt, group='scenario')
515
516
Jay Pipes3f981df2012-03-27 18:59:44 -0400517@singleton
518class TempestConfig:
Daryl Walleck1465d612011-11-02 02:22:15 -0500519 """Provides OpenStack configuration information."""
520
Brian Waldon738cd632011-12-12 18:45:09 -0500521 DEFAULT_CONFIG_DIR = os.path.join(
Zhongyue Luoa1343de2013-01-04 16:21:35 +0800522 os.path.abspath(os.path.dirname(os.path.dirname(__file__))),
Brian Waldon738cd632011-12-12 18:45:09 -0500523 "etc")
Daryl Walleck1465d612011-11-02 02:22:15 -0500524
Brian Waldon738cd632011-12-12 18:45:09 -0500525 DEFAULT_CONFIG_FILE = "tempest.conf"
526
527 def __init__(self):
528 """Initialize a configuration from a conf directory and conf file."""
Sean Dague2416cf32013-04-10 08:29:07 -0400529 config_files = []
530
531 failsafe_path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
Brian Waldon738cd632011-12-12 18:45:09 -0500532
533 # Environment variables override defaults...
534 conf_dir = os.environ.get('TEMPEST_CONFIG_DIR',
Zhongyue Luo79d8d362012-09-25 13:49:27 +0800535 self.DEFAULT_CONFIG_DIR)
536 conf_file = os.environ.get('TEMPEST_CONFIG', self.DEFAULT_CONFIG_FILE)
Brian Waldon738cd632011-12-12 18:45:09 -0500537
Jay Pipes7f757632011-12-02 15:53:32 -0500538 path = os.path.join(conf_dir, conf_file)
539
Zhongyue Luoafd43eb2013-02-04 11:32:57 +0800540 if not (os.path.isfile(path) or
541 'TEMPEST_CONFIG_DIR' in os.environ or
542 'TEMPEST_CONFIG' in os.environ):
Sean Dague2416cf32013-04-10 08:29:07 -0400543 path = failsafe_path
Attila Fazekas5abb2532012-12-04 11:30:49 +0100544
Jay Pipes3f981df2012-03-27 18:59:44 -0400545 LOG.info("Using tempest config file %s" % path)
546
Jay Pipes7f757632011-12-02 15:53:32 -0500547 if not os.path.exists(path):
548 msg = "Config file %(path)s not found" % locals()
Attila Fazekas5abb2532012-12-04 11:30:49 +0100549 print >> sys.stderr, RuntimeError(msg)
Sean Dague2416cf32013-04-10 08:29:07 -0400550 else:
551 config_files.append(path)
Jay Pipes7f757632011-12-02 15:53:32 -0500552
Sean Dague2416cf32013-04-10 08:29:07 -0400553 cfg.CONF([], project='tempest', default_config_files=config_files)
Daryl Walleck1465d612011-11-02 02:22:15 -0500554
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500555 register_compute_opts(cfg.CONF)
556 register_identity_opts(cfg.CONF)
Attila Fazekas3ca1fb32013-01-21 23:10:53 +0100557 register_whitebox_opts(cfg.CONF)
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500558 register_image_opts(cfg.CONF)
559 register_network_opts(cfg.CONF)
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500560 register_volume_opts(cfg.CONF)
561 register_object_storage_opts(cfg.CONF)
Steve Bakerc60e4e32013-05-06 15:22:41 +1200562 register_orchestration_opts(cfg.CONF)
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500563 register_boto_opts(cfg.CONF)
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100564 register_compute_admin_opts(cfg.CONF)
Matthew Treinish615ea6a2013-02-25 17:26:59 -0500565 register_stress_opts(cfg.CONF)
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900566 register_scenario_opts(cfg.CONF)
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500567 self.compute = cfg.CONF.compute
Attila Fazekas3ca1fb32013-01-21 23:10:53 +0100568 self.whitebox = cfg.CONF.whitebox
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500569 self.identity = cfg.CONF.identity
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500570 self.images = cfg.CONF.image
571 self.network = cfg.CONF.network
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500572 self.volume = cfg.CONF.volume
573 self.object_storage = cfg.CONF['object-storage']
Steve Bakerc60e4e32013-05-06 15:22:41 +1200574 self.orchestration = cfg.CONF.orchestration
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500575 self.boto = cfg.CONF.boto
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100576 self.compute_admin = cfg.CONF['compute-admin']
Matthew Treinish615ea6a2013-02-25 17:26:59 -0500577 self.stress = cfg.CONF.stress
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900578 self.scenario = cfg.CONF.scenario
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100579 if not self.compute_admin.username:
580 self.compute_admin.username = self.identity.admin_username
581 self.compute_admin.password = self.identity.admin_password
582 self.compute_admin.tenant_name = self.identity.admin_tenant_name