blob: 190cb5fedeab6068b6d00f83c6aaaf77dd4c38ca [file] [log] [blame]
Jay Pipesf38eaac2012-06-21 13:37:35 -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
18import logging
19
20import nose
21
Matthew Treinish481466b2012-12-20 17:16:01 -050022from tempest import clients
Jay Pipesf38eaac2012-06-21 13:37:35 -040023from tempest import config
Frederic Lepied80a8d4e2013-01-12 12:43:52 +010024from tempest.exceptions import InvalidConfiguration
Jay Pipesf38eaac2012-06-21 13:37:35 -040025
26LOG = logging.getLogger(__name__)
27
28CONFIG = config.TempestConfig()
29CREATE_IMAGE_ENABLED = CONFIG.compute.create_image_enabled
30RESIZE_AVAILABLE = CONFIG.compute.resize_available
David Kranzf97d5fd2012-07-30 13:46:45 -040031CHANGE_PASSWORD_AVAILABLE = CONFIG.compute.change_password_available
Jay Pipes051075a2012-04-28 17:39:37 -040032WHITEBOX_ENABLED = CONFIG.compute.whitebox_enabled
Jay Pipesf38eaac2012-06-21 13:37:35 -040033DISK_CONFIG_ENABLED = False
Armando Migliacciob8cc2202012-12-12 17:20:51 +000034DISK_CONFIG_ENABLED_OVERRIDE = CONFIG.compute.disk_config_enabled_override
Jay Pipesf38eaac2012-06-21 13:37:35 -040035FLAVOR_EXTRA_DATA_ENABLED = False
36MULTI_USER = False
37
Daryl Wallecked97dca2012-07-04 23:25:45 -050038
Jay Pipesf38eaac2012-06-21 13:37:35 -040039# All compute tests -- single setup function
40def setup_package():
41 LOG.debug("Entering tempest.tests.compute.setup_package")
42
43 global MULTI_USER, DISK_CONFIG_ENABLED, FLAVOR_EXTRA_DATA_ENABLED
Matthew Treinish481466b2012-12-20 17:16:01 -050044 os = clients.Manager()
Jay Pipesf38eaac2012-06-21 13:37:35 -040045 images_client = os.images_client
46 flavors_client = os.flavors_client
47 extensions_client = os.extensions_client
Armando Migliacciob8cc2202012-12-12 17:20:51 +000048 DISK_CONFIG_ENABLED = (DISK_CONFIG_ENABLED_OVERRIDE and
49 extensions_client.is_enabled('DiskConfig'))
Jay Pipesf38eaac2012-06-21 13:37:35 -040050 FLAVOR_EXTRA_DATA_ENABLED = extensions_client.is_enabled('FlavorExtraData')
51
52 # Validate reference data exists
53 # If not, we raise the exception here and prevent
54 # going forward...
Frederic Lepied80a8d4e2013-01-12 12:43:52 +010055 image_ref = CONFIG.compute.image_ref
56 image_ref_alt = CONFIG.compute.image_ref_alt
57 images_client.get_image(image_ref)
58 images_client.get_image(image_ref_alt)
Jay Pipesf38eaac2012-06-21 13:37:35 -040059
Frederic Lepied80a8d4e2013-01-12 12:43:52 +010060 flavor_ref = CONFIG.compute.flavor_ref
61 flavor_ref_alt = CONFIG.compute.flavor_ref_alt
62 flavors_client.get_flavor_details(flavor_ref)
63 flavors_client.get_flavor_details(flavor_ref_alt)
Jay Pipesf38eaac2012-06-21 13:37:35 -040064
65 # Determine if there are two regular users that can be
66 # used in testing. If the test cases are allowed to create
67 # users (config.compute.allow_tenant_isolation is true,
68 # then we allow multi-user.
69 if CONFIG.compute.allow_tenant_isolation:
70 MULTI_USER = True
71 else:
72 user1 = CONFIG.compute.username
73 user2 = CONFIG.compute.alt_username
74 if user2 and user1 != user2:
75 user2_password = CONFIG.compute.alt_password
76 user2_tenant_name = CONFIG.compute.alt_tenant_name
Dan Princeff3d5c62012-07-09 11:01:44 -040077 if not user2_password or not user2_tenant_name:
Jay Pipesf38eaac2012-06-21 13:37:35 -040078 msg = ("Alternate user specified but not alternate "
Frederic Lepied80a8d4e2013-01-12 12:43:52 +010079 "tenant or password: alt_tenant_name=%s alt_password=%s"
80 % (user2_tenant_name, user2_password))
81 raise InvalidConfiguration(msg)
Jay Pipesf38eaac2012-06-21 13:37:35 -040082 MULTI_USER = True