Jay Pipes | f38eaac | 2012-06-21 13:37:35 -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 | |
| 18 | import logging |
| 19 | |
| 20 | import nose |
| 21 | |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 22 | from tempest import clients |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 23 | from tempest import config |
Frederic Lepied | 80a8d4e | 2013-01-12 12:43:52 +0100 | [diff] [blame] | 24 | from tempest.exceptions import InvalidConfiguration |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 25 | |
| 26 | LOG = logging.getLogger(__name__) |
| 27 | |
| 28 | CONFIG = config.TempestConfig() |
| 29 | CREATE_IMAGE_ENABLED = CONFIG.compute.create_image_enabled |
| 30 | RESIZE_AVAILABLE = CONFIG.compute.resize_available |
David Kranz | f97d5fd | 2012-07-30 13:46:45 -0400 | [diff] [blame] | 31 | CHANGE_PASSWORD_AVAILABLE = CONFIG.compute.change_password_available |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 32 | WHITEBOX_ENABLED = CONFIG.compute.whitebox_enabled |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 33 | DISK_CONFIG_ENABLED = False |
Armando Migliaccio | b8cc220 | 2012-12-12 17:20:51 +0000 | [diff] [blame] | 34 | DISK_CONFIG_ENABLED_OVERRIDE = CONFIG.compute.disk_config_enabled_override |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 35 | FLAVOR_EXTRA_DATA_ENABLED = False |
| 36 | MULTI_USER = False |
| 37 | |
Daryl Walleck | ed97dca | 2012-07-04 23:25:45 -0500 | [diff] [blame] | 38 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 39 | # All compute tests -- single setup function |
| 40 | def setup_package(): |
| 41 | LOG.debug("Entering tempest.tests.compute.setup_package") |
| 42 | |
| 43 | global MULTI_USER, DISK_CONFIG_ENABLED, FLAVOR_EXTRA_DATA_ENABLED |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 44 | os = clients.Manager() |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 45 | images_client = os.images_client |
| 46 | flavors_client = os.flavors_client |
| 47 | extensions_client = os.extensions_client |
Armando Migliaccio | b8cc220 | 2012-12-12 17:20:51 +0000 | [diff] [blame] | 48 | DISK_CONFIG_ENABLED = (DISK_CONFIG_ENABLED_OVERRIDE and |
| 49 | extensions_client.is_enabled('DiskConfig')) |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 50 | 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 Lepied | 80a8d4e | 2013-01-12 12:43:52 +0100 | [diff] [blame] | 55 | 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 Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 59 | |
Frederic Lepied | 80a8d4e | 2013-01-12 12:43:52 +0100 | [diff] [blame] | 60 | 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 Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 64 | |
| 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 Prince | ff3d5c6 | 2012-07-09 11:01:44 -0400 | [diff] [blame] | 77 | if not user2_password or not user2_tenant_name: |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 78 | msg = ("Alternate user specified but not alternate " |
Frederic Lepied | 80a8d4e | 2013-01-12 12:43:52 +0100 | [diff] [blame] | 79 | "tenant or password: alt_tenant_name=%s alt_password=%s" |
| 80 | % (user2_tenant_name, user2_password)) |
| 81 | raise InvalidConfiguration(msg) |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 82 | MULTI_USER = True |