Merge "DHCPv6 network tests"
diff --git a/HACKING.rst b/HACKING.rst
index e57b670..607682b 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -8,9 +8,10 @@
Tempest Specific Commandments
------------------------------
-- [T102] Cannot import OpenStack python clients in tempest/api tests
+- [T102] Cannot import OpenStack python clients in tempest/api &
+ tempest/scenario tests
- [T104] Scenario tests require a services decorator
-- [T105] Unit tests cannot use setUpClass
+- [T105] Tests cannot use setUpClass/tearDownClass
- [T106] vim configuration should not be kept in source files.
- [N322] Method's default argument shouldn't be mutable
@@ -107,12 +108,52 @@
in tempest.api.compute would require a service tag for those services, however
they do not need to be tagged as compute.
+Test fixtures and resources
+---------------------------
+Test level resources should be cleaned-up after the test execution. Clean-up
+is best scheduled using `addCleanup` which ensures that the resource cleanup
+code is always invoked, and in reverse order with respect to the creation
+order.
+
+Test class level resources should be defined in the `resource_setup` method of
+the test class, except for any credential obtained from the credentials
+provider, which should be set-up in the `setup_credentials` method.
+
+The test base class `BaseTestCase` defines Tempest framework for class level
+fixtures. `setUpClass` and `tearDownClass` are defined here and cannot be
+overwritten by subclasses (enforced via hacking rule T105).
+
+Set-up is split in a series of steps (setup stages), which can be overwritten
+by test classes. Set-up stages are:
+- `skip_checks`
+- `setup_credentials`
+- `setup_clients`
+- `resource_setup`
+
+Tear-down is also split in a series of steps (teardown stages), which are
+stacked for execution only if the corresponding setup stage had been
+reached during the setup phase. Tear-down stages are:
+- `clear_isolated_creds` (defined in the base test class)
+- `resource_cleanup`
+
+Skipping Tests
+--------------
+Skipping tests should be based on configuration only. If that is not possible,
+it is likely that either a configuration flag is missing, or the test should
+fail rather than be skipped.
+Using discovery for skipping tests is generally discouraged.
+
+When running a test that requires a certain "feature" in the target
+cloud, if that feature is missing we should fail, because either the test
+configuration is invalid, or the cloud is broken and the expected "feature" is
+not there even if the cloud was configured with it.
+
Negative Tests
--------------
Newly added negative tests should use the negative test framework. First step
-is to create an interface description in a json file under `etc/schemas`.
-These descriptions consists of two important sections for the test
-(one of those is mandatory):
+is to create an interface description in a python file under
+`tempest/api_schema/request/`. These descriptions consists of two important
+sections for the test (one of those is mandatory):
- A resource (part of the URL of the request): Resources needed for a test
must be created in `setUpClass` and registered with `set_resource` e.g.:
@@ -125,21 +166,17 @@
load_tests = test.NegativeAutoTest.load_tests
- class SampeTestNegativeTestJSON(<your base class>, test.NegativeAutoTest):
- _interface = 'json'
+ @test.SimpleNegativeAutoTest
+ class SampleTestNegativeTestJSON(<your base class>, test.NegativeAutoTest):
_service = 'compute'
- _schema_file = <your Schema file>
+ _schema = <your schema file>
-Negative tests must be marked with a negative attribute::
-
- @test.attr(type=['negative', 'gate'])
- def test_get_console_output(self):
- self.execute(self._schema_file)
+The class decorator `SimpleNegativeAutoTest` will automatically generate test
+cases out of the given schema in the attribute `_schema`.
All negative tests should be added into a separate negative test file.
If such a file doesn't exist for the particular resource being tested a new
-test file should be added. Old XML based negative tests can be kept but should
-be renamed to `_xml.py`.
+test file should be added.
Test skips because of Known Bugs
--------------------------------
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index f509cb4..86dda80 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -78,7 +78,7 @@
#
# List of logger=LEVEL pairs. (list value)
-#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN
+#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN
# Enables or disables fatal status of deprecations. (boolean value)
#fatal_deprecations = false
@@ -260,7 +260,8 @@
# The endpoint type to use for the compute service. (string value)
#endpoint_type = publicURL
-# Visible fixed network name (string value)
+# Name of the fixed network that is visible to all test tenants.
+# (string value)
#fixed_network_name = private
# Valid primary flavor to use in tests. (string value)
@@ -270,7 +271,8 @@
#flavor_ref_alt = 2
# Unallocated floating IP range, which will be used to test the
-# floating IP bulk feature for CRUD operation. (string value)
+# floating IP bulk feature for CRUD operation. This block must not
+# overlap an existing floating IP pool. (string value)
#floating_ip_range = 10.0.0.0/29
# Password used to authenticate to an instance using the alternate
@@ -299,7 +301,8 @@
# IP version used for SSH connections. (integer value)
#ip_version_for_ssh = 4
-# Network used for SSH connections. (string value)
+# Network used for SSH connections. Ignored if
+# use_floatingip_for_ssh=true or run_ssh=false. (string value)
#network_for_ssh = public
# Path to a private key file for SSH access to remote hosts (string
@@ -464,9 +467,6 @@
# [nova.vnc]->vnc_enabled in nova.conf (boolean value)
#vnc_console = false
-# If false skip all v2 api tests with xml (boolean value)
-#xml_api_v2 = true
-
[dashboard]
@@ -517,9 +517,6 @@
# From tempest.config
#
-# Enable diagnostic commands (boolean value)
-#enable = true
-
# A regex to determine which requests should be traced. This is a
# regex to match the caller for rest client requests to be able to
# selectively trace calls out of specific classes and methods. It
@@ -578,6 +575,10 @@
# (string value)
#auth_version = v2
+# Specify a CA bundle file to use in verifying a TLS (https) server
+# certificate. (string value)
+#ca_certificates_file = <None>
+
# Catalog type of the Identity service. (string value)
#catalog_type = identity
@@ -629,9 +630,6 @@
# (boolean value)
#trust = true
-# If false, skip all identity api tests with xml (boolean value)
-#xml_api = false
-
[image]
@@ -807,9 +805,6 @@
# attributes ipv6_ra_mode and ipv6_address_mode (boolean value)
#ipv6_subnet_attributes = false
-# If false, skip all network api tests with xml (boolean value)
-#xml_api = false
-
[object-storage]
diff --git a/requirements.txt b/requirements.txt
index 1e4c40b..f9d8036 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,8 +5,7 @@
anyjson>=0.3.3
httplib2>=0.7.5
jsonschema>=2.0.0,<3.0.0
-testtools>=0.9.36,!=1.2.0,!=1.4.0
-lxml>=2.3
+testtools>=0.9.36,!=1.2.0
boto>=2.32.1
paramiko>=1.13.0
netaddr>=0.7.12
@@ -18,7 +17,7 @@
python-cinderclient>=1.1.0
python-heatclient>=0.2.9
python-ironicclient>=0.2.1
-python-saharaclient>=0.7.5
+python-saharaclient>=0.7.6
python-swiftclient>=2.2.0
testrepository>=0.0.18
oslo.config>=1.4.0 # Apache-2.0
diff --git a/setup.cfg b/setup.cfg
index 90ea944..1e7cc2b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = tempest
-version = 3
+version = 4
summary = OpenStack Integration Testing
description-file =
README.rst
diff --git a/tempest/README.rst b/tempest/README.rst
index fb25151..d28c3f9 100644
--- a/tempest/README.rst
+++ b/tempest/README.rst
@@ -55,7 +55,8 @@
functionality. They are typically a series of steps where complicated
state requiring multiple services is set up exercised, and torn down.
-Scenario tests can and should use the OpenStack python clients.
+Scenario tests should not use the existing python clients for OpenStack,
+but should instead use the tempest implementations of clients.
:ref:`stress_field_guide`
diff --git a/tempest/api/baremetal/admin/test_ports.py b/tempest/api/baremetal/admin/test_ports.py
index b3f9b7f..3392ab9 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -57,11 +57,13 @@
_, body = self.client.show_port(uuid)
self._assertExpected(port, body)
+ @test.skip_because(bug='1398350')
@test.attr(type='smoke')
def test_create_port_with_extra(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
- extra = {'key': 'value'}
+ extra = {'str': 'value', 'int': 123, 'float': 0.123,
+ 'bool': True, 'list': [1, 2, 3], 'dict': {'foo': 'bar'}}
_, port = self.create_port(node_id=node_id, address=address,
extra=extra)
@@ -224,6 +226,7 @@
_, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
+ @test.skip_because(bug='1398350')
@test.attr(type='smoke')
def test_update_port_mixed_ops(self):
node_id = self.node['uuid']
@@ -234,7 +237,7 @@
extra=extra)
new_address = data_utils.rand_mac_address()
- new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}
+ new_extra = {'key1': 0.123, 'key3': {'cat': 'meow'}}
patch = [{'path': '/address',
'op': 'replace',
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index ead3799..8080eb6 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.py
@@ -34,15 +34,6 @@
self.create_port, node_id=node_id, address=address)
@test.attr(type=['negative', 'smoke'])
- def test_create_port_malformed_extra(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
- extra = {'key': 0.123}
- self.assertRaises(exc.BadRequest,
- self.create_port, node_id=node_id,
- address=address, extra=extra)
-
- @test.attr(type=['negative', 'smoke'])
def test_create_port_nonexsistent_node_id(self):
node_id = str(data_utils.rand_uuid())
address = data_utils.rand_mac_address()
@@ -160,31 +151,6 @@
'value': new_address}])
@test.attr(type=['negative', 'smoke'])
- def test_update_port_add_malformed_extra(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
-
- _, port = self.create_port(node_id=node_id, address=address)
- port_id = port['uuid']
-
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
- [{'path': '/extra/key', ' op': 'add',
- 'value': 0.123}])
-
- @test.attr(type=['negative', 'smoke'])
- def test_update_port_add_whole_malformed_extra(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
-
- _, port = self.create_port(node_id=node_id, address=address)
- port_id = port['uuid']
-
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
- [{'path': '/extra',
- 'op': 'add',
- 'value': [1, 2, 3, 4, 'a']}])
-
- @test.attr(type=['negative', 'smoke'])
def test_update_port_add_nonexistent_property(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
@@ -257,37 +223,6 @@
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
- def test_update_port_replace_extra_item_with_malformed(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
- extra = {'key': 'value'}
-
- _, port = self.create_port(node_id=node_id, address=address,
- extra=extra)
- port_id = port['uuid']
-
- patch = [{'path': '/extra/key',
- 'op': 'replace',
- 'value': 0.123}]
- self.assertRaises(exc.BadRequest,
- self.client.update_port, port_id, patch)
-
- @test.attr(type=['negative', 'smoke'])
- def test_update_port_replace_whole_extra_with_malformed(self):
- node_id = self.node['uuid']
- address = data_utils.rand_mac_address()
-
- _, port = self.create_port(node_id=node_id, address=address)
- port_id = port['uuid']
-
- patch = [{'path': '/extra',
- 'op': 'replace',
- 'value': [1, 2, 3, 4, 'a']}]
-
- self.assertRaises(exc.BadRequest,
- self.client.update_port, port_id, patch)
-
- @test.attr(type=['negative', 'smoke'])
def test_update_port_replace_nonexistent_property(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index f33089c..7c2e604 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -221,9 +221,3 @@
wait_until='ACTIVE')
resp, body = admin_servers_client.get_server(server['id'])
self.assertEqual(self.host, body[self._host_key])
-
-
-class AggregatesAdminTestXML(AggregatesAdminTestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/extended_status/api/v1.1}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index ef6752b..219d12e 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -186,7 +186,3 @@
self.assertRaises(exceptions.NotFound, self.client.remove_host,
aggregate['id'], non_exist_host)
-
-
-class AggregatesAdminNegativeTestXML(AggregatesAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_availability_zone.py b/tempest/api/compute/admin/test_availability_zone.py
index 0a040d7..e88fecb 100644
--- a/tempest/api/compute/admin/test_availability_zone.py
+++ b/tempest/api/compute/admin/test_availability_zone.py
@@ -17,15 +17,15 @@
from tempest import test
-class AZAdminV3Test(base.BaseComputeAdminTest):
+class AZAdminV2TestJSON(base.BaseComputeAdminTest):
"""
Tests Availability Zone API List
"""
- _api_version = 3
+ _api_version = 2
@classmethod
def resource_setup(cls):
- super(AZAdminV3Test, cls).resource_setup()
+ super(AZAdminV2TestJSON, cls).resource_setup()
cls.client = cls.availability_zone_admin_client
@test.attr(type='gate')
@@ -42,11 +42,3 @@
self.client.get_availability_zone_list_detail()
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
-
-
-class AZAdminV2TestJSON(AZAdminV3Test):
- _api_version = 2
-
-
-class AZAdminV2TestXML(AZAdminV2TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
index ea157b3..d062b0c 100644
--- a/tempest/api/compute/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/admin/test_availability_zone_negative.py
@@ -35,7 +35,3 @@
self.assertRaises(
exceptions.Unauthorized,
self.non_adm_client.get_availability_zone_list_detail)
-
-
-class AZAdminNegativeTestXML(AZAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index e7f269d..d1d13a0 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -58,7 +58,3 @@
body = {"unreserve": "None"}
resp, body = self.client.reserve_fixed_ip(self.ip, body)
self.assertEqual(resp.status, 202)
-
-
-class FixedIPsTestXml(FixedIPsTestJson):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index 8d6a7fc..e7022db 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -82,7 +82,3 @@
self.assertRaises(exceptions.BadRequest,
self.client.reserve_fixed_ip,
self.ip, body)
-
-
-class FixedIPsNegativeTestXml(FixedIPsNegativeTestJson):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index 3307159..1953040 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -308,7 +308,3 @@
self.assertEqual(flavor['disk'], self.disk)
self.assertEqual(flavor['ram'], int(ram))
self.assertEqual(int(flavor['id']), new_flavor_id)
-
-
-class FlavorsAdminTestXML(FlavorsAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 176a134..19707d0 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -96,7 +96,3 @@
resp, flavors = self.flavors_client.list_flavors_with_detail()
self.assertEqual(resp.status, 200)
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
-
-
-class FlavorsAdminTestXML(FlavorsAccessTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index 9cc2a92..c49652d 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -135,7 +135,3 @@
self.client.remove_flavor_access,
new_flavor['id'],
str(uuid.uuid4()))
-
-
-class FlavorsAdminNegativeTestXML(FlavorsAccessNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index c05abe2..5157d2e 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -121,7 +121,3 @@
self.assertEqual(resp.status, 200)
self.assertEqual(body['key1'], 'value1')
self.assertNotIn('key2', body)
-
-
-class FlavorsExtraSpecsTestXML(FlavorsExtraSpecsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
index 30adf73..20860c8 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -125,7 +125,3 @@
"key1",
key1="value",
key2="value")
-
-
-class FlavorsExtraSpecsNegativeTestXML(FlavorsExtraSpecsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index 5bc3d10..fb27360 100644
--- a/tempest/api/compute/admin/test_flavors_negative.py
+++ b/tempest/api/compute/admin/test_flavors_negative.py
@@ -18,9 +18,13 @@
from tempest.api.compute import base
from tempest.api_schema.request.compute.v2 import flavors
from tempest.common.utils import data_utils
+from tempest import config
from tempest import exceptions
from tempest import test
+
+CONF = config.CONF
+
load_tests = test.NegativeAutoTest.load_tests
@@ -106,5 +110,5 @@
class FlavorCreateNegativeTestJSON(base.BaseV2ComputeAdminTest,
test.NegativeAutoTest):
_interface = 'json'
- _service = 'compute'
+ _service = CONF.compute.catalog_type
_schema = flavors.flavor_create
diff --git a/tempest/api/compute/admin/test_flavors_negative_xml.py b/tempest/api/compute/admin/test_flavors_negative_xml.py
deleted file mode 100644
index a06b0e6..0000000
--- a/tempest/api/compute/admin/test_flavors_negative_xml.py
+++ /dev/null
@@ -1,268 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from tempest.api.compute.admin import test_flavors_negative
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class FlavorsAdminNegativeTestXML(test_flavors_negative.
- FlavorsAdminNegativeTestJSON):
-
- """
- Tests Flavors API Create and Delete that require admin privileges
- """
-
- _interface = 'xml'
-
- def flavor_clean_up(self, flavor_id):
- resp, body = self.client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 202)
- self.client.wait_for_resource_deletion(flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_is_public_string(self):
- # the 'is_public' parameter can be 'none/true/false' if it exists
- self.assertRaises(exceptions.BadRequest,
- self.client.list_flavors_with_detail,
- {'is_public': 'invalid'})
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_ram(self):
- # the 'ram' attribute must be positive integer
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, -1, self.vcpus,
- self.disk, new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_vcpus(self):
- # the 'vcpu' attribute must be positive integer
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, self.ram, -1,
- self.disk, new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_name_length_less_than_1(self):
- # ensure name length >= 1
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- '',
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_name_length_exceeds_255(self):
- # ensure name do not exceed 255 characters
- new_flavor_name = 'a' * 256
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_name(self):
- # the regex of flavor_name is '^[\w\.\- ]*$'
- invalid_flavor_name = data_utils.rand_name('invalid-!@#$%-')
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- invalid_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_flavor_id(self):
- # the regex of flavor_id is '^[\w\.\- ]*$', and it cannot contain
- # leading and/or trailing whitespace
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- invalid_flavor_id = '!@#$%'
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- invalid_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_id_length_exceeds_255(self):
- # the length of flavor_id should not exceed 255 characters
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- invalid_flavor_id = 'a' * 256
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- invalid_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_root_gb(self):
- # root_gb attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- -1,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_ephemeral_gb(self):
- # ephemeral_gb attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=-1,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_swap(self):
- # swap attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=-1,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_rxtx_factor(self):
- # rxtx_factor attribute should be a positive float
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=-1.5,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_is_public(self):
- # is_public attribute should be boolean
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='Invalid')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_already_exists(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- self.assertEqual(200, resp.status)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
-
- self.assertRaises(exceptions.Conflict,
- self.client.create_flavor,
- flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_nonexistent_flavor(self):
- nonexistent_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.NotFound,
- self.client.delete_flavor,
- nonexistent_flavor_id)
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index bcae492..25965fd 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -84,7 +84,3 @@
self.assertIsNotNone(host_resource['memory_mb'])
self.assertIsNotNone(host_resource['project'])
self.assertEqual(hostname, host_resource['host'])
-
-
-class HostsAdminTestXML(HostsAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 4111aba..055219f 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -66,7 +66,6 @@
status='enable',
maintenance_mode='enable')
- @test.skip_because(bug="1261964", interface="xml")
@test.attr(type=['negative', 'gate'])
def test_update_host_with_extra_param(self):
# only 'status' and 'maintenance_mode' are the valid params.
@@ -167,7 +166,3 @@
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.reboot_host,
hostname)
-
-
-class HostsAdminNegativeTestXML(HostsAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index c51d0a5..de3debb 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -128,7 +128,3 @@
hypers[0]['hypervisor_hostname'])
self.assertEqual(200, resp.status)
self.assertHypervisors(hypers)
-
-
-class HypervisorAdminTestXML(HypervisorAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index d3804e8..b1f2351 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -134,7 +134,3 @@
exceptions.Unauthorized,
self.non_adm_client.search_hypervisor,
hypers[0]['hypervisor_hostname'])
-
-
-class HypervisorAdminNegativeTestXML(HypervisorAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log.py b/tempest/api/compute/admin/test_instance_usage_audit_log.py
index 91f0b02..f7b5e43 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -54,7 +54,3 @@
'period_beginning', 'num_hosts_not_run']
for item in expected_items:
self.assertIn(item, body)
-
-
-class InstanceUsageAuditLogTestXML(InstanceUsageAuditLogTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
index 1af340d..c4905d9 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
@@ -45,8 +45,3 @@
self.assertRaises(exceptions.BadRequest,
self.adm_client.get_instance_usage_audit_log,
"invalid_time")
-
-
-class InstanceUsageAuditLogNegativeTestXML(
- InstanceUsageAuditLogNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index 701e1c2..7c666a2 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -152,10 +152,6 @@
self.assertEqual(ram_default, quota_set_new['ram'])
-class QuotasAdminTestXML(QuotasAdminTestJSON):
- _interface = 'xml'
-
-
class QuotaClassesAdminTestJSON(base.BaseV2ComputeAdminTest):
"""Tests the os-quota-class-sets API to update default quotas.
"""
@@ -202,7 +198,3 @@
LOG.debug("assert that the response has all of the changed values")
self.assertThat(update_body.items(),
matchers.ContainsAll(body.items()))
-
-
-class QuotaClassesAdminTestXML(QuotaClassesAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index a9ed7ce..532f195 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -156,7 +156,3 @@
self.assertRaises((exceptions.OverLimit, exceptions.Unauthorized),
self.sg_client.create_security_group_rule,
secgroup_id, ip_protocol, 1025, 1025)
-
-
-class QuotasAdminNegativeTestXML(QuotasAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index 40ae236..b4615f2 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -90,7 +90,3 @@
self.assertEqual(sec_group['tenant_id'], client_tenant_id,
"Failed to get all security groups for "
"non admin user.")
-
-
-class SecurityGroupsTestAdminXML(SecurityGroupsTestAdminJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 47aaee3..e3477f1 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -182,9 +182,3 @@
resp, server = self.create_test_server(sched_hints=hints,
wait_until='ACTIVE')
self.assertEqual('202', resp['status'])
-
-
-class ServersAdminTestXML(ServersAdminTestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/extended_status/api/v1.1}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 9aa489c..2f0af72 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -148,7 +148,3 @@
self.assertRaises(exceptions.Conflict,
self.client.migrate_server,
server_id)
-
-
-class ServersAdminNegativeTestXML(ServersAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index 76153e7..e7a39f8 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -76,7 +76,3 @@
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
-
-
-class ServicesAdminTestXML(ServicesAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index 5331097..534afc5 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -60,7 +60,3 @@
resp, services = self.client.list_services(params)
self.assertEqual(200, resp.status)
self.assertEqual(0, len(services))
-
-
-class ServicesAdminNegativeTestXML(ServicesAdminNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index 5d596ba..f6553b3 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -73,7 +73,3 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
-
-
-class TenantUsagesTestXML(TenantUsagesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
index 5e2c593..8c31d7c 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -63,7 +63,3 @@
'detailed': int(bool(True))}
self.assertRaises(exceptions.Unauthorized,
self.client.list_tenant_usages, params)
-
-
-class TenantUsagesNegativeTestXML(TenantUsagesNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 2f53a0b..4feba59 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -31,16 +31,13 @@
class BaseComputeTest(tempest.test.BaseTestCase):
"""Base test case class for all Compute API tests."""
- _api_version = 3
+ _api_version = 2
force_tenant_isolation = False
@classmethod
def resource_setup(cls):
cls.set_network_resources()
super(BaseComputeTest, cls).resource_setup()
- if getattr(cls, '_interface', None) == 'xml' and cls._api_version == 2:
- if not CONF.compute_feature_enabled.xml_api_v2:
- raise cls.skipException('XML API is not enabled')
# TODO(andreaf) WE should care also for the alt_manager here
# but only once client lazy load in the manager is done
@@ -90,29 +87,6 @@
cls.migrations_client = cls.os.migrations_client
cls.security_group_default_rules_client = (
cls.os.security_group_default_rules_client)
-
- elif cls._api_version == 3:
- if not CONF.compute_feature_enabled.api_v3:
- skip_msg = ("%s skipped as nova v3 api is not available" %
- cls.__name__)
- raise cls.skipException(skip_msg)
- cls.servers_client = cls.os.servers_v3_client
- cls.images_client = cls.os.image_client
- cls.flavors_client = cls.os.flavors_v3_client
- cls.services_client = cls.os.services_v3_client
- cls.extensions_client = cls.os.extensions_v3_client
- cls.availability_zone_client = cls.os.availability_zone_v3_client
- cls.interfaces_client = cls.os.interfaces_v3_client
- cls.hypervisor_client = cls.os.hypervisor_v3_client
- cls.keypairs_client = cls.os.keypairs_v3_client
- cls.volumes_client = cls.os.volumes_client
- cls.certificates_client = cls.os.certificates_v3_client
- cls.keypairs_client = cls.os.keypairs_v3_client
- cls.aggregates_client = cls.os.aggregates_v3_client
- cls.hosts_client = cls.os.hosts_v3_client
- cls.quotas_client = cls.os.quotas_v3_client
- cls.version_client = cls.os.version_v3_client
- cls.migrations_client = cls.os.migrations_v3_client
else:
msg = ("Unexpected API version is specified (%s)" %
cls._api_version)
@@ -319,20 +293,14 @@
if 'name' in kwargs:
name = kwargs.pop('name')
- if cls._api_version == 2:
- resp, image = cls.images_client.create_image(server_id, name)
- elif cls._api_version == 3:
- resp, image = cls.servers_client.create_image(server_id, name)
+ resp, image = cls.images_client.create_image(server_id, name)
image_id = data_utils.parse_image_id(resp['location'])
cls.images.append(image_id)
if 'wait_until' in kwargs:
cls.images_client.wait_for_image_status(image_id,
kwargs['wait_until'])
- if cls._api_version == 2:
- resp, image = cls.images_client.get_image(image_id)
- elif cls._api_version == 3:
- resp, image = cls.images_client.get_image_meta(image_id)
+ resp, image = cls.images_client.get_image(image_id)
if kwargs['wait_until'] == 'ACTIVE':
if kwargs.get('wait_for_server', True):
@@ -350,19 +318,13 @@
except Exception:
LOG.exception('Failed to delete server %s' % server_id)
resp, server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
- if cls._api_version == 2:
- cls.password = server['adminPass']
- elif cls._api_version == 3:
- cls.password = server['admin_password']
+ cls.password = server['adminPass']
return server['id']
@classmethod
def delete_volume(cls, volume_id):
"""Deletes the given volume and waits for it to be gone."""
- if cls._api_version == 2:
- cls._delete_volume(cls.volumes_extensions_client, volume_id)
- elif cls._api_version == 3:
- cls._delete_volume(cls.volumes_client, volume_id)
+ cls._delete_volume(cls.volumes_extensions_client, volume_id)
class BaseV2ComputeTest(BaseComputeTest):
@@ -370,11 +332,6 @@
_interface = "json"
-class BaseV3ComputeTest(BaseComputeTest):
- _api_version = 3
- _interface = "json"
-
-
class BaseComputeAdminTest(BaseComputeTest):
"""Base test case class for Compute Admin API tests."""
_interface = "json"
@@ -390,29 +347,10 @@
msg = ("Missing Compute Admin API credentials in configuration.")
raise cls.skipException(msg)
- if cls._api_version == 2:
- cls.availability_zone_admin_client = (
- cls.os_adm.availability_zone_client)
-
- else:
- cls.servers_admin_client = cls.os_adm.servers_v3_client
- cls.services_admin_client = cls.os_adm.services_v3_client
- cls.availability_zone_admin_client = \
- cls.os_adm.availability_zone_v3_client
- cls.hypervisor_admin_client = cls.os_adm.hypervisor_v3_client
- cls.flavors_admin_client = cls.os_adm.flavors_v3_client
- cls.aggregates_admin_client = cls.os_adm.aggregates_v3_client
- cls.hosts_admin_client = cls.os_adm.hosts_v3_client
- cls.quotas_admin_client = cls.os_adm.quotas_v3_client
- cls.agents_admin_client = cls.os_adm.agents_v3_client
- cls.migrations_admin_client = cls.os_adm.migrations_v3_client
+ cls.availability_zone_admin_client = (
+ cls.os_adm.availability_zone_client)
class BaseV2ComputeAdminTest(BaseComputeAdminTest):
"""Base test case class for Compute Admin V2 API tests."""
_api_version = 2
-
-
-class BaseV3ComputeAdminTest(BaseComputeAdminTest):
- """Base test case class for Compute Admin V3 API tests."""
- _api_version = 3
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 0f921c5..15ccf53 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -17,9 +17,9 @@
from tempest import test
-class CertificatesV3Test(base.BaseComputeTest):
+class CertificatesV2TestJSON(base.BaseComputeTest):
- _api_version = 3
+ _api_version = 2
@test.attr(type='gate')
def test_create_root_certificate(self):
@@ -35,11 +35,3 @@
self.assertEqual(200, resp.status)
self.assertIn('data', body)
self.assertIn('private_key', body)
-
-
-class CertificatesV2TestJSON(CertificatesV3Test):
- _api_version = 2
-
-
-class CertificatesV2TestXML(CertificatesV2TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index 7beef23..992f86a 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -17,15 +17,15 @@
from tempest import test
-class FlavorsV3Test(base.BaseComputeTest):
+class FlavorsV2TestJSON(base.BaseComputeTest):
- _api_version = 3
- _min_disk = 'min_disk'
- _min_ram = 'min_ram'
+ _api_version = 2
+ _min_disk = 'minDisk'
+ _min_ram = 'minRam'
@classmethod
def resource_setup(cls):
- super(FlavorsV3Test, cls).resource_setup()
+ super(FlavorsV2TestJSON, cls).resource_setup()
cls.client = cls.flavors_client
@test.attr(type='smoke')
@@ -125,14 +125,3 @@
params = {self._min_ram: flavor['ram'] + 1}
resp, flavors = self.client.list_flavors(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
-
-
-class FlavorsV2TestJSON(FlavorsV3Test):
-
- _api_version = 2
- _min_disk = 'minDisk'
- _min_ram = 'minRam'
-
-
-class FlavorsV2TestXML(FlavorsV2TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/flavors/test_flavors_negative.py b/tempest/api/compute/flavors/test_flavors_negative.py
index cae1ac4..83f8e19 100644
--- a/tempest/api/compute/flavors/test_flavors_negative.py
+++ b/tempest/api/compute/flavors/test_flavors_negative.py
@@ -15,23 +15,26 @@
from tempest.api.compute import base
from tempest.api_schema.request.compute.v2 import flavors
+from tempest import config
from tempest import test
+CONF = config.CONF
+
load_tests = test.NegativeAutoTest.load_tests
@test.SimpleNegativeAutoTest
class FlavorsListWithDetailsNegativeTestJSON(base.BaseV2ComputeTest,
test.NegativeAutoTest):
- _service = 'compute'
+ _service = CONF.compute.catalog_type
_schema = flavors.flavor_list
@test.SimpleNegativeAutoTest
class FlavorDetailsNegativeTestJSON(base.BaseV2ComputeTest,
test.NegativeAutoTest):
- _service = 'compute'
+ _service = CONF.compute.catalog_type
_schema = flavors.flavors_details
@classmethod
diff --git a/tempest/api/compute/flavors/test_flavors_negative_xml.py b/tempest/api/compute/flavors/test_flavors_negative_xml.py
deleted file mode 100644
index 299b18a..0000000
--- a/tempest/api/compute/flavors/test_flavors_negative_xml.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-
-
-class FlavorsNegativeTestXML(base.BaseV2ComputeTest):
- _interface = 'xml'
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsNegativeTestXML, cls).resource_setup()
- cls.client = cls.flavors_client
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_minRam_filter(self):
- self.assertRaises(exceptions.BadRequest,
- self.client.list_flavors_with_detail,
- {'minRam': 'invalid'})
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_minDisk_filter(self):
- self.assertRaises(exceptions.BadRequest,
- self.client.list_flavors_with_detail,
- {'minDisk': 'invalid'})
-
- @test.attr(type=['negative', 'gate'])
- def test_non_existent_flavor_id(self):
- # flavor details are not returned for non-existent flavors
- nonexistent_flavor_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
- nonexistent_flavor_id)
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index ba66ab9..db382eb 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -130,10 +130,7 @@
# Make sure no longer associated with old server
self.assertRaises((exceptions.NotFound,
- exceptions.UnprocessableEntity),
+ exceptions.UnprocessableEntity,
+ exceptions.Conflict),
self.client.disassociate_floating_ip_from_server,
self.floating_ip, self.server_id)
-
-
-class FloatingIPsTestXML(FloatingIPsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
index 104d130..2b0f268 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
@@ -93,7 +93,3 @@
self.assertRaises(exceptions.NotFound,
self.client.associate_floating_ip_to_server,
'', self.server_id)
-
-
-class FloatingIPsNegativeTestXML(FloatingIPsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index cb93177..7af9ca7 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -79,7 +79,3 @@
self.assertEqual(200, resp.status)
self.assertNotEqual(0, len(floating_ip_pools),
"Expected floating IP Pools. Got zero.")
-
-
-class FloatingIPDetailsTestXML(FloatingIPDetailsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
index 08819c2..c343018 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
@@ -43,7 +43,3 @@
non_exist_id = data_utils.rand_int_id(start=999)
self.assertRaises(exceptions.NotFound,
self.client.get_floating_ip_details, non_exist_id)
-
-
-class FloatingIPDetailsNegativeTestXML(FloatingIPDetailsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 1fa591f..5105e2f 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -107,7 +107,3 @@
resp, resp_metadata = self.client.list_image_metadata(self.image_id)
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
-
-
-class ImagesMetadataTestXML(ImagesMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index 7f0bc4e..615b5d0 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -72,7 +72,3 @@
self.assertRaises(exceptions.NotFound,
self.client.delete_image_metadata_item,
data_utils.rand_uuid(), 'key1')
-
-
-class ImagesMetadataTestXML(ImagesMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 68f793a..51dae65 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -47,7 +47,3 @@
wait_until='SAVING')
resp, body = self.client.delete_image(image['id'])
self.assertEqual('204', resp['status'])
-
-
-class ImagesTestXML(ImagesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index e406374..9570ca5 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -131,7 +131,3 @@
# Return an error while trying to delete image with id over limit
self.assertRaises(exceptions.NotFound, self.client.delete_image,
'11a22b9-12a9-5555-cc11-00ab112223fa-3fac')
-
-
-class ImagesNegativeTestXML(ImagesNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 459d78b..91e0423 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -99,10 +99,6 @@
@test.attr(type=['gate'])
def test_create_image_specify_multibyte_character_image_name(self):
- if self.__class__._interface == "xml":
- # NOTE(sdague): not entirely accurage, but we'd need a ton of work
- # in our XML client to make this good
- raise self.skipException("Not testable in XML")
# prefix character is:
# http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
@@ -114,7 +110,3 @@
image_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.client.delete_image, image_id)
self.assertEqual('202', resp['status'])
-
-
-class ImagesOneServerTestXML(ImagesOneServerTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index dc3d6bc..ae6e712 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -131,7 +131,3 @@
self.image_ids.remove(image_id)
self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
-
-
-class ImagesOneServerNegativeTestXML(ImagesOneServerNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index 30a99dd..ceab4f9 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -263,7 +263,3 @@
params = {'changes-since': self.image1['created']}
resp, images = self.client.list_images_with_detail(params)
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
-
-
-class ListImageFiltersTestXML(ListImageFiltersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_list_image_filters_negative.py b/tempest/api/compute/images/test_list_image_filters_negative.py
index 53a21a0..a8f2ae7 100644
--- a/tempest/api/compute/images/test_list_image_filters_negative.py
+++ b/tempest/api/compute/images/test_list_image_filters_negative.py
@@ -37,7 +37,3 @@
nonexistent_image = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.get_image,
nonexistent_image)
-
-
-class ListImageFiltersNegativeTestXML(ListImageFiltersNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index eceac82..22d64e9 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -49,7 +49,3 @@
resp, images = self.client.list_images_with_detail()
found = any([i for i in images if i['id'] == self.image_ref])
self.assertTrue(found)
-
-
-class ListImagesTestXML(ListImagesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index 2f0febf..ce10fbe 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -18,13 +18,13 @@
from tempest import test
-class KeyPairsV3Test(base.BaseComputeTest):
+class KeyPairsV2TestJSON(base.BaseComputeTest):
- _api_version = 3
+ _api_version = 2
@classmethod
def resource_setup(cls):
- super(KeyPairsV3Test, cls).resource_setup()
+ super(KeyPairsV2TestJSON, cls).resource_setup()
cls.client = cls.keypairs_client
def _delete_keypair(self, keypair_name):
@@ -113,11 +113,3 @@
self.assertEqual(key_name, k_name,
"The created keypair name is not equal "
"to the requested name!")
-
-
-class KeyPairsV2TestJSON(KeyPairsV3Test):
- _api_version = 2
-
-
-class KeyPairsV2TestXML(KeyPairsV2TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 0da449b..2cc6f00 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -93,7 +93,3 @@
k_name = 'key_/.\@:'
self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name)
-
-
-class KeyPairsNegativeTestXML(KeyPairsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index bac1a39..4420ac7 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -43,7 +43,3 @@
self.assertEqual(0, len(missing_elements),
"Failed to find element %s in absolute limits list"
% ', '.join(ele for ele in missing_elements))
-
-
-class AbsoluteLimitsTestXML(AbsoluteLimitsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index 2b41ea0..f729436 100644
--- a/tempest/api/compute/limits/test_absolute_limits_negative.py
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -46,7 +46,3 @@
name='test', meta=meta_data,
flavor_ref=self.flavor_ref,
image_ref=self.image_ref)
-
-
-class AbsoluteLimitsNegativeTestXML(AbsoluteLimitsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index 4fd5c02..be06213 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
from tempest.api.compute.security_groups import base
from tempest import config
from tempest import test
@@ -40,13 +38,6 @@
to_port = cls.to_port
group = {}
ip_range = {}
- if cls._interface == 'xml':
- # NOTE: An XML response is different from the one of JSON
- # like the following.
- from_port = six.text_type(from_port)
- to_port = six.text_type(to_port)
- group = {'tenant_id': 'None', 'name': 'None'}
- ip_range = {'cidr': 'None'}
cls.expected = {
'id': None,
'parent_group_id': None,
@@ -195,7 +186,3 @@
self.client.list_security_group_rules(sg1_id)
# The group1 has no rules because group2 has deleted
self.assertEqual(0, len(rules))
-
-
-class SecurityGroupRulesTestXML(SecurityGroupRulesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index 7850909..88a99b9 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -162,7 +162,3 @@
self.assertRaises(exceptions.NotFound,
self.client.delete_security_group_rule,
non_existent_rule_id)
-
-
-class SecurityGroupRulesNegativeTestXML(SecurityGroupRulesNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 82dd4f0..1cfb16b 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -155,7 +155,3 @@
self.client.get_security_group(securitygroup_id)
self.assertEqual(s_new_name, fetched_group['name'])
self.assertEqual(s_new_des, fetched_group['description'])
-
-
-class SecurityGroupsTestXML(SecurityGroupsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
index 3101052..ce06180 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -201,7 +201,3 @@
self.client.update_security_group,
non_exist_id, name=s_name,
description=s_description)
-
-
-class SecurityGroupsNegativeTestXML(SecurityGroupsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index d62d19f..049736c 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -157,7 +157,3 @@
resp, body = self.client.remove_fixed_ip(server['id'],
fixed_ip)
self.assertEqual(202, resp.status)
-
-
-class AttachInterfacesTestXML(AttachInterfacesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_availability_zone.py b/tempest/api/compute/servers/test_availability_zone.py
index 44bd7d3..5ddf053 100644
--- a/tempest/api/compute/servers/test_availability_zone.py
+++ b/tempest/api/compute/servers/test_availability_zone.py
@@ -17,15 +17,15 @@
from tempest import test
-class AZV3Test(base.BaseComputeTest):
+class AZV2TestJSON(base.BaseComputeTest):
"""
Tests Availability Zone API List
"""
- _api_version = 3
+ _api_version = 2
@classmethod
def resource_setup(cls):
- super(AZV3Test, cls).resource_setup()
+ super(AZV2TestJSON, cls).resource_setup()
cls.client = cls.availability_zone_client
@test.attr(type='gate')
@@ -34,11 +34,3 @@
resp, availability_zone = self.client.get_availability_zone_list()
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
-
-
-class AZV2TestJSON(AZV3Test):
- _api_version = 2
-
-
-class AZV2TestXML(AZV2TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index d954c01..b561b4e 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -103,7 +103,6 @@
self.password)
self.assertTrue(linux_client.hostname_equals_servername(self.name))
- @test.skip_because(bug="1306367", interface="xml")
@test.attr(type='gate')
def test_create_server_with_scheduler_hint_group(self):
# Create a server with the scheduler hint "group".
@@ -128,9 +127,6 @@
@testtools.skipUnless(CONF.service_available.neutron,
'Neutron service must be available.')
def test_verify_multiple_nics_order(self):
- if getattr(self, '_interface',
- None) == 'xml' and not CONF.network_feature_enabled.xml_api:
- raise self.skipException('Neutron XML API is not enabled')
# Verify that the networks order given at the server creation is
# preserved within the server.
name_net1 = data_utils.rand_name(self.__class__.__name__)
@@ -279,11 +275,3 @@
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).resource_setup()
-
-
-class ServersTestXML(ServersTestJSON):
- _interface = 'xml'
-
-
-class ServersWithSpecificFlavorTestXML(ServersWithSpecificFlavorTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 55931a4..9d1ea9e 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -169,11 +169,3 @@
resp, _ = self.admin_client.delete_server(server['id'])
self.assertEqual('204', resp['status'])
self.servers_client.wait_for_server_termination(server['id'])
-
-
-class DeleteServersTestXML(DeleteServersTestJSON):
- _interface = 'xml'
-
-
-class DeleteServersAdminTestXML(DeleteServersAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 51f2eb4..eeef0e5 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -132,7 +132,3 @@
# Verify the disk_config attribute is set correctly
resp, server = self.client.get_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
-
-
-class ServerDiskConfigTestXML(ServerDiskConfigTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index d11ce25..80b2a69 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -47,7 +47,3 @@
self.assertEqual(200, resp.status)
self.assertEqual(self.server_id, body['instance_uuid'])
self.assertEqual('create', body['action'])
-
-
-class InstanceActionsTestXML(InstanceActionsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index c706ad5..e92f04c 100644
--- a/tempest/api/compute/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -41,7 +41,3 @@
# Get the action details of the provided server with invalid request
self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
self.server_id, '999')
-
-
-class InstanceActionsNegativeTestXML(InstanceActionsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index e660f00..5ff39df 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -143,7 +143,6 @@
# Verify only the expected number of servers are returned
params = {'limit': 1}
resp, servers = self.client.list_servers(params)
- # when _interface='xml', one element for servers_links in servers
self.assertEqual(1, len([x for x in servers['servers'] if 'id' in x]))
@test.attr(type='gate')
@@ -293,7 +292,3 @@
params = {'limit': 1}
resp, servers = self.client.list_servers_with_detail(params)
self.assertEqual(1, len(servers['servers']))
-
-
-class ListServerFiltersTestXML(ListServerFiltersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index f4d8dda..fd66d2b 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -147,7 +147,3 @@
if srv['id'] in deleted_ids]
self.assertEqual('200', resp['status'])
self.assertEqual([], actual)
-
-
-class ListServersNegativeTestXML(ListServersNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index 40b9c16..6fd2a75 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -53,7 +53,3 @@
return_reservation_id=True)
self.assertEqual(resp['status'], '202')
self.assertIn('reservation_id', body)
-
-
-class MultipleCreateTestXML(MultipleCreateTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_multiple_create_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
index 3dea521..55db605 100644
--- a/tempest/api/compute/servers/test_multiple_create_negative.py
+++ b/tempest/api/compute/servers/test_multiple_create_negative.py
@@ -66,7 +66,3 @@
self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
min_count=min_count,
max_count=max_count)
-
-
-class MultipleCreateNegativeTestXML(MultipleCreateNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index b51b46e..28deaa7 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -498,7 +498,3 @@
self.assertEqual(console_type, body['type'])
self.assertNotEqual('', body['url'])
self._validate_url(body['url'])
-
-
-class ServerActionsTestXML(ServerActionsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index a494896..3d1d964 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -65,7 +65,3 @@
addr = addr[addr_type]
for address in addresses[addr_type]:
self.assertTrue(any([a for a in addr if a == address]))
-
-
-class ServerAddressesTestXML(ServerAddressesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
index c7e4c89..3087e59 100644
--- a/tempest/api/compute/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -42,7 +42,3 @@
self.assertRaises(exceptions.NotFound,
self.client.list_addresses_by_network,
self.server['id'], 'invalid')
-
-
-class ServerAddressesNegativeTestXML(ServerAddressesNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index c265352..6fd6a6d 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -113,7 +113,3 @@
resp, resp_metadata = self.client.list_server_metadata(self.server_id)
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
-
-
-class ServerMetadataTestXML(ServerMetadataTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index 497b94b..8b074fd 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -40,7 +40,7 @@
for sz in [256, 257, 511, 1023]:
key = "k" * sz
meta = {key: 'data1'}
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises((exceptions.BadRequest, exceptions.OverLimit),
self.create_test_server,
meta=meta)
@@ -155,7 +155,3 @@
self.assertRaises(exceptions.BadRequest,
self.client.set_server_metadata,
self.server_id, meta=meta, no_metadata_field=True)
-
-
-class ServerMetadataNegativeTestXML(ServerMetadataNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index aba9bb6..994caa4 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -35,7 +35,3 @@
def test_delete_server_password(self):
resp, body = self.client.delete_password(self.server['id'])
self.assertEqual(204, resp.status)
-
-
-class ServerPasswordTestXML(ServerPasswordTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index effb52f..de5b6c1 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -61,7 +61,3 @@
})
resp, server = self.create_test_server(personality=person)
self.assertEqual('202', resp['status'])
-
-
-class ServerPersonalityTestXML(ServerPersonalityTestJSON):
- _interface = "xml"
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 5986f41..ee1e268 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -117,7 +117,3 @@
resp, body = self.servers_client.remove_security_group(self.server_id,
self.sg_name)
self.assertEqual(202, resp.status)
-
-
-class ServerRescueTestXML(ServerRescueTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index de43164..f1e2f7f 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -148,7 +148,3 @@
self.servers_client.detach_volume,
self.server_id,
volume['id'])
-
-
-class ServerRescueNegativeTestXML(ServerRescueNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index d501839..aba6dff 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -124,7 +124,3 @@
self.client.wait_for_server_status(server['id'], 'ACTIVE')
resp, server = self.client.get_server(server['id'])
self.assertEqual('2001:2001::3', server['accessIPv6'])
-
-
-class ServersTestXML(ServersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 0349260..4e6dcda 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -181,10 +181,6 @@
@test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
- # Create a server with a numeric name
- if self.__class__._interface == "xml":
- raise self.skipException("Not testable in XML")
-
server_name = 12345
self.assertRaises(exceptions.BadRequest,
self.create_test_server,
@@ -223,7 +219,7 @@
# Pass really long metadata while creating a server
metadata = {'a': 'b' * 260}
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises((exceptions.BadRequest, exceptions.OverLimit),
self.create_test_server,
meta=metadata)
@@ -471,7 +467,3 @@
self.assertRaises(exceptions.Conflict,
self.client.unshelve_server,
self.server_id)
-
-
-class ServersNegativeTestXML(ServersNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index f205761..48af084 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -50,7 +50,3 @@
mac_address = virt_iface['mac_address']
self.assertTrue(netaddr.valid_mac(mac_address),
"Invalid mac address detected.")
-
-
-class VirtualInterfacesTestXML(VirtualInterfacesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
index 1f4a20e..e81ccc6 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -38,7 +38,3 @@
self.assertRaises(exceptions.NotFound,
self.client.list_virtual_interfaces,
invalid_server_id)
-
-
-class VirtualInterfacesNegativeTestXML(VirtualInterfacesNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 175f008..1f4f124 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -379,7 +379,3 @@
self.assertRaises(exceptions.NotFound,
self.alt_client.get_console_output,
self.server['id'], 10)
-
-
-class AuthorizationTestXML(AuthorizationTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/test_extensions.py b/tempest/api/compute/test_extensions.py
index 674ca9a..46e7251 100644
--- a/tempest/api/compute/test_extensions.py
+++ b/tempest/api/compute/test_extensions.py
@@ -38,11 +38,11 @@
if ext == 'all':
self.assertIn('Hosts', map(lambda x: x['name'], extensions))
elif ext:
- self.assertIn(ext, map(lambda x: x['name'], extensions))
+ self.assertIn(ext, map(lambda x: x['alias'], extensions))
else:
raise self.skipException('There are not any extensions configured')
# Log extensions list
- extension_list = map(lambda x: x['name'], extensions)
+ extension_list = map(lambda x: x['alias'], extensions)
LOG.debug("Nova extensions: %s" % ','.join(extension_list))
@test.requires_ext(extension='os-consoles', service='compute')
@@ -52,7 +52,3 @@
resp, extension = self.extensions_client.get_extension('os-consoles')
self.assertEqual(200, resp.status)
self.assertEqual('os-consoles', extension['alias'])
-
-
-class ExtensionsTestXML(ExtensionsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index 86b8395..cb75d07 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -130,9 +130,3 @@
self._migrate_server_to(server_id, target_host)
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
self.assertEqual(target_host, self._get_host_for_server(server_id))
-
-
-class LiveBlockMigrationTestXML(LiveBlockMigrationTestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/extended_status/api/v1.1}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/test_live_block_migration_negative.py b/tempest/api/compute/test_live_block_migration_negative.py
index 95eea19..281b2b3 100644
--- a/tempest/api/compute/test_live_block_migration_negative.py
+++ b/tempest/api/compute/test_live_block_migration_negative.py
@@ -51,9 +51,3 @@
self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
server_id, target_host)
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
-
-class LiveBlockMigrationNegativeTestXML(LiveBlockMigrationNegativeTestJSON):
- _host_key = (
- '{http://docs.openstack.org/compute/ext/extended_status/api/v1.1}host')
- _interface = 'xml'
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index e66b652..4177751 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -76,7 +76,3 @@
resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(200, resp.status)
self.assertEqual(defualt_quota_set, tenant_quota_set)
-
-
-class QuotasTestXML(QuotasTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/__init__.py b/tempest/api/compute/v3/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api/compute/v3/__init__.py
+++ /dev/null
diff --git a/tempest/api/compute/v3/admin/__init__.py b/tempest/api/compute/v3/admin/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api/compute/v3/admin/__init__.py
+++ /dev/null
diff --git a/tempest/api/compute/v3/admin/test_agents.py b/tempest/api/compute/v3/admin/test_agents.py
deleted file mode 100644
index b7c0011..0000000
--- a/tempest/api/compute/v3/admin/test_agents.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class AgentsAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Agents API that require admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(AgentsAdminV3Test, cls).resource_setup()
- cls.client = cls.agents_admin_client
-
- @test.attr(type='gate')
- def test_create_update_list_delete_agents(self):
-
- """
- 1. Create 2 agents.
- 2. Update one of the agents.
- 3. List all agent builds.
- 4. List the agent builds by the filter.
- 5. Delete agents.
- """
- params_kvm = expected_kvm = {'hypervisor': 'kvm',
- 'os': 'win',
- 'architecture': 'x86',
- 'version': '7.0',
- 'url': 'xxx://xxxx/xxx/xxx',
- 'md5hash': ("""add6bb58e139be103324d04d"""
- """82d8f545""")}
-
- resp, agent_kvm = self.client.create_agent(**params_kvm)
- self.assertEqual(201, resp.status)
- for expected_item, value in expected_kvm.items():
- self.assertEqual(value, agent_kvm[expected_item])
-
- params_xen = expected_xen = {'hypervisor': 'xen',
- 'os': 'linux',
- 'architecture': 'x86',
- 'version': '7.0',
- 'url': 'xxx://xxxx/xxx/xxx1',
- 'md5hash': """add6bb58e139be103324d04d8"""
- """2d8f546"""}
-
- resp, agent_xen = self.client.create_agent(**params_xen)
- self.assertEqual(201, resp.status)
-
- for expected_item, value in expected_xen.items():
- self.assertEqual(value, agent_xen[expected_item])
-
- params_kvm_new = expected_kvm_new = {'version': '8.0',
- 'url': 'xxx://xxxx/xxx/xxx2',
- 'md5hash': """add6bb58e139be103"""
- """324d04d82d8f547"""}
-
- resp, resp_agent_kvm = self.client.update_agent(agent_kvm['agent_id'],
- **params_kvm_new)
- self.assertEqual(200, resp.status)
- for expected_item, value in expected_kvm_new.items():
- self.assertEqual(value, resp_agent_kvm[expected_item])
-
- resp, agents = self.client.list_agents()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(agents) > 1)
-
- params_filter = {'hypervisor': 'kvm'}
- resp, agent = self.client.list_agents(params_filter)
- self.assertEqual(200, resp.status)
- self.assertTrue(len(agent) > 0)
- self.assertEqual('kvm', agent[0]['hypervisor'])
-
- resp, _ = self.client.delete_agent(agent_kvm['agent_id'])
- self.assertEqual(204, resp.status)
- resp, _ = self.client.delete_agent(agent_xen['agent_id'])
- self.assertEqual(204, resp.status)
diff --git a/tempest/api/compute/v3/admin/test_aggregates.py b/tempest/api/compute/v3/admin/test_aggregates.py
deleted file mode 100644
index 1beeb13..0000000
--- a/tempest/api/compute/v3/admin/test_aggregates.py
+++ /dev/null
@@ -1,213 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common import tempest_fixtures as fixtures
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-class AggregatesAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Aggregates API that require admin privileges
- """
-
- _host_key = 'os-extended-server-attributes:host'
-
- @classmethod
- def resource_setup(cls):
- super(AggregatesAdminV3Test, cls).resource_setup()
- cls.client = cls.aggregates_admin_client
- cls.aggregate_name_prefix = 'test_aggregate_'
- cls.az_name_prefix = 'test_az_'
-
- resp, hosts_all = cls.hosts_admin_client.list_hosts()
- hosts = map(lambda x: x['host_name'],
- filter(lambda y: y['service'] == 'compute', hosts_all))
- cls.host = hosts[0]
-
- @test.attr(type='gate')
- def test_aggregate_create_delete(self):
- # Create and delete an aggregate.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.assertEqual(aggregate_name, aggregate['name'])
- self.assertIsNone(aggregate['availability_zone'])
-
- resp, _ = self.client.delete_aggregate(aggregate['id'])
- self.assertEqual(204, resp.status)
- self.client.wait_for_resource_deletion(aggregate['id'])
-
- @test.attr(type='gate')
- def test_aggregate_create_delete_with_az(self):
- # Create and delete an aggregate.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- az_name = data_utils.rand_name(self.az_name_prefix)
- resp, aggregate = self.client.create_aggregate(
- name=aggregate_name, availability_zone=az_name)
- self.assertEqual(201, resp.status)
- self.assertEqual(aggregate_name, aggregate['name'])
- self.assertEqual(az_name, aggregate['availability_zone'])
-
- resp, _ = self.client.delete_aggregate(aggregate['id'])
- self.assertEqual(204, resp.status)
- self.client.wait_for_resource_deletion(aggregate['id'])
-
- @test.attr(type='gate')
- def test_aggregate_create_verify_entry_in_list(self):
- # Create an aggregate and ensure it is listed.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- resp, aggregates = self.client.list_aggregates()
- self.assertEqual(200, resp.status)
- self.assertIn((aggregate['id'], aggregate['availability_zone']),
- map(lambda x: (x['id'], x['availability_zone']),
- aggregates))
-
- @test.attr(type='gate')
- def test_aggregate_create_update_metadata_get_details(self):
- # Create an aggregate and ensure its details are returned.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- resp, body = self.client.get_aggregate(aggregate['id'])
- self.assertEqual(200, resp.status)
- self.assertEqual(aggregate['name'], body['name'])
- self.assertEqual(aggregate['availability_zone'],
- body['availability_zone'])
- self.assertEqual({}, body["metadata"])
-
- # set the metadata of the aggregate
- meta = {"key": "value"}
- resp, body = self.client.set_metadata(aggregate['id'], meta)
- self.assertEqual(200, resp.status)
- self.assertEqual(meta, body["metadata"])
-
- # verify the metadata has been set
- resp, body = self.client.get_aggregate(aggregate['id'])
- self.assertEqual(200, resp.status)
- self.assertEqual(meta, body["metadata"])
-
- @test.attr(type='gate')
- def test_aggregate_create_update_with_az(self):
- # Update an aggregate and ensure properties are updated correctly
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- az_name = data_utils.rand_name(self.az_name_prefix)
- resp, aggregate = self.client.create_aggregate(
- name=aggregate_name, availability_zone=az_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertEqual(201, resp.status)
- self.assertEqual(aggregate_name, aggregate['name'])
- self.assertEqual(az_name, aggregate['availability_zone'])
- self.assertIsNotNone(aggregate['id'])
-
- aggregate_id = aggregate['id']
- new_aggregate_name = aggregate_name + '_new'
- new_az_name = az_name + '_new'
-
- resp, resp_aggregate = self.client.update_aggregate(aggregate_id,
- new_aggregate_name,
- new_az_name)
- self.assertEqual(200, resp.status)
- self.assertEqual(new_aggregate_name, resp_aggregate['name'])
- self.assertEqual(new_az_name, resp_aggregate['availability_zone'])
-
- resp, aggregates = self.client.list_aggregates()
- self.assertEqual(200, resp.status)
- self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
- map(lambda x:
- (x['id'], x['name'], x['availability_zone']),
- aggregates))
-
- @test.attr(type='gate')
- def test_aggregate_add_remove_host(self):
- # Add an host to the given aggregate and remove.
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- resp, body = self.client.add_host(aggregate['id'], self.host)
- self.assertEqual(202, resp.status)
- self.assertEqual(aggregate_name, body['name'])
- self.assertEqual(aggregate['availability_zone'],
- body['availability_zone'])
- self.assertIn(self.host, body['hosts'])
-
- resp, body = self.client.remove_host(aggregate['id'], self.host)
- self.assertEqual(202, resp.status)
- self.assertEqual(aggregate_name, body['name'])
- self.assertEqual(aggregate['availability_zone'],
- body['availability_zone'])
- self.assertNotIn(self.host, body['hosts'])
-
- @test.attr(type='gate')
- def test_aggregate_add_host_list(self):
- # Add an host to the given aggregate and list.
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
-
- resp, aggregates = self.client.list_aggregates()
- aggs = filter(lambda x: x['id'] == aggregate['id'], aggregates)
- self.assertEqual(1, len(aggs))
- agg = aggs[0]
- self.assertEqual(aggregate_name, agg['name'])
- self.assertIsNone(agg['availability_zone'])
- self.assertIn(self.host, agg['hosts'])
-
- @test.attr(type='gate')
- def test_aggregate_add_host_get_details(self):
- # Add an host to the given aggregate and get details.
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
-
- resp, body = self.client.get_aggregate(aggregate['id'])
- self.assertEqual(aggregate_name, body['name'])
- self.assertIsNone(body['availability_zone'])
- self.assertIn(self.host, body['hosts'])
-
- @test.attr(type='gate')
- def test_aggregate_add_host_create_server_with_az(self):
- # Add an host to the given aggregate and create a server.
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- az_name = data_utils.rand_name(self.az_name_prefix)
- resp, aggregate = self.client.create_aggregate(
- name=aggregate_name, availability_zone=az_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.client.add_host(aggregate['id'], self.host)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
- server_name = data_utils.rand_name('test_server_')
- admin_servers_client = self.servers_admin_client
- resp, server = self.create_test_server(name=server_name,
- availability_zone=az_name,
- wait_until='ACTIVE')
- resp, body = admin_servers_client.get_server(server['id'])
- self.assertEqual(self.host, body[self._host_key])
diff --git a/tempest/api/compute/v3/admin/test_aggregates_negative.py b/tempest/api/compute/v3/admin/test_aggregates_negative.py
deleted file mode 100644
index 093963f..0000000
--- a/tempest/api/compute/v3/admin/test_aggregates_negative.py
+++ /dev/null
@@ -1,188 +0,0 @@
-# Copyright 2013 Huawei Technologies Co.,LTD.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common import tempest_fixtures as fixtures
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class AggregatesAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Aggregates API that require admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(AggregatesAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.aggregates_admin_client
- cls.user_client = cls.aggregates_client
- cls.aggregate_name_prefix = 'test_aggregate_'
- cls.az_name_prefix = 'test_az_'
-
- resp, hosts_all = cls.hosts_admin_client.list_hosts()
- hosts = map(lambda x: x['host_name'],
- filter(lambda y: y['service'] == 'compute', hosts_all))
- cls.host = hosts[0]
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_create_as_user(self):
- # Regular user is not allowed to create an aggregate.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.create_aggregate,
- name=aggregate_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_create_aggregate_name_length_less_than_1(self):
- # the length of aggregate name should >= 1 and <=255
- self.assertRaises(exceptions.BadRequest,
- self.client.create_aggregate,
- name='')
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_create_aggregate_name_length_exceeds_255(self):
- # the length of aggregate name should >= 1 and <=255
- aggregate_name = 'a' * 256
- self.assertRaises(exceptions.BadRequest,
- self.client.create_aggregate,
- name=aggregate_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_create_with_existent_aggregate_name(self):
- # creating an aggregate with existent aggregate name is forbidden
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Conflict,
- self.client.create_aggregate,
- name=aggregate_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_delete_as_user(self):
- # Regular user is not allowed to delete an aggregate.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.delete_aggregate,
- aggregate['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_list_as_user(self):
- # Regular user is not allowed to list aggregates.
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.list_aggregates)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_get_details_as_user(self):
- # Regular user is not allowed to get aggregate details.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.get_aggregate,
- aggregate['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_delete_with_invalid_id(self):
- # Delete an aggregate with invalid id should raise exceptions.
- self.assertRaises(exceptions.NotFound,
- self.client.delete_aggregate, -1)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_get_details_with_invalid_id(self):
- # Get aggregate details with invalid id should raise exceptions.
- self.assertRaises(exceptions.NotFound,
- self.client.get_aggregate, -1)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_add_non_exist_host(self):
- # Adding a non-exist host to an aggregate should raise exceptions.
- resp, hosts_all = self.hosts_admin_client.list_hosts()
- hosts = map(lambda x: x['host_name'], hosts_all)
- while True:
- non_exist_host = data_utils.rand_name('nonexist_host_')
- if non_exist_host not in hosts:
- break
-
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.NotFound, self.client.add_host,
- aggregate['id'], non_exist_host)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_add_host_as_user(self):
- # Regular user is not allowed to add a host to an aggregate.
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.add_host,
- aggregate['id'], self.host)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_add_existent_host(self):
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- resp, body = self.client.add_host(aggregate['id'], self.host)
- self.assertEqual(202, resp.status)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
-
- self.assertRaises(exceptions.Conflict, self.client.add_host,
- aggregate['id'], self.host)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_remove_host_as_user(self):
- # Regular user is not allowed to remove a host from an aggregate.
- self.useFixture(fixtures.LockFixture('availability_zone'))
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- resp, body = self.client.add_host(aggregate['id'], self.host)
- self.assertEqual(202, resp.status)
- self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.remove_host,
- aggregate['id'], self.host)
-
- @test.attr(type=['negative', 'gate'])
- def test_aggregate_remove_nonexistent_host(self):
- non_exist_host = data_utils.rand_name('nonexist_host_')
- aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.NotFound, self.client.remove_host,
- aggregate['id'], non_exist_host)
diff --git a/tempest/api/compute/v3/admin/test_availability_zone_negative.py b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
deleted file mode 100644
index 56cdd6c..0000000
--- a/tempest/api/compute/v3/admin/test_availability_zone_negative.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-
-
-class AZAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Availability Zone API List
- """
-
- @classmethod
- def resource_setup(cls):
- super(AZAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.availability_zone_admin_client
- cls.non_adm_client = cls.availability_zone_client
-
- @test.attr(type=['negative', 'gate'])
- def test_get_availability_zone_list_detail_with_non_admin_user(self):
- # List of availability zones and available services with
- # non-administrator user
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_availability_zone_list_detail)
diff --git a/tempest/api/compute/v3/admin/test_flavors.py b/tempest/api/compute/v3/admin/test_flavors.py
deleted file mode 100644
index f307907..0000000
--- a/tempest/api/compute/v3/admin/test_flavors.py
+++ /dev/null
@@ -1,308 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class FlavorsAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Flavors API Create and Delete that require admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsAdminV3Test, cls).resource_setup()
-
- cls.client = cls.flavors_admin_client
- cls.user_client = cls.flavors_client
- cls.flavor_name_prefix = 'test_flavor_'
- cls.ram = 512
- cls.vcpus = 1
- cls.disk = 10
- cls.ephemeral = 10
- cls.swap = 1024
- cls.rxtx = 2
-
- def flavor_clean_up(self, flavor_id):
- resp, body = self.client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 204)
- self.client.wait_for_resource_deletion(flavor_id)
-
- def _create_flavor(self, flavor_id):
- # Create a flavor and ensure it is listed
- # This operation requires the user to have 'admin' role
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
-
- # Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(201, resp.status)
- self.assertEqual(flavor['name'], flavor_name)
- self.assertEqual(flavor['vcpus'], self.vcpus)
- self.assertEqual(flavor['disk'], self.disk)
- self.assertEqual(flavor['ram'], self.ram)
- self.assertEqual(flavor['swap'], self.swap)
- if test.is_extension_enabled("os-flavor-rxtx", "compute_v3"):
- self.assertEqual(flavor['os-flavor-rxtx:rxtx_factor'], self.rxtx)
- self.assertEqual(flavor['ephemeral'],
- self.ephemeral)
- self.assertEqual(flavor['flavor-access:is_public'], True)
-
- # Verify flavor is retrieved
- resp, flavor = self.client.get_flavor_details(flavor['id'])
- self.assertEqual(resp.status, 200)
- self.assertEqual(flavor['name'], flavor_name)
-
- return flavor['id']
-
- @test.attr(type='gate')
- def test_create_flavor_with_int_id(self):
- flavor_id = data_utils.rand_int_id(start=1000)
- new_flavor_id = self._create_flavor(flavor_id)
- self.assertEqual(new_flavor_id, str(flavor_id))
-
- @test.attr(type='gate')
- def test_create_flavor_with_uuid_id(self):
- flavor_id = str(uuid.uuid4())
- new_flavor_id = self._create_flavor(flavor_id)
- self.assertEqual(new_flavor_id, flavor_id)
-
- @test.attr(type='gate')
- def test_create_flavor_with_none_id(self):
- # If nova receives a request with None as flavor_id,
- # nova generates flavor_id of uuid.
- flavor_id = None
- new_flavor_id = self._create_flavor(flavor_id)
- self.assertEqual(new_flavor_id, str(uuid.UUID(new_flavor_id)))
-
- @test.attr(type='gate')
- def test_create_flavor_verify_entry_in_list_details(self):
- # Create a flavor and ensure it's details are listed
- # This operation requires the user to have 'admin' role
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- # Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- flag = False
- # Verify flavor is retrieved
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- flag = True
- self.assertTrue(flag)
-
- @test.attr(type='gate')
- def test_create_list_flavor_without_extra_data(self):
- # Create a flavor and ensure it is listed
- # This operation requires the user to have 'admin' role
-
- def verify_flavor_response_extension(flavor):
- # check some extensions for the flavor create/show/detail response
- self.assertEqual(flavor['swap'], 0)
- if test.is_extension_enabled("os-flavor-rxtx", "compute_v3"):
- self.assertEqual(int(flavor['os-flavor-rxtx:rxtx_factor']), 1)
- self.assertEqual(int(flavor['ephemeral']), 0)
- self.assertEqual(flavor['flavor-access:is_public'], True)
-
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- # Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(201, resp.status)
- self.assertEqual(flavor['name'], flavor_name)
- self.assertEqual(flavor['ram'], self.ram)
- self.assertEqual(flavor['vcpus'], self.vcpus)
- self.assertEqual(flavor['disk'], self.disk)
- self.assertEqual(int(flavor['id']), new_flavor_id)
- verify_flavor_response_extension(flavor)
-
- # Verify flavor is retrieved
- resp, flavor = self.client.get_flavor_details(new_flavor_id)
- self.assertEqual(resp.status, 200)
- self.assertEqual(flavor['name'], flavor_name)
- verify_flavor_response_extension(flavor)
-
- # Check if flavor is present in list
- resp, flavors = self.user_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- verify_flavor_response_extension(flavor)
- flag = True
- self.assertTrue(flag)
-
- @test.attr(type='gate')
- def test_list_non_public_flavor(self):
- # Create a flavor with os-flavor-access:is_public false should
- # be present in list_details.
- # This operation requires the user to have 'admin' role
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- # Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public="False")
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- # Verify flavor is retrieved
- flag = False
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- flag = True
- self.assertTrue(flag)
-
- # Verify flavor is not retrieved with other user
- flag = False
- resp, flavors = self.user_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- flag = True
- self.assertFalse(flag)
-
- @test.attr(type='gate')
- def test_create_server_with_non_public_flavor(self):
- # Create a flavor with os-flavor-access:is_public false
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- # Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public="False")
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(201, resp.status)
-
- # Verify flavor is not used by other user
- self.assertRaises(exceptions.BadRequest,
- self.servers_client.create_server,
- 'test', self.image_ref, flavor['id'])
-
- @test.attr(type='gate')
- def test_list_public_flavor_with_other_user(self):
- # Create a Flavor with public access.
- # Try to List/Get flavor with another user
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- # Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public="True")
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- flag = False
- self.new_client = self.flavors_client
- # Verify flavor is retrieved with new user
- resp, flavors = self.new_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- flag = True
- self.assertTrue(flag)
-
- @test.attr(type='gate')
- def test_is_public_string_variations(self):
- flavor_id_not_public = data_utils.rand_int_id(start=1000)
- flavor_name_not_public = data_utils.rand_name(self.flavor_name_prefix)
- flavor_id_public = data_utils.rand_int_id(start=1000)
- flavor_name_public = data_utils.rand_name(self.flavor_name_prefix)
-
- # Create a non public flavor
- resp, flavor = self.client.create_flavor(flavor_name_not_public,
- self.ram, self.vcpus,
- self.disk,
- flavor_id_not_public,
- is_public="False")
- self.addCleanup(self.flavor_clean_up, flavor['id'])
-
- # Create a public flavor
- resp, flavor = self.client.create_flavor(flavor_name_public,
- self.ram, self.vcpus,
- self.disk,
- flavor_id_public,
- is_public="True")
- self.addCleanup(self.flavor_clean_up, flavor['id'])
-
- def _flavor_lookup(flavors, flavor_name):
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- return flavor
- return None
-
- def _test_string_variations(variations, flavor_name):
- for string in variations:
- params = {'is_public': string}
- r, flavors = self.client.list_flavors_with_detail(params)
- self.assertEqual(r.status, 200)
- flavor = _flavor_lookup(flavors, flavor_name)
- self.assertIsNotNone(flavor)
-
- _test_string_variations(['f', 'false', 'no', '0'],
- flavor_name_not_public)
-
- _test_string_variations(['t', 'true', 'yes', '1'],
- flavor_name_public)
-
- @test.attr(type='gate')
- def test_create_flavor_using_string_ram(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- ram = "1024"
- resp, flavor = self.client.create_flavor(flavor_name,
- ram, self.vcpus,
- self.disk,
- new_flavor_id)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(201, resp.status)
- self.assertEqual(flavor['name'], flavor_name)
- self.assertEqual(flavor['vcpus'], self.vcpus)
- self.assertEqual(flavor['disk'], self.disk)
- self.assertEqual(flavor['ram'], int(ram))
- self.assertEqual(int(flavor['id']), new_flavor_id)
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
deleted file mode 100644
index c79e591..0000000
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-class FlavorsAccessV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Flavor Access API extension.
- Add and remove Flavor Access require admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsAccessV3Test, cls).resource_setup()
-
- cls.client = cls.flavors_admin_client
- admin_client = cls._get_identity_admin_client()
- cls.tenant_id = cls.client.tenant_id
- cls.adm_tenant_id = admin_client.tenant_id
- cls.flavor_name_prefix = 'test_flavor_access_'
- cls.ram = 512
- cls.vcpus = 1
- cls.disk = 10
-
- @test.attr(type='gate')
- def test_flavor_access_list_with_private_flavor(self):
- # Test to list flavor access successfully by querying private flavor
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 201)
- resp, flavor_access = self.client.list_flavor_access(new_flavor_id)
- self.assertEqual(resp.status, 200)
- self.assertEqual(len(flavor_access), 1, str(flavor_access))
- first_flavor = flavor_access[0]
- self.assertEqual(str(new_flavor_id), str(first_flavor['flavor_id']))
- self.assertEqual(self.adm_tenant_id, first_flavor['tenant_id'])
-
- @test.attr(type='gate')
- def test_flavor_access_add_remove(self):
- # Test to add and remove flavor access to a given tenant.
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- # Add flavor access to a tenant.
- resp_body = {
- "tenant_id": str(self.tenant_id),
- "flavor_id": str(new_flavor['id']),
- }
- add_resp, add_body = \
- self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
- self.assertEqual(add_resp.status, 200)
- self.assertIn(resp_body, add_body)
-
- # The flavor is present in list.
- resp, flavors = self.flavors_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
-
- # Remove flavor access from a tenant.
- remove_resp, remove_body = \
- self.client.remove_flavor_access(new_flavor['id'], self.tenant_id)
- self.assertEqual(remove_resp.status, 200)
- self.assertNotIn(resp_body, remove_body)
-
- # The flavor is not present in list.
- resp, flavors = self.flavors_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
diff --git a/tempest/api/compute/v3/admin/test_flavors_access_negative.py b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
deleted file mode 100644
index 87e8cbf..0000000
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ /dev/null
@@ -1,134 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class FlavorsAccessNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Flavor Access API extension.
- Add and remove Flavor Access require admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsAccessNegativeV3Test, cls).resource_setup()
-
- cls.client = cls.flavors_admin_client
- cls.tenant_id = cls.client.tenant_id
- cls.flavor_name_prefix = 'test_flavor_access_'
- cls.ram = 512
- cls.vcpus = 1
- cls.disk = 10
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_access_list_with_public_flavor(self):
- # Test to list flavor access with exceptions by querying public flavor
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='True')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 201)
- self.assertRaises(exceptions.NotFound,
- self.client.list_flavor_access,
- new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_non_admin_add(self):
- # Test to add flavor access as a user without admin privileges.
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertRaises(exceptions.Unauthorized,
- self.flavors_client.add_flavor_access,
- new_flavor['id'],
- self.tenant_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_non_admin_remove(self):
- # Test to remove flavor access as a user without admin privileges.
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- # Add flavor access to a tenant.
- self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
- self.addCleanup(self.client.remove_flavor_access,
- new_flavor['id'], self.tenant_id)
- self.assertRaises(exceptions.Unauthorized,
- self.flavors_client.remove_flavor_access,
- new_flavor['id'],
- self.tenant_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_add_flavor_access_duplicate(self):
- # Create a new flavor.
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
-
- # Add flavor access to a tenant.
- self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
- self.addCleanup(self.client.remove_flavor_access,
- new_flavor['id'], self.tenant_id)
-
- # An exception should be raised when adding flavor access to the same
- # tenant
- self.assertRaises(exceptions.Conflict,
- self.client.add_flavor_access,
- new_flavor['id'],
- self.tenant_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_remove_flavor_access_not_found(self):
- # Create a new flavor.
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
- self.addCleanup(self.client.delete_flavor, new_flavor['id'])
-
- # An exception should be raised when flavor access is not found
- self.assertRaises(exceptions.NotFound,
- self.client.remove_flavor_access,
- new_flavor['id'],
- str(uuid.uuid4()))
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
deleted file mode 100644
index 24844b1..0000000
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-class FlavorsExtraSpecsV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Flavor Extra Spec API extension.
- SET, UNSET, UPDATE Flavor Extra specs require admin privileges.
- GET Flavor Extra specs can be performed even by without admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsExtraSpecsV3Test, cls).resource_setup()
-
- cls.client = cls.flavors_admin_client
- flavor_name = data_utils.rand_name('test_flavor')
- ram = 512
- vcpus = 1
- disk = 10
- ephemeral = 10
- cls.new_flavor_id = data_utils.rand_int_id(start=1000)
- swap = 1024
- rxtx = 1
- # Create a flavor so as to set/get/unset extra specs
- resp, cls.flavor = cls.client.create_flavor(flavor_name,
- ram, vcpus,
- disk,
- cls.new_flavor_id,
- ephemeral=ephemeral,
- swap=swap, rxtx=rxtx)
-
- @classmethod
- def resource_cleanup(cls):
- resp, body = cls.client.delete_flavor(cls.flavor['id'])
- cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsV3Test, cls).resource_cleanup()
-
- @test.attr(type='gate')
- def test_flavor_set_get_update_show_unset_keys(self):
- # Test to SET, GET, UPDATE, SHOW, UNSET flavor extra
- # spec as a user with admin privileges.
- # Assigning extra specs values that are to be set
- specs = {"key1": "value1", "key2": "value2"}
- # SET extra specs to the flavor created in setUp
- set_resp, set_body = \
- self.client.set_flavor_extra_spec(self.flavor['id'], specs)
- self.assertEqual(set_resp.status, 201)
- self.assertEqual(set_body, specs)
- # GET extra specs and verify
- get_resp, get_body = \
- self.client.get_flavor_extra_spec(self.flavor['id'])
- self.assertEqual(get_resp.status, 200)
- self.assertEqual(get_body, specs)
-
- # UPDATE the value of the extra specs key1
- update_resp, update_body = \
- self.client.update_flavor_extra_spec(self.flavor['id'],
- "key1",
- key1="value")
- self.assertEqual(update_resp.status, 200)
- self.assertEqual({"key1": "value"}, update_body)
-
- # GET extra specs and verify the value of the key2
- # is the same as before
- get_resp, get_body = \
- self.client.get_flavor_extra_spec(self.flavor['id'])
- self.assertEqual(get_resp.status, 200)
- self.assertEqual(get_body, {"key1": "value", "key2": "value2"})
-
- # UNSET extra specs that were set in this test
- unset_resp, _ = \
- self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")
- self.assertEqual(unset_resp.status, 204)
- unset_resp, _ = \
- self.client.unset_flavor_extra_spec(self.flavor['id'], "key2")
- self.assertEqual(unset_resp.status, 204)
-
- @test.attr(type='gate')
- def test_flavor_non_admin_get_all_keys(self):
- specs = {"key1": "value1", "key2": "value2"}
- set_resp, set_body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
- resp, body = self.flavors_client.get_flavor_extra_spec(
- self.flavor['id'])
- self.assertEqual(resp.status, 200)
-
- for key in specs:
- self.assertEqual(body[key], specs[key])
-
- @test.attr(type='gate')
- def test_flavor_non_admin_get_specific_key(self):
- specs = {"key1": "value1", "key2": "value2"}
- resp, body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
- self.assertEqual(resp.status, 201)
- self.assertEqual(body['key1'], 'value1')
- self.assertIn('key2', body)
- resp, body = self.flavors_client.get_flavor_extra_spec_with_key(
- self.flavor['id'], 'key1')
- self.assertEqual(resp.status, 200)
- self.assertEqual(body['key1'], 'value1')
- self.assertNotIn('key2', body)
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
deleted file mode 100644
index 5fcd7a4..0000000
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class FlavorsExtraSpecsNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Negative Tests Flavor Extra Spec API extension.
- SET, UNSET, UPDATE Flavor Extra specs require admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsExtraSpecsNegativeV3Test, cls).resource_setup()
-
- cls.client = cls.flavors_admin_client
- flavor_name = data_utils.rand_name('test_flavor')
- ram = 512
- vcpus = 1
- disk = 10
- ephemeral = 10
- cls.new_flavor_id = data_utils.rand_int_id(start=1000)
- swap = 1024
- rxtx = 1
- # Create a flavor
- resp, cls.flavor = cls.client.create_flavor(flavor_name,
- ram, vcpus,
- disk,
- cls.new_flavor_id,
- ephemeral=ephemeral,
- swap=swap, rxtx=rxtx)
-
- @classmethod
- def resource_cleanup(cls):
- resp, body = cls.client.delete_flavor(cls.flavor['id'])
- cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsNegativeV3Test, cls).resource_cleanup()
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_non_admin_set_keys(self):
- # Test to SET flavor extra spec as a user without admin privileges.
- specs = {"key1": "value1", "key2": "value2"}
- self.assertRaises(exceptions.Unauthorized,
- self.flavors_client.set_flavor_extra_spec,
- self.flavor['id'],
- specs)
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_non_admin_update_specific_key(self):
- # non admin user is not allowed to update flavor extra spec
- specs = {"key1": "value1", "key2": "value2"}
- resp, body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
- self.assertEqual(resp.status, 201)
- self.assertEqual(body['key1'], 'value1')
- self.assertRaises(exceptions.Unauthorized,
- self.flavors_client.
- update_flavor_extra_spec,
- self.flavor['id'],
- 'key1',
- key1='value1_new')
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_non_admin_unset_keys(self):
- specs = {"key1": "value1", "key2": "value2"}
- set_resp, set_body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
-
- self.assertRaises(exceptions.Unauthorized,
- self.flavors_client.unset_flavor_extra_spec,
- self.flavor['id'],
- 'key1')
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_unset_nonexistent_key(self):
- nonexistent_key = data_utils.rand_name('flavor_key')
- self.assertRaises(exceptions.NotFound,
- self.client.unset_flavor_extra_spec,
- self.flavor['id'],
- nonexistent_key)
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_get_nonexistent_key(self):
- self.assertRaises(exceptions.NotFound,
- self.flavors_client.get_flavor_extra_spec_with_key,
- self.flavor['id'],
- "nonexistent_key")
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_update_mismatch_key(self):
- # the key will be updated should be match the key in the body
- self.assertRaises(exceptions.BadRequest,
- self.client.update_flavor_extra_spec,
- self.flavor['id'],
- "key2",
- key1="value")
-
- @test.attr(type=['negative', 'gate'])
- def test_flavor_update_more_key(self):
- # there should be just one item in the request body
- self.assertRaises(exceptions.BadRequest,
- self.client.update_flavor_extra_spec,
- self.flavor['id'],
- "key1",
- key1="value",
- key2="value")
diff --git a/tempest/api/compute/v3/admin/test_flavors_negative.py b/tempest/api/compute/v3/admin/test_flavors_negative.py
deleted file mode 100644
index 426d13e..0000000
--- a/tempest/api/compute/v3/admin/test_flavors_negative.py
+++ /dev/null
@@ -1,333 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class FlavorsAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Flavors API Create and Delete that require admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(FlavorsAdminNegativeV3Test, cls).resource_setup()
-
- cls.client = cls.flavors_admin_client
- cls.user_client = cls.flavors_client
- cls.flavor_name_prefix = 'test_flavor_'
- cls.ram = 512
- cls.vcpus = 1
- cls.disk = 10
- cls.ephemeral = 10
- cls.swap = 1024
- cls.rxtx = 2
-
- def flavor_clean_up(self, flavor_id):
- resp, body = self.client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 204)
- self.client.wait_for_resource_deletion(flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_flavor_details_for_deleted_flavor(self):
- # Delete a flavor and ensure it is not listed
- # Create a test flavor
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
-
- # no need to specify flavor_id, we can get the flavor_id from a
- # response of create_flavor() call.
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram,
- self.vcpus, self.disk,
- None,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- # Delete the flavor
- new_flavor_id = flavor['id']
- resp_delete, body = self.client.delete_flavor(new_flavor_id)
- self.assertEqual(201, resp.status)
- self.assertEqual(204, resp_delete.status)
-
- # Deleted flavors can be seen via detailed GET
- resp, flavor = self.client.get_flavor_details(new_flavor_id)
- self.assertEqual(resp.status, 200)
- self.assertEqual(flavor['name'], flavor_name)
-
- # Deleted flavors should not show up in a list however
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- flag = True
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- flag = False
- self.assertTrue(flag)
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_is_public_string(self):
- # the 'is_public' parameter can be 'none/true/false' if it exists
- self.assertRaises(exceptions.BadRequest,
- self.client.list_flavors_with_detail,
- {'is_public': 'invalid'})
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_as_user(self):
- # only admin user can create a flavor
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.create_flavor,
- flavor_name, self.ram, self.vcpus, self.disk,
- new_flavor_id, ephemeral=self.ephemeral,
- swap=self.swap, rxtx=self.rxtx)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_flavor_as_user(self):
- # only admin user can delete a flavor
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.delete_flavor,
- self.flavor_ref_alt)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_ram(self):
- # the 'ram' attribute must be positive integer
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, -1, self.vcpus,
- self.disk, new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_vcpus(self):
- # the 'vcpu' attribute must be positive integer
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, self.ram, -1,
- self.disk, new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_name_length_less_than_1(self):
- # ensure name length >= 1
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- '',
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_name_length_exceeds_255(self):
- # ensure name do not exceed 255 characters
- new_flavor_name = 'a' * 256
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_name(self):
- # the regex of flavor_name is '^[\w\.\- ]*$'
- invalid_flavor_name = data_utils.rand_name('invalid-!@#$%-')
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- invalid_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_flavor_id(self):
- # the regex of flavor_id is '^[\w\.\- ]*$', and it cannot contain
- # leading and/or trailing whitespace
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- invalid_flavor_id = '!@#$%'
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- invalid_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_id_length_exceeds_255(self):
- # the length of flavor_id should not exceed 255 characters
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- invalid_flavor_id = 'a' * 256
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- invalid_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_root_gb(self):
- # root_gb attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- -1,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_ephemeral_gb(self):
- # ephemeral_gb attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=-1,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_swap(self):
- # swap attribute should be non-negative ( >= 0) integer
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=-1,
- rxtx=self.rxtx,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_rxtx_factor(self):
- # rxtx_factor attribute should be a positive float
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=-1.5,
- is_public='False')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_with_invalid_is_public(self):
- # is_public attribute should be boolean
- new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- new_flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx,
- is_public='Invalid')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_already_exists(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = str(uuid.uuid4())
-
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- self.assertEqual(201, resp.status)
- self.addCleanup(self.flavor_clean_up, flavor['id'])
-
- self.assertRaises(exceptions.Conflict,
- self.client.create_flavor,
- flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_nonexistent_flavor(self):
- nonexistent_flavor_id = str(uuid.uuid4())
-
- self.assertRaises(exceptions.NotFound,
- self.client.delete_flavor,
- nonexistent_flavor_id)
diff --git a/tempest/api/compute/v3/admin/test_hosts.py b/tempest/api/compute/v3/admin/test_hosts.py
deleted file mode 100644
index 898a704..0000000
--- a/tempest/api/compute/v3/admin/test_hosts.py
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common import tempest_fixtures as fixtures
-from tempest import test
-
-
-class HostsAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests hosts API using admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(HostsAdminV3Test, cls).resource_setup()
- cls.client = cls.hosts_admin_client
-
- @test.attr(type='gate')
- def test_list_hosts(self):
- resp, hosts = self.client.list_hosts()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(hosts) >= 2, str(hosts))
-
- @test.attr(type='gate')
- def test_list_hosts_with_zone(self):
- self.useFixture(fixtures.LockFixture('availability_zone'))
- resp, hosts = self.client.list_hosts()
- host = hosts[0]
- zone_name = host['zone']
- params = {'zone': zone_name}
- resp, hosts = self.client.list_hosts(params)
- self.assertEqual(200, resp.status)
- self.assertTrue(len(hosts) >= 1)
- self.assertIn(host, hosts)
-
- @test.attr(type='gate')
- def test_list_hosts_with_a_blank_zone(self):
- # If send the request with a blank zone, the request will be successful
- # and it will return all the hosts list
- params = {'zone': ''}
- resp, hosts = self.client.list_hosts(params)
- self.assertNotEqual(0, len(hosts))
- self.assertEqual(200, resp.status)
-
- @test.attr(type='gate')
- def test_list_hosts_with_nonexistent_zone(self):
- # If send the request with a nonexistent zone, the request will be
- # successful and no hosts will be retured
- params = {'zone': 'xxx'}
- resp, hosts = self.client.list_hosts(params)
- self.assertEqual(0, len(hosts))
- self.assertEqual(200, resp.status)
-
- @test.attr(type='gate')
- def test_show_host_detail(self):
- resp, hosts = self.client.list_hosts()
- self.assertEqual(200, resp.status)
-
- hosts = [host for host in hosts if host['service'] == 'compute']
- self.assertTrue(len(hosts) >= 1)
-
- for host in hosts:
- hostname = host['host_name']
- resp, resources = self.client.show_host_detail(hostname)
- self.assertEqual(200, resp.status)
- self.assertTrue(len(resources) >= 1)
- host_resource = resources[0]['resource']
- self.assertIsNotNone(host_resource)
- self.assertIsNotNone(host_resource['cpu'])
- self.assertIsNotNone(host_resource['disk_gb'])
- self.assertIsNotNone(host_resource['memory_mb'])
- self.assertIsNotNone(host_resource['project'])
- self.assertEqual(hostname, host_resource['host'])
diff --git a/tempest/api/compute/v3/admin/test_hosts_negative.py b/tempest/api/compute/v3/admin/test_hosts_negative.py
deleted file mode 100644
index 2b82baa..0000000
--- a/tempest/api/compute/v3/admin/test_hosts_negative.py
+++ /dev/null
@@ -1,168 +0,0 @@
-# Copyright 2013 Huawei Technologies Co.,LTD.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class HostsAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests hosts API using admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(HostsAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.hosts_admin_client
- cls.non_admin_client = cls.hosts_client
-
- def _get_host_name(self):
- resp, hosts = self.client.list_hosts()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(hosts) >= 1)
- hostname = hosts[0]['host_name']
- return hostname
-
- @test.attr(type=['negative', 'gate'])
- def test_list_hosts_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.list_hosts)
-
- @test.attr(type=['negative', 'gate'])
- def test_show_host_detail_with_nonexistent_hostname(self):
- nonexitent_hostname = data_utils.rand_name('rand_hostname')
- self.assertRaises(exceptions.NotFound,
- self.client.show_host_detail, nonexitent_hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_show_host_detail_with_non_admin_user(self):
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.show_host_detail,
- hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_host_with_non_admin_user(self):
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.update_host,
- hostname,
- status='enable',
- maintenance_mode='enable')
-
- @test.attr(type=['negative', 'gate'])
- def test_update_host_with_extra_param(self):
- # only 'status' and 'maintenance_mode' are the valid params.
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.BadRequest,
- self.client.update_host,
- hostname,
- status='enable',
- maintenance_mode='enable',
- param='XXX')
-
- @test.attr(type=['negative', 'gate'])
- def test_update_host_with_invalid_status(self):
- # 'status' can only be 'enable' or 'disable'
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.BadRequest,
- self.client.update_host,
- hostname,
- status='invalid',
- maintenance_mode='enable')
-
- @test.attr(type=['negative', 'gate'])
- def test_update_host_with_invalid_maintenance_mode(self):
- # 'maintenance_mode' can only be 'enable' or 'disable'
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.BadRequest,
- self.client.update_host,
- hostname,
- status='enable',
- maintenance_mode='invalid')
-
- @test.attr(type=['negative', 'gate'])
- def test_update_host_without_param(self):
- # 'status' or 'maintenance_mode' needed for host update
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.BadRequest,
- self.client.update_host,
- hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_nonexistent_host(self):
- nonexitent_hostname = data_utils.rand_name('rand_hostname')
-
- self.assertRaises(exceptions.NotFound,
- self.client.update_host,
- nonexitent_hostname,
- status='enable',
- maintenance_mode='enable')
-
- @test.attr(type=['negative', 'gate'])
- def test_startup_nonexistent_host(self):
- nonexitent_hostname = data_utils.rand_name('rand_hostname')
-
- self.assertRaises(exceptions.NotFound,
- self.client.startup_host,
- nonexitent_hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_startup_host_with_non_admin_user(self):
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.startup_host,
- hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_shutdown_nonexistent_host(self):
- nonexitent_hostname = data_utils.rand_name('rand_hostname')
-
- self.assertRaises(exceptions.NotFound,
- self.client.shutdown_host,
- nonexitent_hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_shutdown_host_with_non_admin_user(self):
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.shutdown_host,
- hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_reboot_nonexistent_host(self):
- nonexitent_hostname = data_utils.rand_name('rand_hostname')
-
- self.assertRaises(exceptions.NotFound,
- self.client.reboot_host,
- nonexitent_hostname)
-
- @test.attr(type=['negative', 'gate'])
- def test_reboot_host_with_non_admin_user(self):
- hostname = self._get_host_name()
-
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.reboot_host,
- hostname)
diff --git a/tempest/api/compute/v3/admin/test_hypervisor.py b/tempest/api/compute/v3/admin/test_hypervisor.py
deleted file mode 100644
index 831e20f..0000000
--- a/tempest/api/compute/v3/admin/test_hypervisor.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class HypervisorAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Hypervisors API that require admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(HypervisorAdminV3Test, cls).resource_setup()
- cls.client = cls.hypervisor_admin_client
-
- def _list_hypervisors(self):
- # List of hypervisors
- resp, hypers = self.client.get_hypervisor_list()
- self.assertEqual(200, resp.status)
- return hypers
-
- @test.attr(type='gate')
- def test_get_hypervisor_list(self):
- # List of hypervisor and available hypervisors hostname
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- @test.attr(type='gate')
- def test_get_hypervisor_list_details(self):
- # Display the details of the all hypervisor
- resp, hypers = self.client.get_hypervisor_list_details()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(hypers) > 0)
-
- @test.attr(type='gate')
- def test_get_hypervisor_show_details(self):
- # Display the details of the specified hypervisor
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- resp, details = (self.client.
- get_hypervisor_show_details(hypers[0]['id']))
- self.assertEqual(200, resp.status)
- self.assertTrue(len(details) > 0)
- self.assertEqual(details['hypervisor_hostname'],
- hypers[0]['hypervisor_hostname'])
-
- @test.attr(type='gate')
- def test_get_hypervisor_show_servers(self):
- # Show instances about the specific hypervisors
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- hypervisor_id = hypers[0]['id']
- resp, hypervisors = self.client.get_hypervisor_servers(hypervisor_id)
- self.assertEqual(200, resp.status)
- self.assertTrue(len(hypervisors) > 0)
-
- @test.attr(type='gate')
- def test_get_hypervisor_stats(self):
- # Verify the stats of the all hypervisor
- resp, stats = self.client.get_hypervisor_stats()
- self.assertEqual(200, resp.status)
- self.assertTrue(len(stats) > 0)
-
- @test.attr(type='gate')
- def test_get_hypervisor_uptime(self):
- # Verify that GET shows the specified hypervisor uptime
- hypers = self._list_hypervisors()
-
- # Ironic will register each baremetal node as a 'hypervisor',
- # so the hypervisor list can contain many hypervisors of type
- # 'ironic'. If they are ALL ironic, skip this test since ironic
- # doesn't support hypervisor uptime. Otherwise, remove them
- # from the list of hypervisors to test.
- ironic_only = True
- hypers_without_ironic = []
- for hyper in hypers:
- resp, details = (self.client.
- get_hypervisor_show_details(hypers[0]['id']))
- self.assertEqual(200, resp.status)
- if details['hypervisor_type'] != 'ironic':
- hypers_without_ironic.append(hyper)
- ironic_only = False
-
- if ironic_only:
- raise self.skipException(
- "Ironic does not support hypervisor uptime")
-
- resp, uptime = self.client.get_hypervisor_uptime(
- hypers_without_ironic[0]['id'])
- self.assertEqual(200, resp.status)
- self.assertTrue(len(uptime) > 0)
-
- @test.attr(type='gate')
- def test_search_hypervisor(self):
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
- resp, hypers = self.client.search_hypervisor(
- hypers[0]['hypervisor_hostname'])
- self.assertEqual(200, resp.status)
- self.assertTrue(len(hypers) > 0)
diff --git a/tempest/api/compute/v3/admin/test_hypervisor_negative.py b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
deleted file mode 100644
index df23b46..0000000
--- a/tempest/api/compute/v3/admin/test_hypervisor_negative.py
+++ /dev/null
@@ -1,136 +0,0 @@
-# Copyright 2013 Huawei Technologies Co.,LTD.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class HypervisorAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Hypervisors API that require admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(HypervisorAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.hypervisor_admin_client
- cls.non_adm_client = cls.hypervisor_client
-
- def _list_hypervisors(self):
- # List of hypervisors
- resp, hypers = self.client.get_hypervisor_list()
- self.assertEqual(200, resp.status)
- return hypers
-
- @test.attr(type=['negative', 'gate'])
- def test_show_nonexistent_hypervisor(self):
- nonexistent_hypervisor_id = str(uuid.uuid4())
-
- self.assertRaises(
- exceptions.NotFound,
- self.client.get_hypervisor_show_details,
- nonexistent_hypervisor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_show_hypervisor_with_non_admin_user(self):
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_hypervisor_show_details,
- hypers[0]['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_show_servers_with_non_admin_user(self):
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_hypervisor_servers,
- hypers[0]['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_show_servers_with_nonexistent_hypervisor(self):
- nonexistent_hypervisor_id = str(uuid.uuid4())
-
- self.assertRaises(
- exceptions.NotFound,
- self.client.get_hypervisor_servers,
- nonexistent_hypervisor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_hypervisor_stats_with_non_admin_user(self):
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_hypervisor_stats)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_nonexistent_hypervisor_uptime(self):
- nonexistent_hypervisor_id = str(uuid.uuid4())
-
- self.assertRaises(
- exceptions.NotFound,
- self.client.get_hypervisor_uptime,
- nonexistent_hypervisor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_hypervisor_uptime_with_non_admin_user(self):
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_hypervisor_uptime,
- hypers[0]['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_get_hypervisor_list_with_non_admin_user(self):
- # List of hypervisor and available services with non admin user
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_hypervisor_list)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_hypervisor_list_details_with_non_admin_user(self):
- # List of hypervisor details and available services with non admin user
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_hypervisor_list_details)
-
- @test.attr(type=['negative', 'gate'])
- def test_search_nonexistent_hypervisor(self):
- nonexistent_hypervisor_name = data_utils.rand_name('test_hypervisor')
-
- resp, hypers = self.client.search_hypervisor(
- nonexistent_hypervisor_name)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(hypers))
-
- @test.attr(type=['negative', 'gate'])
- def test_search_hypervisor_with_non_admin_user(self):
- hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
-
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.search_hypervisor,
- hypers[0]['hypervisor_hostname'])
diff --git a/tempest/api/compute/v3/admin/test_migrations.py b/tempest/api/compute/v3/admin/test_migrations.py
deleted file mode 100644
index e8bd473..0000000
--- a/tempest/api/compute/v3/admin/test_migrations.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import testtools
-
-from tempest.api.compute import base
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class MigrationsAdminV3Test(base.BaseV3ComputeAdminTest):
-
- @test.attr(type='gate')
- def test_list_migrations(self):
- # Admin can get the migrations list
- resp, _ = self.migrations_admin_client.list_migrations()
- self.assertEqual(200, resp.status)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.resize,
- 'Resize not available.')
- @test.attr(type='gate')
- def test_list_migrations_in_flavor_resize_situation(self):
- # Admin can get the migrations list which contains the resized server
- resp, server = self.create_test_server(wait_until="ACTIVE")
- server_id = server['id']
-
- resp, _ = self.servers_client.resize(server_id, self.flavor_ref_alt)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(server_id, 'VERIFY_RESIZE')
- self.servers_client.confirm_resize(server_id)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
- resp, body = self.migrations_admin_client.list_migrations()
- self.assertEqual(200, resp.status)
-
- instance_uuids = [x['instance_uuid'] for x in body]
- self.assertIn(server_id, instance_uuids)
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
deleted file mode 100644
index 3dad45c..0000000
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ /dev/null
@@ -1,150 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class QuotasAdminV3Test(base.BaseV3ComputeAdminTest):
- force_tenant_isolation = True
-
- @classmethod
- def resource_setup(cls):
- super(QuotasAdminV3Test, cls).resource_setup()
- cls.client = cls.quotas_client
- cls.adm_client = cls.quotas_admin_client
-
- # NOTE(afazekas): these test cases should always create and use a new
- # tenant most of them should be skipped if we can't do that
- cls.demo_tenant_id = cls.client.tenant_id
-
- cls.default_quota_set = set(('metadata_items',
- 'ram', 'floating_ips',
- 'fixed_ips', 'key_pairs',
- 'instances', 'security_group_rules',
- 'cores', 'security_groups'))
-
- @test.attr(type='smoke')
- def test_get_default_quotas(self):
- # Admin can get the default resource quota set for a tenant
- expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.adm_client.get_default_quota_set(
- self.demo_tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
- self.assertEqual(quota_set['id'], self.demo_tenant_id)
-
- @test.attr(type='smoke')
- def test_get_quota_set_detail(self):
- # Admin can get the detail of resource quota set for a tenant
- expected_quota_set = self.default_quota_set | set(['id'])
- expected_detail = ['reserved', 'limit', 'in_use']
- resp, quota_set = self.adm_client.get_quota_set_detail(
- self.demo_tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set), sorted(quota_set.keys()))
- self.assertEqual(quota_set['id'], self.demo_tenant_id)
- for quota in quota_set:
- if quota == 'id':
- continue
- self.assertEqual(sorted(expected_detail),
- sorted(quota_set[quota].keys()))
-
- @test.attr(type='gate')
- def test_update_all_quota_resources_for_tenant(self):
- # Admin can update all the resource quota limits for a tenant
- resp, default_quota_set = self.adm_client.get_default_quota_set(
- self.demo_tenant_id)
- new_quota_set = {'metadata_items': 256,
- 'ram': 10240, 'floating_ips': 20, 'fixed_ips': 10,
- 'key_pairs': 200,
- 'instances': 20, 'security_group_rules': 20,
- 'cores': 2, 'security_groups': 20}
- # Update limits for all quota resources
- resp, quota_set = self.adm_client.update_quota_set(
- self.demo_tenant_id,
- force=True,
- **new_quota_set)
-
- default_quota_set.pop('id')
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id, **default_quota_set)
- self.assertEqual(200, resp.status)
- quota_set.pop('id')
- self.assertEqual(new_quota_set, quota_set)
-
- # TODO(afazekas): merge these test cases
- @test.attr(type='gate')
- def test_get_updated_quotas(self):
- # Verify that GET shows the updated quota set of tenant
- tenant_name = data_utils.rand_name('cpu_quota_tenant_')
- tenant_desc = tenant_name + '-desc'
- identity_client = self.os_adm.identity_client
- _, tenant = identity_client.create_tenant(name=tenant_name,
- description=tenant_desc)
- tenant_id = tenant['id']
- self.addCleanup(identity_client.delete_tenant, tenant_id)
-
- self.adm_client.update_quota_set(tenant_id, ram='5120')
- resp, quota_set = self.adm_client.get_quota_set(tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(5120, quota_set['ram'])
-
- # Verify that GET shows the updated quota set of user
- user_name = data_utils.rand_name('cpu_quota_user_')
- password = data_utils.rand_name('password-')
- email = user_name + '@testmail.tm'
- _, user = identity_client.create_user(name=user_name,
- password=password,
- tenant_id=tenant_id,
- email=email)
- user_id = user['id']
- self.addCleanup(identity_client.delete_user, user_id)
-
- self.adm_client.update_quota_set(tenant_id,
- user_id=user_id,
- ram='2048')
- resp, quota_set = self.adm_client.get_quota_set(tenant_id,
- user_id=user_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(2048, quota_set['ram'])
-
- @test.attr(type='gate')
- def test_delete_quota(self):
- # Admin can delete the resource quota set for a tenant
- tenant_name = data_utils.rand_name('cpu_quota_tenant_')
- tenant_desc = tenant_name + '-desc'
- identity_client = self.os_adm.identity_client
- _, tenant = identity_client.create_tenant(name=tenant_name,
- description=tenant_desc)
- tenant_id = tenant['id']
- self.addCleanup(identity_client.delete_tenant, tenant_id)
- resp, quota_set_default = self.adm_client.get_quota_set(tenant_id)
- self.assertEqual(200, resp.status)
- ram_default = quota_set_default['ram']
-
- self.adm_client.update_quota_set(tenant_id, ram='5120')
- self.assertEqual(200, resp.status)
- resp, _ = self.adm_client.delete_quota_set(tenant_id)
- self.assertEqual(204, resp.status)
-
- resp, quota_set_new = self.adm_client.get_quota_set(tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(ram_default, quota_set_new['ram'])
diff --git a/tempest/api/compute/v3/admin/test_quotas_negative.py b/tempest/api/compute/v3/admin/test_quotas_negative.py
deleted file mode 100644
index 86abcab..0000000
--- a/tempest/api/compute/v3/admin/test_quotas_negative.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# Copyright 2014 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-
-
-class QuotasAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
- force_tenant_isolation = True
-
- @classmethod
- def resource_setup(cls):
- super(QuotasAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.quotas_client
- cls.adm_client = cls.quotas_admin_client
-
- # NOTE(afazekas): these test cases should always create and use a new
- # tenant most of them should be skipped if we can't do that
- cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
-
- # TODO(afazekas): Add dedicated tenant to the skiped quota tests
- # it can be moved into the setUpClass as well
- @test.attr(type=['negative', 'gate'])
- def test_create_server_when_cpu_quota_is_full(self):
- # Disallow server creation when tenant's vcpu quota is full
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
- default_vcpu_quota = quota_set['cores']
- vcpu_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- cores=vcpu_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- cores=default_vcpu_quota)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
- self.create_test_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_server_when_memory_quota_is_full(self):
- # Disallow server creation when tenant's memory quota is full
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
- default_mem_quota = quota_set['ram']
- mem_quota = 0 # Set the quota to zero to conserve resources
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- ram=mem_quota)
-
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- ram=default_mem_quota)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
- self.create_test_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_quota_normal_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.client.update_quota_set,
- self.demo_tenant_id,
- ram=0)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_server_when_instances_quota_is_full(self):
- # Once instances quota limit is reached, disallow server creation
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
- default_instances_quota = quota_set['instances']
- instances_quota = 0 # Set quota to zero to disallow server creation
-
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- instances=instances_quota)
- self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
- instances=default_instances_quota)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
- self.create_test_server)
diff --git a/tempest/api/compute/v3/admin/test_servers.py b/tempest/api/compute/v3/admin/test_servers.py
deleted file mode 100644
index 36ea7ba..0000000
--- a/tempest/api/compute/v3/admin/test_servers.py
+++ /dev/null
@@ -1,174 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-class ServersAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Servers API using admin privileges
- """
-
- _host_key = 'os-extended-server-attributes:host'
-
- @classmethod
- def resource_setup(cls):
- super(ServersAdminV3Test, cls).resource_setup()
- cls.client = cls.servers_admin_client
- cls.non_admin_client = cls.servers_client
- cls.flavors_client = cls.flavors_admin_client
-
- cls.s1_name = data_utils.rand_name('server')
- resp, server = cls.create_test_server(name=cls.s1_name,
- wait_until='ACTIVE')
- cls.s1_id = server['id']
-
- cls.s2_name = data_utils.rand_name('server')
- resp, server = cls.create_test_server(name=cls.s2_name,
- wait_until='ACTIVE')
- cls.s2_id = server['id']
-
- @test.attr(type='gate')
- def test_list_servers_by_admin(self):
- # Listing servers by admin user returns empty list by default
- resp, body = self.client.list_servers_with_detail()
- servers = body['servers']
- self.assertEqual('200', resp['status'])
- self.assertEqual([], servers)
-
- @test.attr(type='gate')
- def test_list_servers_by_admin_with_all_tenants(self):
- # Listing servers by admin user with all tenants parameter
- # Here should be listed all servers
- params = {'all_tenants': ''}
- resp, body = self.client.list_servers_with_detail(params)
- servers = body['servers']
- servers_name = map(lambda x: x['name'], servers)
-
- self.assertIn(self.s1_name, servers_name)
- self.assertIn(self.s2_name, servers_name)
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_existent_host(self):
- # Filter the list of servers by existent host
- name = data_utils.rand_name('server')
- flavor = self.flavor_ref
- image_id = self.image_ref
- resp, test_server = self.client.create_server(
- name, image_id, flavor)
- self.assertEqual('202', resp['status'])
- self.addCleanup(self.client.delete_server, test_server['id'])
- self.client.wait_for_server_status(test_server['id'], 'ACTIVE')
- resp, server = self.client.get_server(test_server['id'])
- self.assertEqual(server['status'], 'ACTIVE')
- hostname = server[self._host_key]
- params = {'host': hostname}
- resp, body = self.client.list_servers(params)
- self.assertEqual('200', resp['status'])
- servers = body['servers']
- nonexistent_params = {'host': 'nonexistent_host'}
- resp, nonexistent_body = self.client.list_servers(
- nonexistent_params)
- self.assertEqual('200', resp['status'])
- nonexistent_servers = nonexistent_body['servers']
- self.assertIn(test_server['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(test_server['id'],
- map(lambda x: x['id'], nonexistent_servers))
-
- @test.attr(type='gate')
- def test_reset_state_server(self):
- # Reset server's state to 'error'
- resp, server = self.client.reset_state(self.s1_id)
- self.assertEqual(202, resp.status)
-
- # Verify server's state
- resp, server = self.client.get_server(self.s1_id)
- self.assertEqual(server['status'], 'ERROR')
-
- # Reset server's state to 'active'
- resp, server = self.client.reset_state(self.s1_id, state='active')
- self.assertEqual(202, resp.status)
-
- # Verify server's state
- resp, server = self.client.get_server(self.s1_id)
- self.assertEqual(server['status'], 'ACTIVE')
-
- @test.attr(type='gate')
- @test.skip_because(bug="1240043")
- def test_get_server_diagnostics_by_admin(self):
- # Retrieve server diagnostics by admin user
- resp, diagnostic = self.client.get_server_diagnostics(self.s1_id)
- self.assertEqual(200, resp.status)
- basic_attrs = ['rx_packets', 'rx_errors', 'rx_drop',
- 'tx_packets', 'tx_errors', 'tx_drop',
- 'read_req', 'write_req', 'cpu', 'memory']
- for key in basic_attrs:
- self.assertIn(key, str(diagnostic.keys()))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_error_status(self):
- # Filter the list of servers by server error status
- params = {'status': 'error'}
- resp, server = self.client.reset_state(self.s1_id, state='error')
- resp, body = self.non_admin_client.list_servers(params)
- # Reset server's state to 'active'
- resp, server = self.client.reset_state(self.s1_id, state='active')
- # Verify server's state
- resp, server = self.client.get_server(self.s1_id)
- self.assertEqual(server['status'], 'ACTIVE')
- servers = body['servers']
- # Verify error server in list result
- self.assertIn(self.s1_id, map(lambda x: x['id'], servers))
- self.assertNotIn(self.s2_id, map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_rebuild_server_in_error_state(self):
- # The server in error state should be rebuilt using the provided
- # image and changed to ACTIVE state
-
- # resetting vm state require admin privilege
- resp, server = self.client.reset_state(self.s1_id, state='error')
- self.assertEqual(202, resp.status)
- resp, rebuilt_server = self.non_admin_client.rebuild(
- self.s1_id, self.image_ref_alt)
- self.addCleanup(self.non_admin_client.wait_for_server_status,
- self.s1_id, 'ACTIVE')
- self.addCleanup(self.non_admin_client.rebuild, self.s1_id,
- self.image_ref)
-
- # Verify the properties in the initial response are correct
- self.assertEqual(self.s1_id, rebuilt_server['id'])
- rebuilt_image_id = rebuilt_server['image']['id']
- self.assertEqual(self.image_ref_alt, rebuilt_image_id)
- self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
- self.non_admin_client.wait_for_server_status(rebuilt_server['id'],
- 'ACTIVE',
- raise_on_error=False)
- # Verify the server properties after rebuilding
- resp, server = self.non_admin_client.get_server(rebuilt_server['id'])
- rebuilt_image_id = server['image']['id']
- self.assertEqual(self.image_ref_alt, rebuilt_image_id)
-
- @test.attr(type='gate')
- def test_reset_network_inject_network_info(self):
- resp, server = self.create_test_server(wait_until='ACTIVE')
- # Reset Network of a Server
- resp, server_body = self.client.reset_network(server['id'])
- self.assertEqual(202, resp.status)
- # Inject the Network Info into Server
- resp, server = self.client.inject_network_info(server['id'])
- self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/v3/admin/test_servers_negative.py b/tempest/api/compute/v3/admin/test_servers_negative.py
deleted file mode 100644
index f561ed3..0000000
--- a/tempest/api/compute/v3/admin/test_servers_negative.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# Copyright 2013 Huawei Technologies Co.,LTD.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import uuid
-
-import testtools
-
-from tempest.api.compute import base
-from tempest.common import tempest_fixtures as fixtures
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class ServersAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Servers API using admin privileges
- """
-
- @classmethod
- def resource_setup(cls):
- super(ServersAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.servers_admin_client
- cls.non_adm_client = cls.servers_client
- cls.flavors_client = cls.flavors_admin_client
- cls.tenant_id = cls.client.tenant_id
-
- cls.s1_name = data_utils.rand_name('server')
- resp, server = cls.create_test_server(name=cls.s1_name,
- wait_until='ACTIVE')
- cls.s1_id = server['id']
-
- def _get_unused_flavor_id(self):
- flavor_id = data_utils.rand_int_id(start=1000)
- while True:
- try:
- resp, body = self.flavors_client.get_flavor_details(flavor_id)
- except exceptions.NotFound:
- break
- flavor_id = data_utils.rand_int_id(start=1000)
- return flavor_id
-
- @test.attr(type=['negative', 'gate'])
- def test_resize_server_using_overlimit_ram(self):
- # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
- self.useFixture(fixtures.LockFixture('compute_quotas'))
- flavor_name = data_utils.rand_name("flavor-")
- flavor_id = self._get_unused_flavor_id()
- resp, quota_set = self.quotas_client.get_default_quota_set(
- self.tenant_id)
- ram = int(quota_set['ram']) + 1
- vcpus = 8
- disk = 10
- resp, flavor_ref = self.flavors_client.create_flavor(flavor_name,
- ram, vcpus, disk,
- flavor_id)
- self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
- self.client.resize,
- self.servers[0]['id'],
- flavor_ref['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_resize_server_using_overlimit_vcpus(self):
- # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
- self.useFixture(fixtures.LockFixture('compute_quotas'))
- flavor_name = data_utils.rand_name("flavor-")
- flavor_id = self._get_unused_flavor_id()
- ram = 512
- resp, quota_set = self.quotas_client.get_default_quota_set(
- self.tenant_id)
- vcpus = int(quota_set['cores']) + 1
- disk = 10
- resp, flavor_ref = self.flavors_client.create_flavor(flavor_name,
- ram, vcpus, disk,
- flavor_id)
- self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
- self.client.resize,
- self.servers[0]['id'],
- flavor_ref['id'])
-
- @test.attr(type=['negative', 'gate'])
- def test_reset_state_server_invalid_state(self):
- self.assertRaises(exceptions.BadRequest,
- self.client.reset_state, self.s1_id,
- state='invalid')
-
- @test.attr(type=['negative', 'gate'])
- def test_reset_state_server_invalid_type(self):
- self.assertRaises(exceptions.BadRequest,
- self.client.reset_state, self.s1_id,
- state=1)
-
- @test.attr(type=['negative', 'gate'])
- def test_reset_state_server_nonexistent_server(self):
- self.assertRaises(exceptions.NotFound,
- self.client.reset_state, '999')
-
- @test.attr(type=['negative', 'gate'])
- def test_get_server_diagnostics_by_non_admin(self):
- # Non-admin user can not view server diagnostics according to policy
- self.assertRaises(exceptions.Unauthorized,
- self.non_adm_client.get_server_diagnostics,
- self.s1_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_migrate_non_existent_server(self):
- # migrate a non existent server
- self.assertRaises(exceptions.NotFound,
- self.client.migrate_server,
- str(uuid.uuid4()))
-
- @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
- 'Suspend is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_migrate_server_invalid_state(self):
- # create server.
- resp, server = self.create_test_server(wait_until='ACTIVE')
- self.assertEqual(202, resp.status)
- server_id = server['id']
- # suspend the server.
- resp, _ = self.client.suspend_server(server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(server_id, 'SUSPENDED')
- # migrate an suspended server should fail
- self.assertRaises(exceptions.Conflict,
- self.client.migrate_server,
- server_id)
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
deleted file mode 100644
index f1c3b9a..0000000
--- a/tempest/api/compute/v3/admin/test_services.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# Copyright 2013 NEC Corporation
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class ServicesAdminV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Services API. List and Enable/Disable require admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(ServicesAdminV3Test, cls).resource_setup()
- cls.client = cls.services_admin_client
-
- @test.attr(type='gate')
- def test_list_services(self):
- resp, services = self.client.list_services()
- self.assertEqual(200, resp.status)
- self.assertNotEqual(0, len(services))
-
- @test.attr(type='gate')
- def test_get_service_by_service_binary_name(self):
- binary_name = 'nova-compute'
- params = {'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertNotEqual(0, len(services))
- for service in services:
- self.assertEqual(binary_name, service['binary'])
-
- @test.attr(type='gate')
- def test_get_service_by_host_name(self):
- resp, services = self.client.list_services()
- self.assertEqual(200, resp.status)
- host_name = services[0]['host']
- services_on_host = [service for service in services if
- service['host'] == host_name]
- params = {'host': host_name}
-
- resp, services = self.client.list_services(params)
-
- # we could have a periodic job checkin between the 2 service
- # lookups, so only compare binary lists.
- s1 = map(lambda x: x['binary'], services)
- s2 = map(lambda x: x['binary'], services_on_host)
-
- # sort the lists before comparing, to take out dependency
- # on order.
- self.assertEqual(sorted(s1), sorted(s2))
-
- @test.attr(type='gate')
- def test_get_service_by_service_and_host_name(self):
- resp, services = self.client.list_services()
- host_name = services[0]['host']
- binary_name = services[0]['binary']
- params = {'host': host_name, 'binary': binary_name}
-
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(1, len(services))
- self.assertEqual(host_name, services[0]['host'])
- self.assertEqual(binary_name, services[0]['binary'])
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
deleted file mode 100644
index 1f9f2b1..0000000
--- a/tempest/api/compute/v3/admin/test_services_negative.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright 2013 NEC Corporation
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-
-
-class ServicesAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
-
- """
- Tests Services API. List and Enable/Disable require admin privileges.
- """
-
- @classmethod
- def resource_setup(cls):
- super(ServicesAdminNegativeV3Test, cls).resource_setup()
- cls.client = cls.services_admin_client
- cls.non_admin_client = cls.services_client
-
- @test.attr(type=['negative', 'gate'])
- def test_list_services_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.list_services)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_params(self):
- # return all services if send the request with invalid parameter
- resp, services = self.client.list_services()
- params = {'xxx': 'nova-compute'}
- resp, services_xxx = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(len(services), len(services_xxx))
-
- @test.attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_service_and_valid_host(self):
- resp, services = self.client.list_services()
- host_name = services[0]['host']
- params = {'host': host_name, 'binary': 'xxx'}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
- @test.attr(type=['negative', 'gate'])
- def test_get_service_with_valid_service_and_invalid_host(self):
- resp, services = self.client.list_services()
- binary_name = services[0]['binary']
- params = {'host': 'xxx', 'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
diff --git a/tempest/api/compute/v3/flavors/__init__.py b/tempest/api/compute/v3/flavors/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api/compute/v3/flavors/__init__.py
+++ /dev/null
diff --git a/tempest/api/compute/v3/flavors/test_flavors_negative.py b/tempest/api/compute/v3/flavors/test_flavors_negative.py
deleted file mode 100644
index 2dd7b71..0000000
--- a/tempest/api/compute/v3/flavors/test_flavors_negative.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.api_schema.request.compute.v3 import flavors
-from tempest import test
-
-
-load_tests = test.NegativeAutoTest.load_tests
-
-
-@test.SimpleNegativeAutoTest
-class FlavorsListNegativeV3Test(base.BaseV3ComputeTest,
- test.NegativeAutoTest):
- _service = 'computev3'
- _schema = flavors.flavor_list
-
-
-@test.SimpleNegativeAutoTest
-class FlavorDetailsNegativeV3Test(base.BaseV3ComputeTest,
- test.NegativeAutoTest):
- _service = 'computev3'
- _schema = flavors.flavors_details
-
- @classmethod
- def resource_setup(cls):
- super(FlavorDetailsNegativeV3Test, cls).resource_setup()
- cls.set_resource("flavor", cls.flavor_ref)
diff --git a/tempest/api/compute/v3/images/__init__.py b/tempest/api/compute/v3/images/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api/compute/v3/images/__init__.py
+++ /dev/null
diff --git a/tempest/api/compute/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
deleted file mode 100644
index a234a22..0000000
--- a/tempest/api/compute/v3/images/test_images.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class ImagesV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(ImagesV3Test, cls).resource_setup()
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
- cls.client = cls.images_client
-
- @test.attr(type='gate')
- def test_create_image_from_stopped_server(self):
- resp, server = self.create_test_server(wait_until='ACTIVE')
- self.servers_client.stop(server['id'])
- self.servers_client.wait_for_server_status(server['id'],
- 'SHUTOFF')
- self.addCleanup(self.servers_client.delete_server, server['id'])
- snapshot_name = data_utils.rand_name('test-snap-')
- resp, image = self.create_image_from_server(server['id'],
- name=snapshot_name,
- wait_until='active')
- self.addCleanup(self.client.delete_image, image['id'])
- self.assertEqual(snapshot_name, image['name'])
-
- @test.attr(type='gate')
- def test_delete_queued_image(self):
- snapshot_name = data_utils.rand_name('test-snap-')
- resp, server = self.create_test_server(wait_until='ACTIVE')
- self.addCleanup(self.servers_client.delete_server, server['id'])
- resp, image = self.create_image_from_server(server['id'],
- name=snapshot_name,
- wait_until='queued')
- resp, body = self.client.delete_image(image['id'])
- self.assertEqual('200', resp['status'])
diff --git a/tempest/api/compute/v3/images/test_images_negative.py b/tempest/api/compute/v3/images/test_images_negative.py
deleted file mode 100644
index 83e9436..0000000
--- a/tempest/api/compute/v3/images/test_images_negative.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class ImagesNegativeV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(ImagesNegativeV3Test, cls).resource_setup()
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
- cls.client = cls.images_client
-
- def __create_image__(self, server_id, name, meta=None):
- resp, body = self.servers_client.create_image(server_id, name, meta)
- image_id = data_utils.parse_image_id(resp['location'])
- self.addCleanup(self.client.delete_image, image_id)
- self.client.wait_for_image_status(image_id, 'active')
- return resp, body
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_from_deleted_server(self):
- # An image should not be created if the server instance is removed
- resp, server = self.create_test_server(wait_until='ACTIVE')
-
- # Delete server before trying to create server
- self.servers_client.delete_server(server['id'])
- self.servers_client.wait_for_server_termination(server['id'])
- # Create a new image after server is deleted
- name = data_utils.rand_name('image')
- meta = {'image_type': 'test'}
- self.assertRaises(exceptions.NotFound,
- self.__create_image__,
- server['id'], name, meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_from_nonexistent_server(self):
- # An image should not be created with invalid server id
- # Create a new image with invalid server id
- nonexistent_server_id = data_utils.rand_uuid()
- name = data_utils.rand_name('image')
- meta = {'image_type': 'test'}
- self.assertRaises(exceptions.NotFound, self.__create_image__,
- nonexistent_server_id, name, meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_uuid_35_characters_or_less(self):
- # Return an error if Image ID passed is 35 characters or less
- snapshot_name = data_utils.rand_name('test-snap-')
- test_uuid = ('a' * 35)
- self.assertRaises(exceptions.NotFound,
- self.servers_client.create_image,
- test_uuid, snapshot_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_uuid_37_characters_or_more(self):
- # Return an error if Image ID passed is 37 characters or more
- snapshot_name = data_utils.rand_name('test-snap-')
- test_uuid = ('a' * 37)
- self.assertRaises(exceptions.NotFound,
- self.servers_client.create_image,
- test_uuid, snapshot_name)
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
deleted file mode 100644
index 87e730c..0000000
--- a/tempest/api/compute/v3/images/test_images_oneserver.py
+++ /dev/null
@@ -1,105 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest.openstack.common import log as logging
-from tempest import test
-
-CONF = config.CONF
-LOG = logging.getLogger(__name__)
-
-
-class ImagesOneServerV3Test(base.BaseV3ComputeTest):
-
- def setUp(self):
- # NOTE(afazekas): Normally we use the same server with all test cases,
- # but if it has an issue, we build a new one
- super(ImagesOneServerV3Test, self).setUp()
- # Check if the server is in a clean state after test
- try:
- self.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
- except Exception:
- LOG.exception('server %s timed out to become ACTIVE. rebuilding'
- % self.server_id)
- # Rebuild server if cannot reach the ACTIVE state
- # Usually it means the server had a serious accident
- self.__class__.server_id = self.rebuild_server(self.server_id)
-
- def tearDown(self):
- """Terminate test instances created after a test is executed."""
- self.server_check_teardown()
- super(ImagesOneServerV3Test, self).tearDown()
-
- @classmethod
- def resource_setup(cls):
- super(ImagesOneServerV3Test, cls).resource_setup()
- cls.client = cls.images_client
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
-
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
-
- def _get_default_flavor_disk_size(self, flavor_id):
- resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
- return flavor['disk']
-
- @test.attr(type='smoke')
- def test_create_delete_image(self):
-
- # Create a new image
- name = data_utils.rand_name('image')
- meta = {'image_type': 'test'}
- resp, body = self.servers_client.create_image(self.server_id,
- name, meta)
- self.assertEqual(202, resp.status)
- image_id = data_utils.parse_image_id(resp['location'])
- self.client.wait_for_image_status(image_id, 'active')
-
- # Verify the image was created correctly
- resp, image = self.client.get_image_meta(image_id)
- self.assertEqual(name, image['name'])
- self.assertEqual('test', image['properties']['image_type'])
-
- resp, original_image = self.client.get_image_meta(self.image_ref)
-
- # Verify minRAM is the same as the original image
- self.assertEqual(image['min_ram'], original_image['min_ram'])
-
- # Verify minDisk is the same as the original image or the flavor size
- flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
- self.assertIn(str(image['min_disk']),
- (str(original_image['min_disk']), str(flavor_disk_size)))
-
- # Verify the image was deleted correctly
- resp, body = self.client.delete_image(image_id)
- self.assertEqual('200', resp['status'])
- self.client.wait_for_resource_deletion(image_id)
-
- @test.attr(type=['gate'])
- def test_create_image_specify_multibyte_character_image_name(self):
- # prefix character is:
- # http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
- utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
- resp, body = self.servers_client.create_image(self.server_id,
- utf8_name)
- image_id = data_utils.parse_image_id(resp['location'])
- self.addCleanup(self.client.delete_image, image_id)
- self.assertEqual('202', resp['status'])
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
deleted file mode 100644
index 5892cd7..0000000
--- a/tempest/api/compute/v3/images/test_images_oneserver_negative.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-from tempest import test
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class ImagesOneServerNegativeV3Test(base.BaseV3ComputeTest):
-
- def tearDown(self):
- """Terminate test instances created after a test is executed."""
- for image_id in self.image_ids:
- self.client.delete_image(image_id)
- self.image_ids.remove(image_id)
- self.server_check_teardown()
- super(ImagesOneServerNegativeV3Test, self).tearDown()
-
- def setUp(self):
- # NOTE(afazekas): Normally we use the same server with all test cases,
- # but if it has an issue, we build a new one
- super(ImagesOneServerNegativeV3Test, self).setUp()
- # Check if the server is in a clean state after test
- try:
- self.servers_client.wait_for_server_status(self.server_id,
- 'ACTIVE')
- except Exception:
- LOG.exception('server %s timed out to become ACTIVE. rebuilding'
- % self.server_id)
- # Rebuild server if cannot reach the ACTIVE state
- # Usually it means the server had a serious accident
- self._reset_server()
-
- def _reset_server(self):
- self.__class__.server_id = self.rebuild_server(self.server_id)
-
- @classmethod
- def resource_setup(cls):
- super(ImagesOneServerNegativeV3Test, cls).resource_setup()
- cls.client = cls.images_client
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
-
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
-
- cls.image_ids = []
-
- @test.skip_because(bug="1006725")
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_multibyte_character_image_name(self):
- # invalid multibyte sequence from:
- # http://stackoverflow.com/questions/1301402/
- # example-invalid-utf8-string
- invalid_name = data_utils.rand_name(u'\xc3\x28')
- self.assertRaises(exceptions.BadRequest,
- self.servers_client.create_image,
- self.server_id,
- invalid_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_invalid_metadata(self):
- # Return an error when creating image with invalid metadata
- snapshot_name = data_utils.rand_name('test-snap-')
- meta = {'': ''}
- self.assertRaises(exceptions.BadRequest,
- self.servers_client.create_image,
- self.server_id, snapshot_name, meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_metadata_over_limits(self):
- # Return an error when creating image with meta data over 256 chars
- snapshot_name = data_utils.rand_name('test-snap-')
- meta = {'a' * 260: 'b' * 260}
- self.assertRaises(exceptions.BadRequest,
- self.servers_client.create_image,
- self.server_id, snapshot_name, meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_second_image_when_first_image_is_being_saved(self):
- # Disallow creating another image when first image is being saved
-
- # Create first snapshot
- snapshot_name = data_utils.rand_name('test-snap-')
- resp, body = self.servers_client.create_image(self.server_id,
- snapshot_name)
- self.assertEqual(202, resp.status)
- image_id = data_utils.parse_image_id(resp['location'])
- self.image_ids.append(image_id)
- self.addCleanup(self._reset_server)
-
- # Create second snapshot
- alt_snapshot_name = data_utils.rand_name('test-snap-')
- self.assertRaises(exceptions.Conflict,
- self.servers_client.create_image,
- self.server_id, alt_snapshot_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_name_over_256_chars(self):
- # Return an error if snapshot name over 256 characters is passed
-
- snapshot_name = data_utils.rand_name('a' * 260)
- self.assertRaises(exceptions.BadRequest,
- self.servers_client.create_image,
- self.server_id, snapshot_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_image_that_is_not_yet_active(self):
- # Return an error while trying to delete an image what is creating
-
- snapshot_name = data_utils.rand_name('test-snap-')
- resp, body = self.servers_client.create_image(self.server_id,
- snapshot_name)
- self.assertEqual(202, resp.status)
- image_id = data_utils.parse_image_id(resp['location'])
- self.image_ids.append(image_id)
- self.addCleanup(self._reset_server)
-
- # Do not wait, attempt to delete the image, ensure it's successful
- resp, body = self.client.delete_image(image_id)
- self.assertEqual('200', resp['status'])
- self.image_ids.remove(image_id)
-
- self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
diff --git a/tempest/api/compute/v3/keypairs/__init__.py b/tempest/api/compute/v3/keypairs/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api/compute/v3/keypairs/__init__.py
+++ /dev/null
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
deleted file mode 100644
index 1f7206a..0000000
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class KeyPairsNegativeV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(KeyPairsNegativeV3Test, cls).resource_setup()
- cls.client = cls.keypairs_client
-
- def _create_keypair(self, keypair_name, pub_key=None):
- self.client.create_keypair(keypair_name, pub_key)
- self.addCleanup(self.client.delete_keypair, keypair_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_keypair_create_with_invalid_pub_key(self):
- # Keypair should not be created with a non RSA public key
- k_name = data_utils.rand_name('keypair-')
- pub_key = "ssh-rsa JUNK nova@ubuntu"
- self.assertRaises(exceptions.BadRequest,
- self._create_keypair, k_name, pub_key)
-
- @test.attr(type=['negative', 'gate'])
- def test_keypair_delete_nonexistent_key(self):
- # Non-existent key deletion should throw a proper error
- k_name = data_utils.rand_name("keypair-non-existent-")
- self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
- k_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_keypair_with_empty_public_key(self):
- # Keypair should not be created with an empty public key
- k_name = data_utils.rand_name("keypair-")
- pub_key = ' '
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
- k_name, pub_key)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_keypair_when_public_key_bits_exceeds_maximum(self):
- # Keypair should not be created when public key bits are too long
- k_name = data_utils.rand_name("keypair-")
- pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
- k_name, pub_key)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_keypair_with_duplicate_name(self):
- # Keypairs with duplicate names should not be created
- k_name = data_utils.rand_name('keypair-')
- resp, _ = self.client.create_keypair(k_name)
- self.addCleanup(self.client.delete_keypair, k_name)
- self.assertEqual(201, resp.status)
- # Now try the same keyname to create another key
- self.assertRaises(exceptions.Conflict, self._create_keypair,
- k_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_keypair_with_empty_name_string(self):
- # Keypairs with name being an empty string should not be created
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
- '')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_keypair_with_long_keynames(self):
- # Keypairs with name longer than 255 chars should not be created
- k_name = 'keypair-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
- k_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_keypair_invalid_name(self):
- # Keypairs with name being an invalid name should not be created
- k_name = 'key_/.\@:'
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
- k_name)
diff --git a/tempest/api/compute/v3/servers/__init__.py b/tempest/api/compute/v3/servers/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api/compute/v3/servers/__init__.py
+++ /dev/null
diff --git a/tempest/api/compute/v3/servers/test_attach_interfaces.py b/tempest/api/compute/v3/servers/test_attach_interfaces.py
deleted file mode 100644
index d4d4fca..0000000
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-import time
-
-CONF = config.CONF
-
-
-class AttachInterfacesV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- if not CONF.service_available.neutron:
- raise cls.skipException("Neutron is required")
- if not CONF.compute_feature_enabled.interface_attach:
- raise cls.skipException("Interface attachment is not available.")
- # This test class requires network and subnet
- cls.set_network_resources(network=True, subnet=True)
- super(AttachInterfacesV3Test, cls).resource_setup()
- cls.client = cls.interfaces_client
-
- def _check_interface(self, iface, port_id=None, network_id=None,
- fixed_ip=None):
- self.assertIn('port_state', iface)
- if port_id:
- self.assertEqual(iface['port_id'], port_id)
- if network_id:
- self.assertEqual(iface['net_id'], network_id)
- if fixed_ip:
- self.assertEqual(iface['fixed_ips'][0]['ip_address'], fixed_ip)
-
- def _create_server_get_interfaces(self):
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, ifs = self.client.list_interfaces(server['id'])
- self.assertEqual(200, resp.status)
- resp, body = self.client.wait_for_interface_status(
- server['id'], ifs[0]['port_id'], 'ACTIVE')
- ifs[0]['port_state'] = body['port_state']
- return server, ifs
-
- def _test_create_interface(self, server):
- resp, iface = self.client.create_interface(server['id'])
- self.assertEqual(200, resp.status)
- resp, iface = self.client.wait_for_interface_status(
- server['id'], iface['port_id'], 'ACTIVE')
- self._check_interface(iface)
- return iface
-
- def _test_create_interface_by_network_id(self, server, ifs):
- network_id = ifs[0]['net_id']
- resp, iface = self.client.create_interface(server['id'],
- network_id=network_id)
- self.assertEqual(200, resp.status)
- resp, iface = self.client.wait_for_interface_status(
- server['id'], iface['port_id'], 'ACTIVE')
- self._check_interface(iface, network_id=network_id)
- return iface
-
- def _test_show_interface(self, server, ifs):
- iface = ifs[0]
- resp, _iface = self.client.show_interface(server['id'],
- iface['port_id'])
- self.assertEqual(200, resp.status)
- self.assertEqual(iface, _iface)
-
- def _test_delete_interface(self, server, ifs):
- # NOTE(danms): delete not the first or last, but one in the middle
- iface = ifs[1]
- resp, _ = self.client.delete_interface(server['id'], iface['port_id'])
- self.assertEqual(202, resp.status)
- _ifs = self.client.list_interfaces(server['id'])[1]
- start = int(time.time())
-
- while len(ifs) == len(_ifs):
- time.sleep(self.build_interval)
- _ifs = self.client.list_interfaces(server['id'])[1]
- timed_out = int(time.time()) - start >= self.build_timeout
- if len(ifs) == len(_ifs) and timed_out:
- message = ('Failed to delete interface within '
- 'the required time: %s sec.' % self.build_timeout)
- raise exceptions.TimeoutException(message)
-
- self.assertNotIn(iface['port_id'], [i['port_id'] for i in _ifs])
- return _ifs
-
- def _compare_iface_list(self, list1, list2):
- # NOTE(danms): port_state will likely have changed, so just
- # confirm the port_ids are the same at least
- list1 = [x['port_id'] for x in list1]
- list2 = [x['port_id'] for x in list2]
-
- self.assertEqual(sorted(list1), sorted(list2))
-
- @test.attr(type='smoke')
- def test_create_list_show_delete_interfaces(self):
- server, ifs = self._create_server_get_interfaces()
- interface_count = len(ifs)
- self.assertTrue(interface_count > 0)
- self._check_interface(ifs[0])
-
- iface = self._test_create_interface(server)
- ifs.append(iface)
-
- iface = self._test_create_interface_by_network_id(server, ifs)
- ifs.append(iface)
-
- resp, _ifs = self.client.list_interfaces(server['id'])
- self._compare_iface_list(ifs, _ifs)
-
- self._test_show_interface(server, ifs)
-
- _ifs = self._test_delete_interface(server, ifs)
- self.assertEqual(len(ifs) - 1, len(_ifs))
-
- @test.attr(type='smoke')
- def test_add_remove_fixed_ip(self):
- # Add and Remove the fixed IP to server.
- server, ifs = self._create_server_get_interfaces()
- interface_count = len(ifs)
- self.assertGreater(interface_count, 0)
- self._check_interface(ifs[0])
- network_id = ifs[0]['net_id']
- resp, body = self.client.add_fixed_ip(server['id'],
- network_id)
- self.assertEqual(202, resp.status)
- server_resp, server_detail = self.servers_client.get_server(
- server['id'])
- # Get the Fixed IP from server.
- fixed_ip = None
- for ip_set in server_detail['addresses']:
- for ip in server_detail['addresses'][ip_set]:
- if ip['type'] == 'fixed':
- fixed_ip = ip['addr']
- break
- if fixed_ip is not None:
- break
- # Remove the fixed IP from server.
- resp, body = self.client.remove_fixed_ip(server['id'],
- fixed_ip)
- self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
deleted file mode 100644
index 76b5549..0000000
--- a/tempest/api/compute/v3/servers/test_attach_volume.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import testtools
-
-from tempest.api.compute import base
-from tempest.common.utils.linux import remote_client
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class AttachVolumeV3Test(base.BaseV3ComputeTest):
-
- def __init__(self, *args, **kwargs):
- super(AttachVolumeV3Test, self).__init__(*args, **kwargs)
- self.server = None
- self.volume = None
- self.attached = False
-
- @classmethod
- def resource_setup(cls):
- cls.prepare_instance_network()
- super(AttachVolumeV3Test, cls).resource_setup()
- cls.device = CONF.compute.volume_device_name
- if not CONF.service_available.cinder:
- skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
-
- def _detach(self, server_id, volume_id):
- if self.attached:
- self.servers_client.detach_volume(server_id, volume_id)
- self.volumes_client.wait_for_volume_status(volume_id, 'available')
-
- def _delete_volume(self):
- if self.volume:
- self.volumes_client.delete_volume(self.volume['id'])
- self.volume = None
-
- def _create_and_attach(self):
- # Start a server and wait for it to become ready
- admin_pass = self.image_ssh_password
- resp, server = self.create_test_server(wait_until='ACTIVE',
- admin_password=admin_pass)
- self.server = server
-
- # Record addresses so that we can ssh later
- resp, server['addresses'] = \
- self.servers_client.list_addresses(server['id'])
-
- # Create a volume and wait for it to become ready
- resp, volume = self.volumes_client.create_volume(1,
- display_name='test')
- self.volume = volume
- self.addCleanup(self._delete_volume)
- self.volumes_client.wait_for_volume_status(volume['id'], 'available')
-
- # Attach the volume to the server
- self.servers_client.attach_volume(server['id'], volume['id'],
- device='/dev/%s' % self.device)
- self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
-
- self.attached = True
- self.addCleanup(self._detach, server['id'], volume['id'])
-
- @testtools.skipUnless(CONF.compute.run_ssh, 'SSH required for this test')
- @test.attr(type='gate')
- def test_attach_detach_volume(self):
- # Stop and Start a server with an attached volume, ensuring that
- # the volume remains attached.
- self._create_and_attach()
- server = self.server
- volume = self.volume
-
- self.servers_client.stop(server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
-
- self.servers_client.start(server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
-
- linux_client = remote_client.RemoteClient(server, self.image_ssh_user,
- server['admin_password'])
- partitions = linux_client.get_partitions()
- self.assertIn(self.device, partitions)
-
- self._detach(server['id'], volume['id'])
- self.attached = False
-
- self.servers_client.stop(server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
-
- self.servers_client.start(server['id'])
- self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
-
- linux_client = remote_client.RemoteClient(server, self.image_ssh_user,
- server['admin_password'])
- partitions = linux_client.get_partitions()
- self.assertNotIn(self.device, partitions)
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
deleted file mode 100644
index bcd6176..0000000
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ /dev/null
@@ -1,199 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import base64
-
-import netaddr
-import testtools
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest.common.utils.linux import remote_client
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class ServersV3Test(base.BaseV3ComputeTest):
- disk_config = 'AUTO'
-
- @classmethod
- def resource_setup(cls):
- cls.prepare_instance_network()
- super(ServersV3Test, cls).resource_setup()
- cls.meta = {'hello': 'world'}
- cls.accessIPv4 = '1.1.1.1'
- cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
- cls.name = data_utils.rand_name('server')
- file_contents = 'This is a test file.'
- personality = [{'path': '/test.txt',
- 'contents': base64.b64encode(file_contents)}]
- cls.client = cls.servers_client
- cli_resp = cls.create_test_server(name=cls.name,
- meta=cls.meta,
- access_ip_v4=cls.accessIPv4,
- access_ip_v6=cls.accessIPv6,
- personality=personality,
- disk_config=cls.disk_config)
- cls.resp, cls.server_initial = cli_resp
- cls.password = cls.server_initial['admin_password']
- cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
- resp, cls.server = cls.client.get_server(cls.server_initial['id'])
-
- @test.attr(type='smoke')
- def test_verify_server_details(self):
- # Verify the specified server attributes are set correctly
- self.assertEqual(self.accessIPv4,
- self.server['os-access-ips:access_ip_v4'])
- # NOTE(maurosr): See http://tools.ietf.org/html/rfc5952 (section 4)
- # Here we compare directly with the canonicalized format.
- self.assertEqual(self.server['os-access-ips:access_ip_v6'],
- str(netaddr.IPAddress(self.accessIPv6)))
- self.assertEqual(self.name, self.server['name'])
- self.assertEqual(self.image_ref, self.server['image']['id'])
- self.assertEqual(self.flavor_ref, self.server['flavor']['id'])
- self.assertEqual(self.meta, self.server['metadata'])
-
- @test.attr(type='smoke')
- def test_list_servers(self):
- # The created server should be in the list of all servers
- resp, body = self.client.list_servers()
- servers = body['servers']
- found = any([i for i in servers if i['id'] == self.server['id']])
- self.assertTrue(found)
-
- @test.attr(type='smoke')
- def test_list_servers_with_detail(self):
- # The created server should be in the detailed list of all servers
- resp, body = self.client.list_servers_with_detail()
- servers = body['servers']
- found = any([i for i in servers if i['id'] == self.server['id']])
- self.assertTrue(found)
-
- @testtools.skipUnless(CONF.compute.run_ssh,
- 'Instance validation tests are disabled.')
- @test.attr(type='gate')
- def test_verify_created_server_vcpus(self):
- # Verify that the number of vcpus reported by the instance matches
- # the amount stated by the flavor
- resp, flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
- linux_client = remote_client.RemoteClient(self.server,
- self.ssh_user, self.password)
- self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
-
- @testtools.skipUnless(CONF.compute.run_ssh,
- 'Instance validation tests are disabled.')
- @test.attr(type='gate')
- def test_host_name_is_same_as_server_name(self):
- # Verify the instance host name is the same as the server name
- linux_client = remote_client.RemoteClient(self.server,
- self.ssh_user, self.password)
- self.assertTrue(linux_client.hostname_equals_servername(self.name))
-
-
-class ServersWithSpecificFlavorV3Test(base.BaseV3ComputeAdminTest):
- disk_config = 'AUTO'
-
- @classmethod
- def resource_setup(cls):
- cls.prepare_instance_network()
- super(ServersWithSpecificFlavorV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- cls.flavor_client = cls.flavors_admin_client
-
- @testtools.skipUnless(CONF.compute.run_ssh,
- 'Instance validation tests are disabled.')
- @test.attr(type='gate')
- def test_verify_created_server_ephemeral_disk(self):
- # Verify that the ephemeral disk is created when creating server
-
- def create_flavor_with_extra_specs():
- flavor_with_eph_disk_name = data_utils.rand_name('eph_flavor')
- flavor_with_eph_disk_id = data_utils.rand_int_id(start=1000)
- ram = 512
- vcpus = 1
- disk = 10
-
- # Create a flavor with extra specs
- resp, flavor = (self.flavor_client.
- create_flavor(flavor_with_eph_disk_name,
- ram, vcpus, disk,
- flavor_with_eph_disk_id,
- ephemeral=1, rxtx=1))
- self.addCleanup(flavor_clean_up, flavor['id'])
- self.assertEqual(201, resp.status)
-
- return flavor['id']
-
- def create_flavor_without_extra_specs():
- flavor_no_eph_disk_name = data_utils.rand_name('no_eph_flavor')
- flavor_no_eph_disk_id = data_utils.rand_int_id(start=1000)
-
- ram = 512
- vcpus = 1
- disk = 10
-
- # Create a flavor without extra specs
- resp, flavor = (self.flavor_client.
- create_flavor(flavor_no_eph_disk_name,
- ram, vcpus, disk,
- flavor_no_eph_disk_id))
- self.addCleanup(flavor_clean_up, flavor['id'])
- self.assertEqual(201, resp.status)
-
- return flavor['id']
-
- def flavor_clean_up(flavor_id):
- resp, body = self.flavor_client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 204)
- self.flavor_client.wait_for_resource_deletion(flavor_id)
-
- flavor_with_eph_disk_id = create_flavor_with_extra_specs()
- flavor_no_eph_disk_id = create_flavor_without_extra_specs()
-
- admin_pass = self.image_ssh_password
-
- resp, server_no_eph_disk = (self.create_test_server(
- wait_until='ACTIVE',
- adminPass=admin_pass,
- flavor=flavor_no_eph_disk_id))
- resp, server_with_eph_disk = (self.create_test_server(
- wait_until='ACTIVE',
- adminPass=admin_pass,
- flavor=flavor_with_eph_disk_id))
- # Get partition number of server without extra specs.
- _, server_no_eph_disk = self.client.get_server(
- server_no_eph_disk['id'])
- linux_client = remote_client.RemoteClient(server_no_eph_disk,
- self.ssh_user, admin_pass)
- partition_num = len(linux_client.get_partitions().split('\n'))
- _, server_with_eph_disk = self.client.get_server(
- server_with_eph_disk['id'])
- linux_client = remote_client.RemoteClient(server_with_eph_disk,
- self.ssh_user, admin_pass)
- partition_num_emph = len(linux_client.get_partitions().split('\n'))
- self.assertEqual(partition_num + 1, partition_num_emph)
-
-
-class ServersV3TestManualDisk(ServersV3Test):
- disk_config = 'MANUAL'
-
- @classmethod
- def resource_setup(cls):
- if not CONF.compute_feature_enabled.disk_config:
- msg = "DiskConfig extension not enabled."
- raise cls.skipException(msg)
- super(ServersV3TestManualDisk, cls).resource_setup()
diff --git a/tempest/api/compute/v3/servers/test_delete_server.py b/tempest/api/compute/v3/servers/test_delete_server.py
deleted file mode 100644
index ab10b4c..0000000
--- a/tempest/api/compute/v3/servers/test_delete_server.py
+++ /dev/null
@@ -1,156 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import testtools
-
-from tempest.api.compute import base
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class DeleteServersV3Test(base.BaseV3ComputeTest):
- # NOTE: Server creations of each test class should be under 10
- # for preventing "Quota exceeded for instances".
-
- @classmethod
- def resource_setup(cls):
- super(DeleteServersV3Test, cls).resource_setup()
- cls.client = cls.servers_client
-
- @test.attr(type='gate')
- def test_delete_server_while_in_building_state(self):
- # Delete a server while it's VM state is Building
- resp, server = self.create_test_server(wait_until='BUILD')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
-
- @test.attr(type='gate')
- def test_delete_active_server(self):
- # Delete a server while it's VM state is Active
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
-
- @test.attr(type='gate')
- def test_delete_server_while_in_shutoff_state(self):
- # Delete a server while it's VM state is Shutoff
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.stop(server['id'])
- self.client.wait_for_server_status(server['id'], 'SHUTOFF')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
-
- @testtools.skipUnless(CONF.compute_feature_enabled.pause,
- 'Pause is not available.')
- @test.attr(type='gate')
- def test_delete_server_while_in_pause_state(self):
- # Delete a server while it's VM state is Pause
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.pause_server(server['id'])
- self.client.wait_for_server_status(server['id'], 'PAUSED')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
-
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @test.attr(type='gate')
- def test_delete_server_while_in_shelved_state(self):
- # Delete a server while it's VM state is Shelved
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.shelve_server(server['id'])
- self.assertEqual(202, resp.status)
-
- offload_time = CONF.compute.shelved_offload_time
- if offload_time >= 0:
- self.client.wait_for_server_status(server['id'],
- 'SHELVED_OFFLOADED',
- extra_timeout=offload_time)
- else:
- self.client.wait_for_server_status(server['id'],
- 'SHELVED')
-
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
-
- @testtools.skipIf(not CONF.compute_feature_enabled.resize,
- 'Resize not available.')
- @test.attr(type='gate')
- def test_delete_server_while_in_verify_resize_state(self):
- # Delete a server while it's VM state is VERIFY_RESIZE
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.client.resize(server['id'], self.flavor_ref_alt)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(server['id'], 'VERIFY_RESIZE')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
-
- @test.attr(type='gate')
- def test_delete_server_while_in_attached_volume(self):
- # Delete a server while a volume is attached to it
- device = '/dev/%s' % CONF.compute.volume_device_name
- resp, server = self.create_test_server(wait_until='ACTIVE')
-
- resp, volume = self.volumes_client.create_volume(1)
- self.addCleanup(self.volumes_client.delete_volume, volume['id'])
- self.volumes_client.wait_for_volume_status(volume['id'], 'available')
- resp, body = self.client.attach_volume(server['id'],
- volume['id'],
- device=device)
- self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
-
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.client.wait_for_server_termination(server['id'])
- self.volumes_client.wait_for_volume_status(volume['id'], 'available')
-
-
-class DeleteServersAdminV3Test(base.BaseV3ComputeAdminTest):
- # NOTE: Server creations of each test class should be under 10
- # for preventing "Quota exceeded for instances".
-
- @classmethod
- def resource_setup(cls):
- super(DeleteServersAdminV3Test, cls).resource_setup()
- cls.non_admin_client = cls.servers_client
- cls.admin_client = cls.servers_admin_client
-
- @test.attr(type='gate')
- def test_delete_server_while_in_error_state(self):
- # Delete a server while it's VM state is error
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, body = self.admin_client.reset_state(server['id'], state='error')
- self.assertEqual(202, resp.status)
- # Verify server's state
- resp, server = self.non_admin_client.get_server(server['id'])
- self.assertEqual(server['status'], 'ERROR')
- resp, _ = self.non_admin_client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.servers_client.wait_for_server_termination(server['id'],
- ignore_error=True)
-
- @test.attr(type='gate')
- def test_admin_delete_servers_of_others(self):
- # Administrator can delete servers of others
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, _ = self.admin_client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
- self.servers_client.wait_for_server_termination(server['id'])
diff --git a/tempest/api/compute/v3/servers/test_instance_actions.py b/tempest/api/compute/v3/servers/test_instance_actions.py
deleted file mode 100644
index 227f6cd..0000000
--- a/tempest/api/compute/v3/servers/test_instance_actions.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class InstanceActionsV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(InstanceActionsV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.resp = resp
- cls.server_id = server['id']
-
- @test.attr(type='gate')
- def test_list_server_actions(self):
- # List actions of the provided server
- resp, body = self.client.reboot(self.server_id, 'HARD')
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- resp, body = self.client.list_server_actions(self.server_id)
- self.assertEqual(200, resp.status)
- self.assertTrue(len(body) == 2, str(body))
- self.assertTrue(any([i for i in body if i['action'] == 'create']))
- self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
-
- @test.attr(type='gate')
- def test_get_server_action(self):
- # Get the action details of the provided server
- request_id = self.resp['x-openstack-request-id']
- resp, body = self.client.get_server_action(self.server_id,
- request_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(self.server_id, body['server_uuid'])
- self.assertEqual('create', body['action'])
diff --git a/tempest/api/compute/v3/servers/test_instance_actions_negative.py b/tempest/api/compute/v3/servers/test_instance_actions_negative.py
deleted file mode 100644
index b9d4be2..0000000
--- a/tempest/api/compute/v3/servers/test_instance_actions_negative.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2014 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class InstanceActionsNegativeV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(InstanceActionsNegativeV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
-
- @test.attr(type=['negative', 'gate'])
- def test_list_server_actions_invalid_server(self):
- # List actions of the invalid server id
- invalid_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.list_server_actions, invalid_server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_server_action_invalid_request(self):
- # Get the action details of the provided server with invalid request
- invalid_request_id = 'req-' + data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.get_server_action,
- self.server_id, invalid_request_id)
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
deleted file mode 100644
index 73844cf..0000000
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ /dev/null
@@ -1,269 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.api import utils
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class ListServerFiltersV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- cls.set_network_resources(network=True, subnet=True, dhcp=True)
- super(ListServerFiltersV3Test, cls).resource_setup()
- cls.client = cls.servers_client
-
- # Check to see if the alternate image ref actually exists...
- images_client = cls.images_client
- resp, images = images_client.image_list()
-
- if cls.image_ref != cls.image_ref_alt and \
- any([image for image in images
- if image['id'] == cls.image_ref_alt]):
- cls.multiple_images = True
- else:
- cls.image_ref_alt = cls.image_ref
-
- # Do some sanity checks here. If one of the images does
- # not exist, fail early since the tests won't work...
- try:
- cls.images_client.get_image_meta(cls.image_ref)
- except exceptions.NotFound:
- raise RuntimeError("Image %s (image_ref) was not found!" %
- cls.image_ref)
-
- try:
- cls.images_client.get_image_meta(cls.image_ref_alt)
- except exceptions.NotFound:
- raise RuntimeError("Image %s (image_ref_alt) was not found!" %
- cls.image_ref_alt)
-
- cls.s1_name = data_utils.rand_name(cls.__name__ + '-instance')
- resp, cls.s1 = cls.create_test_server(name=cls.s1_name,
- wait_until='ACTIVE')
-
- cls.s2_name = data_utils.rand_name(cls.__name__ + '-instance')
- resp, cls.s2 = cls.create_test_server(name=cls.s2_name,
- image_id=cls.image_ref_alt,
- wait_until='ACTIVE')
-
- cls.s3_name = data_utils.rand_name(cls.__name__ + '-instance')
- resp, cls.s3 = cls.create_test_server(name=cls.s3_name,
- flavor=cls.flavor_ref_alt,
- wait_until='ACTIVE')
-
- cls.fixed_network_name = CONF.compute.fixed_network_name
- if CONF.service_available.neutron:
- if hasattr(cls.isolated_creds, 'get_primary_network'):
- network = cls.isolated_creds.get_primary_network()
- cls.fixed_network_name = network['name']
-
- @utils.skip_unless_attr('multiple_images', 'Only one image found')
- @test.attr(type='gate')
- def test_list_servers_filter_by_image(self):
- # Filter the list of servers by image
- params = {'image': self.image_ref}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_flavor(self):
- # Filter the list of servers by flavor
- params = {'flavor': self.flavor_ref_alt}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertNotIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_server_name(self):
- # Filter the list of servers by server name
- params = {'name': self.s1_name}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_server_status(self):
- # Filter the list of servers by server status
- params = {'status': 'active'}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_limit(self):
- # Verify only the expected number of servers are returned
- params = {'limit': 1}
- resp, servers = self.client.list_servers(params)
- self.assertEqual(1, len([x for x in servers['servers'] if 'id' in x]))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_zero_limit(self):
- # Verify only the expected number of servers are returned
- params = {'limit': 0}
- resp, servers = self.client.list_servers(params)
- self.assertEqual(0, len(servers['servers']))
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_exceed_limit(self):
- # Verify only the expected number of servers are returned
- params = {'limit': 100000}
- resp, servers = self.client.list_servers(params)
- resp, all_servers = self.client.list_servers()
- self.assertEqual(len([x for x in all_servers['servers'] if 'id' in x]),
- len([x for x in servers['servers'] if 'id' in x]))
-
- @utils.skip_unless_attr('multiple_images', 'Only one image found')
- @test.attr(type='gate')
- def test_list_servers_detailed_filter_by_image(self):
- # Filter the detailed list of servers by image
- params = {'image': self.image_ref}
- resp, body = self.client.list_servers_with_detail(params)
- servers = body['servers']
-
- self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_detailed_filter_by_flavor(self):
- # Filter the detailed list of servers by flavor
- params = {'flavor': self.flavor_ref_alt}
- resp, body = self.client.list_servers_with_detail(params)
- servers = body['servers']
-
- self.assertNotIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_detailed_filter_by_server_name(self):
- # Filter the detailed list of servers by server name
- params = {'name': self.s1_name}
- resp, body = self.client.list_servers_with_detail(params)
- servers = body['servers']
-
- self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_detailed_filter_by_server_status(self):
- # Filter the detailed list of servers by server status
- params = {'status': 'active'}
- resp, body = self.client.list_servers_with_detail(params)
- expected_servers = (self.s1['id'], self.s2['id'], self.s3['id'])
- servers = [x for x in body['servers'] if x['id'] in expected_servers]
-
- self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
- self.assertEqual(['ACTIVE'] * 3, [x['status'] for x in servers])
-
- @test.attr(type='gate')
- def test_list_servers_filter_by_shutoff_status(self):
- # Filter the list of servers by server shutoff status
- params = {'status': 'shutoff'}
- self.client.stop(self.s1['id'])
- self.client.wait_for_server_status(self.s1['id'],
- 'SHUTOFF')
- resp, body = self.client.list_servers(params)
- self.client.start(self.s1['id'])
- self.client.wait_for_server_status(self.s1['id'],
- 'ACTIVE')
- servers = body['servers']
-
- self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
- self.assertNotIn(self.s3['id'], map(lambda x: x['id'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_filtered_by_name_wildcard(self):
- # List all servers that contains '-instance' in name
- params = {'name': '-instance'}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
- self.assertIn(self.s2_name, map(lambda x: x['name'], servers))
- self.assertIn(self.s3_name, map(lambda x: x['name'], servers))
-
- # Let's take random part of name and try to search it
- part_name = self.s1_name[6:-1]
-
- params = {'name': part_name}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_filtered_by_ip(self):
- # Filter servers by ip
- # Here should be listed 1 server
- resp, self.s1 = self.client.get_server(self.s1['id'])
- ip = self.s1['addresses'][self.fixed_network_name][0]['addr']
- params = {'ip': ip}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
- self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
-
- @test.skip_because(bug="1182883",
- condition=CONF.service_available.neutron)
- @test.attr(type='gate')
- def test_list_servers_filtered_by_ip_regex(self):
- # Filter servers by regex ip
- # List all servers filtered by part of ip address.
- # Here should be listed all servers
- resp, self.s1 = self.client.get_server(self.s1['id'])
- ip = self.s1['addresses'][self.fixed_network_name][0]['addr'][0:-3]
- params = {'ip': ip}
- resp, body = self.client.list_servers(params)
- servers = body['servers']
-
- self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
- self.assertIn(self.s2_name, map(lambda x: x['name'], servers))
- self.assertIn(self.s3_name, map(lambda x: x['name'], servers))
-
- @test.attr(type='gate')
- def test_list_servers_detailed_limit_results(self):
- # Verify only the expected number of detailed results are returned
- params = {'limit': 1}
- resp, servers = self.client.list_servers_with_detail(params)
- self.assertEqual(1, len(servers['servers']))
diff --git a/tempest/api/compute/v3/servers/test_list_servers_negative.py b/tempest/api/compute/v3/servers/test_list_servers_negative.py
deleted file mode 100644
index 67e1155..0000000
--- a/tempest/api/compute/v3/servers/test_list_servers_negative.py
+++ /dev/null
@@ -1,164 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import datetime
-
-from six import moves
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest import test
-
-
-class ListServersNegativeV3Test(base.BaseV3ComputeTest):
- force_tenant_isolation = True
-
- @classmethod
- def resource_setup(cls):
- super(ListServersNegativeV3Test, cls).resource_setup()
- cls.client = cls.servers_client
-
- # The following servers are created for use
- # by the test methods in this class. These
- # servers are cleaned up automatically in the
- # tearDownClass method of the super-class.
- cls.existing_fixtures = []
- cls.deleted_fixtures = []
- cls.start_time = datetime.datetime.utcnow()
- for x in moves.xrange(2):
- resp, srv = cls.create_test_server(wait_until='ACTIVE')
- cls.existing_fixtures.append(srv)
-
- resp, srv = cls.create_test_server()
- cls.client.delete_server(srv['id'])
- # We ignore errors on termination because the server may
- # be put into ERROR status on a quick spawn, then delete,
- # as the compute node expects the instance local status
- # to be spawning, not deleted. See LP Bug#1061167
- cls.client.wait_for_server_termination(srv['id'],
- ignore_error=True)
- cls.deleted_fixtures.append(srv)
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_with_a_deleted_server(self):
- # Verify deleted servers do not show by default in list servers
- # List servers and verify server not returned
- resp, body = self.client.list_servers()
- servers = body['servers']
- deleted_ids = [s['id'] for s in self.deleted_fixtures]
- actual = [srv for srv in servers
- if srv['id'] in deleted_ids]
- self.assertEqual('200', resp['status'])
- self.assertEqual([], actual)
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_non_existing_image(self):
- # Listing servers for a non existing image returns empty list
- non_existing_image = '1234abcd-zzz0-aaa9-ppp3-0987654abcde'
- resp, body = self.client.list_servers(dict(image=non_existing_image))
- servers = body['servers']
- self.assertEqual('200', resp['status'])
- self.assertEqual([], servers)
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_non_existing_flavor(self):
- # Listing servers by non existing flavor returns empty list
- non_existing_flavor = 1234
- resp, body = self.client.list_servers(dict(flavor=non_existing_flavor))
- servers = body['servers']
- self.assertEqual('200', resp['status'])
- self.assertEqual([], servers)
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_non_existing_server_name(self):
- # Listing servers for a non existent server name returns empty list
- non_existing_name = 'junk_server_1234'
- resp, body = self.client.list_servers(dict(name=non_existing_name))
- servers = body['servers']
- self.assertEqual('200', resp['status'])
- self.assertEqual([], servers)
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_status_non_existing(self):
- # Return an empty list when invalid status is specified
- non_existing_status = 'BALONEY'
- resp, body = self.client.list_servers(dict(status=non_existing_status))
- servers = body['servers']
- self.assertEqual('200', resp['status'])
- self.assertEqual([], servers)
-
- @test.attr(type='gate')
- def test_list_servers_by_limits(self):
- # List servers by specifying limits
- resp, body = self.client.list_servers({'limit': 1})
- self.assertEqual('200', resp['status'])
- self.assertEqual(1, len([x for x in body['servers'] if 'id' in x]))
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_limits_greater_than_actual_count(self):
- # List servers by specifying a greater value for limit
- resp, body = self.client.list_servers({'limit': 100})
- self.assertEqual('200', resp['status'])
- self.assertEqual(len(self.existing_fixtures), len(body['servers']))
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_limits_pass_string(self):
- # Return an error if a string value is passed for limit
- self.assertRaises(exceptions.BadRequest, self.client.list_servers,
- {'limit': 'testing'})
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_limits_pass_negative_value(self):
- # Return an error if a negative value for limit is passed
- self.assertRaises(exceptions.BadRequest, self.client.list_servers,
- {'limit': -1})
-
- @test.attr(type='gate')
- def test_list_servers_by_changes_since(self):
- # Servers are listed by specifying changes-since date
- changes_since = {'changes_since': self.start_time.isoformat()}
- resp, body = self.client.list_servers(changes_since)
- self.assertEqual('200', resp['status'])
- # changes-since returns all instances, including deleted.
- num_expected = (len(self.existing_fixtures) +
- len(self.deleted_fixtures))
- self.assertEqual(num_expected, len(body['servers']),
- "Number of servers %d is wrong in %s" %
- (num_expected, body['servers']))
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_changes_since_invalid_date(self):
- # Return an error when invalid date format is passed
- self.assertRaises(exceptions.BadRequest, self.client.list_servers,
- {'changes_since': '2011/01/01'})
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_by_changes_since_future_date(self):
- # Return an empty list when a date in the future is passed
- changes_since = {'changes_since': '2051-01-01T12:34:00Z'}
- resp, body = self.client.list_servers(changes_since)
- self.assertEqual('200', resp['status'])
- self.assertEqual(0, len(body['servers']))
-
- @test.attr(type=['negative', 'gate'])
- def test_list_servers_detail_server_is_deleted(self):
- # Server details are not listed for a deleted server
- deleted_ids = [s['id'] for s in self.deleted_fixtures]
- resp, body = self.client.list_servers_with_detail()
- servers = body['servers']
- actual = [srv for srv in servers
- if srv['id'] in deleted_ids]
- self.assertEqual('200', resp['status'])
- self.assertEqual([], actual)
diff --git a/tempest/api/compute/v3/servers/test_multiple_create.py b/tempest/api/compute/v3/servers/test_multiple_create.py
deleted file mode 100644
index 23e0854..0000000
--- a/tempest/api/compute/v3/servers/test_multiple_create.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-class MultipleCreateV3Test(base.BaseV3ComputeTest):
- _name = 'multiple-create-test'
-
- def _generate_name(self):
- return data_utils.rand_name(self._name)
-
- def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
- """
- This is the right way to create_multiple servers and manage to get the
- created servers into the servers list to be cleaned up after all.
- """
- kwargs['name'] = kwargs.get('name', self._generate_name())
- resp, body = self.create_test_server(**kwargs)
-
- return resp, body
-
- @test.attr(type='gate')
- def test_multiple_create(self):
- resp, body = self._create_multiple_servers(wait_until='ACTIVE',
- min_count=1,
- max_count=2)
- # NOTE(maurosr): do status response check and also make sure that
- # reservation_id is not in the response body when the request send
- # contains return_reservation_id=False
- self.assertEqual('202', resp['status'])
- self.assertNotIn('reservation_id', body)
-
- @test.attr(type='gate')
- def test_multiple_create_with_reservation_return(self):
- resp, body = self._create_multiple_servers(wait_until='ACTIVE',
- min_count=1,
- max_count=2,
- return_reservation_id=True)
- self.assertEqual(resp['status'], '202')
- self.assertIn('reservation_id', body)
diff --git a/tempest/api/compute/v3/servers/test_multiple_create_negative.py b/tempest/api/compute/v3/servers/test_multiple_create_negative.py
deleted file mode 100644
index f208bc0..0000000
--- a/tempest/api/compute/v3/servers/test_multiple_create_negative.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class MultipleCreateV3NegativeTest(base.BaseV3ComputeTest):
- _name = 'multiple-create-negative-test'
-
- def _generate_name(self):
- return data_utils.rand_name(self._name)
-
- def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
- """
- This is the right way to create_multiple servers and manage to get the
- created servers into the servers list to be cleaned up after all.
- """
- kwargs['name'] = kwargs.get('name', self._generate_name())
- resp, body = self.create_test_server(**kwargs)
-
- return resp, body
-
- @test.attr(type=['negative', 'gate'])
- def test_min_count_less_than_one(self):
- invalid_min_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=invalid_min_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_min_count_non_integer(self):
- invalid_min_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=invalid_min_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_max_count_less_than_one(self):
- invalid_max_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- max_count=invalid_max_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_max_count_non_integer(self):
- invalid_max_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- max_count=invalid_max_count)
-
- @test.attr(type=['negative', 'gate'])
- def test_max_count_less_than_min_count(self):
- min_count = 3
- max_count = 2
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=min_count,
- max_count=max_count)
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
deleted file mode 100644
index a4e8dba..0000000
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ /dev/null
@@ -1,509 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import logging
-import urlparse
-
-import testtools
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest.common.utils.linux import remote_client
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class ServerActionsV3Test(base.BaseV3ComputeTest):
- run_ssh = CONF.compute.run_ssh
-
- def setUp(self):
- # NOTE(afazekas): Normally we use the same server with all test cases,
- # but if it has an issue, we build a new one
- super(ServerActionsV3Test, self).setUp()
- # Check if the server is in a clean state after test
- try:
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- except Exception:
- # Rebuild server if something happened to it during a test
- self.__class__.server_id = self.rebuild_server(self.server_id)
-
- def tearDown(self):
- _, server = self.client.get_server(self.server_id)
- self.assertEqual(self.image_ref, server['image']['id'])
- self.server_check_teardown()
- super(ServerActionsV3Test, self).tearDown()
-
- @classmethod
- def resource_setup(cls):
- cls.prepare_instance_network()
- super(ServerActionsV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- cls.server_id = cls.rebuild_server(None)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
- 'Change password not available.')
- @test.attr(type='gate')
- def test_change_server_password(self):
- # The server's password should be set to the provided password
- new_password = 'Newpass1234'
- resp, body = self.client.change_password(self.server_id, new_password)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- if self.run_ssh:
- # Verify that the user can authenticate with the new password
- resp, server = self.client.get_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- new_password)
- linux_client.validate_authentication()
-
- @test.attr(type='smoke')
- def test_reboot_server_hard(self):
- # The server should be power cycled
- if self.run_ssh:
- # Get the time the server was last rebooted,
- resp, server = self.client.get_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
- boot_time = linux_client.get_boot_time()
-
- resp, body = self.client.reboot(self.server_id, 'HARD')
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- if self.run_ssh:
- # Log in and verify the boot time has changed
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
- new_boot_time = linux_client.get_boot_time()
- self.assertGreater(new_boot_time, boot_time)
-
- @test.skip_because(bug="1014647")
- @test.attr(type='smoke')
- def test_reboot_server_soft(self):
- # The server should be signaled to reboot gracefully
- if self.run_ssh:
- # Get the time the server was last rebooted,
- resp, server = self.client.get_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
- boot_time = linux_client.get_boot_time()
-
- resp, body = self.client.reboot(self.server_id, 'SOFT')
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- if self.run_ssh:
- # Log in and verify the boot time has changed
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
- new_boot_time = linux_client.get_boot_time()
- self.assertGreater(new_boot_time, boot_time)
-
- @test.attr(type='smoke')
- def test_rebuild_server(self):
- # The server should be rebuilt using the provided image and data
- meta = {'rebuild': 'server'}
- new_name = data_utils.rand_name('server')
- password = 'rebuildPassw0rd'
- resp, rebuilt_server = self.client.rebuild(self.server_id,
- self.image_ref_alt,
- name=new_name,
- metadata=meta,
- admin_password=password)
-
- # Verify the properties in the initial response are correct
- self.assertEqual(self.server_id, rebuilt_server['id'])
- rebuilt_image_id = rebuilt_server['image']['id']
- self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
- self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
-
- # Verify the server properties after the rebuild completes
- self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
- resp, server = self.client.get_server(rebuilt_server['id'])
- rebuilt_image_id = server['image']['id']
- self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
- self.assertEqual(new_name, server['name'])
-
- if self.run_ssh:
- # Verify that the user can authenticate with the provided password
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- password)
- linux_client.validate_authentication()
-
- if self.image_ref_alt != self.image_ref:
- self.client.rebuild(self.server_id, self.image_ref)
-
- @test.attr(type='gate')
- def test_rebuild_server_in_stop_state(self):
- # The server in stop state should be rebuilt using the provided
- # image and remain in SHUTOFF state
- resp, server = self.client.get_server(self.server_id)
- old_image = server['image']['id']
- new_image = self.image_ref_alt \
- if old_image == self.image_ref else self.image_ref
- resp, server = self.client.stop(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'SHUTOFF')
- resp, rebuilt_server = self.client.rebuild(self.server_id, new_image)
-
- # Verify the properties in the initial response are correct
- self.assertEqual(self.server_id, rebuilt_server['id'])
- rebuilt_image_id = rebuilt_server['image']['id']
- self.assertEqual(new_image, rebuilt_image_id)
- self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
-
- # Verify the server properties after the rebuild completes
- self.client.wait_for_server_status(rebuilt_server['id'], 'SHUTOFF')
- resp, server = self.client.get_server(rebuilt_server['id'])
- rebuilt_image_id = server['image']['id']
- self.assertEqual(new_image, rebuilt_image_id)
-
- # Restore to the original image (The tearDown will test it again)
- if self.image_ref_alt != self.image_ref:
- self.client.rebuild(self.server_id, old_image)
- self.client.wait_for_server_status(self.server_id, 'SHUTOFF')
- self.client.start(self.server_id)
-
- def _detect_server_image_flavor(self, server_id):
- # Detects the current server image flavor ref.
- resp, server = self.client.get_server(server_id)
- current_flavor = server['flavor']['id']
- new_flavor_ref = self.flavor_ref_alt \
- if current_flavor == self.flavor_ref else self.flavor_ref
- return current_flavor, new_flavor_ref
-
- def _test_resize_server_confirm(self, stop=False):
- # The server's RAM and disk space should be modified to that of
- # the provided flavor
-
- previous_flavor_ref, new_flavor_ref = \
- self._detect_server_image_flavor(self.server_id)
-
- if stop:
- resp = self.servers_client.stop(self.server_id)[0]
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id,
- 'SHUTOFF')
-
- resp, server = self.client.resize(self.server_id, new_flavor_ref)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')
-
- self.client.confirm_resize(self.server_id)
- expected_status = 'SHUTOFF' if stop else 'ACTIVE'
- self.client.wait_for_server_status(self.server_id, expected_status)
-
- resp, server = self.client.get_server(self.server_id)
- self.assertEqual(new_flavor_ref, server['flavor']['id'])
-
- if stop:
- # NOTE(mriedem): tearDown requires the server to be started.
- self.client.start(self.server_id)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.resize,
- 'Resize not available.')
- @test.attr(type='smoke')
- def test_resize_server_confirm(self):
- self._test_resize_server_confirm(stop=False)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.resize,
- 'Resize not available.')
- @test.attr(type='smoke')
- def test_resize_server_confirm_from_stopped(self):
- self._test_resize_server_confirm(stop=True)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.resize,
- 'Resize not available.')
- @test.attr(type='gate')
- def test_resize_server_revert(self):
- # The server's RAM and disk space should return to its original
- # values after a resize is reverted
-
- previous_flavor_ref, new_flavor_ref = \
- self._detect_server_image_flavor(self.server_id)
-
- resp, server = self.client.resize(self.server_id, new_flavor_ref)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE')
-
- self.client.revert_resize(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- resp, server = self.client.get_server(self.server_id)
- self.assertEqual(previous_flavor_ref, server['flavor']['id'])
-
- @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
- 'Snapshotting not available, backup not possible.')
- @test.attr(type='gate')
- def test_create_backup(self):
- # Positive test:create backup successfully and rotate backups correctly
- # create the first and the second backup
- backup1 = data_utils.rand_name('backup-1')
- resp, _ = self.servers_client.create_backup(self.server_id,
- 'daily',
- 2,
- backup1)
- oldest_backup_exist = True
-
- # the oldest one should be deleted automatically in this test
- def _clean_oldest_backup(oldest_backup):
- if oldest_backup_exist:
- try:
- self.images_client.delete_image(oldest_backup)
- except exceptions.NotFound:
- pass
- else:
- LOG.warning("Deletion of oldest backup %s should not have "
- "been successful as it should have been "
- "deleted during rotation." % oldest_backup)
-
- image1_id = data_utils.parse_image_id(resp['location'])
- self.addCleanup(_clean_oldest_backup, image1_id)
- self.assertEqual(202, resp.status)
- self.images_client.wait_for_image_status(image1_id, 'active')
-
- backup2 = data_utils.rand_name('backup-2')
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp, _ = self.servers_client.create_backup(self.server_id,
- 'daily',
- 2,
- backup2)
- image2_id = data_utils.parse_image_id(resp['location'])
- self.addCleanup(self.images_client.delete_image, image2_id)
- self.assertEqual(202, resp.status)
- self.images_client.wait_for_image_status(image2_id, 'active')
-
- # verify they have been created
- properties = {
- 'image_type': 'backup',
- 'backup_type': "daily",
- 'instance_uuid': self.server_id,
- }
- resp, image_list = self.images_client.image_list_detail(
- properties,
- sort_key='created_at',
- sort_dir='asc')
- self.assertEqual(200, resp.status)
- self.assertEqual(2, len(image_list))
- self.assertEqual((backup1, backup2),
- (image_list[0]['name'], image_list[1]['name']))
-
- # create the third one, due to the rotation is 2,
- # the first one will be deleted
- backup3 = data_utils.rand_name('backup-3')
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp, _ = self.servers_client.create_backup(self.server_id,
- 'daily',
- 2,
- backup3)
- image3_id = data_utils.parse_image_id(resp['location'])
- self.addCleanup(self.images_client.delete_image, image3_id)
- self.assertEqual(202, resp.status)
- # the first back up should be deleted
- self.images_client.wait_for_resource_deletion(image1_id)
- oldest_backup_exist = False
- resp, image_list = self.images_client.image_list_detail(
- properties,
- sort_key='created_at',
- sort_dir='asc')
- self.assertEqual(200, resp.status)
- self.assertEqual(2, len(image_list),
- 'Unexpected number of images for '
- 'v3:test_create_backup; was the oldest backup not '
- 'yet deleted? Image list: %s' %
- [image['name'] for image in image_list])
- self.assertEqual((backup2, backup3),
- (image_list[0]['name'], image_list[1]['name']))
-
- def _get_output(self):
- resp, output = self.servers_client.get_console_output(
- self.server_id, 10)
- self.assertEqual(200, resp.status)
- self.assertTrue(output, "Console output was empty.")
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.console_output,
- 'Console output not supported.')
- @test.attr(type='gate')
- def test_get_console_output(self):
- # Positive test:Should be able to GET the console output
- # for a given server_id and number of lines
-
- # This reboot is necessary for outputting some console log after
- # creating a instance backup. If a instance backup, the console
- # log file is truncated and we cannot get any console log through
- # "console-log" API.
- # The detail is https://bugs.launchpad.net/nova/+bug/1251920
- resp, body = self.servers_client.reboot(self.server_id, 'HARD')
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- self.wait_for(self._get_output)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.console_output,
- 'Console output not supported.')
- @test.attr(type='gate')
- def test_get_console_output_server_id_in_shutoff_status(self):
- # Positive test:Should be able to GET the console output
- # for a given server_id in SHUTOFF status
-
- # NOTE: SHUTOFF is irregular status. To avoid test instability,
- # one server is created only for this test without using
- # the server that was created in setupClass.
- resp, server = self.create_test_server(wait_until='ACTIVE')
- temp_server_id = server['id']
-
- resp, server = self.servers_client.stop(temp_server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(temp_server_id, 'SHUTOFF')
-
- self.wait_for(self._get_output)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.pause,
- 'Pause is not available.')
- @test.attr(type='gate')
- def test_pause_unpause_server(self):
- resp, server = self.client.pause_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'PAUSED')
- resp, server = self.client.unpause_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
- 'Suspend is not available.')
- @test.attr(type='gate')
- def test_suspend_resume_server(self):
- resp, server = self.client.suspend_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'SUSPENDED')
- resp, server = self.client.resume_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @test.attr(type='gate')
- def test_shelve_unshelve_server(self):
- resp, server = self.client.shelve_server(self.server_id)
- self.assertEqual(202, resp.status)
-
- offload_time = CONF.compute.shelved_offload_time
- if offload_time >= 0:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED_OFFLOADED',
- extra_timeout=offload_time)
- else:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED')
-
- resp, server = self.client.shelve_offload_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED_OFFLOADED')
-
- resp, server = self.client.get_server(self.server_id)
- image_name = server['name'] + '-shelved'
- resp, images = self.images_client.image_list(name=image_name)
- self.assertEqual(1, len(images))
- self.assertEqual(image_name, images[0]['name'])
-
- resp, server = self.client.unshelve_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- @test.attr(type='gate')
- def test_stop_start_server(self):
- resp, server = self.servers_client.stop(self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'SHUTOFF')
- resp, server = self.servers_client.start(self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- @test.attr(type='gate')
- def test_lock_unlock_server(self):
- # Lock the server,try server stop(exceptions throw),unlock it and retry
- resp, server = self.servers_client.lock_server(self.server_id)
- self.assertEqual(202, resp.status)
- resp, server = self.servers_client.get_server(self.server_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(server['status'], 'ACTIVE')
- # Locked server is not allowed to be stopped by non-admin user
- self.assertRaises(exceptions.Conflict,
- self.servers_client.stop, self.server_id)
- resp, server = self.servers_client.unlock_server(self.server_id)
- self.assertEqual(202, resp.status)
- resp, server = self.servers_client.stop(self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'SHUTOFF')
- resp, server = self.servers_client.start(self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- def _validate_url(self, url):
- valid_scheme = ['http', 'https']
- parsed_url = urlparse.urlparse(url)
- self.assertNotEqual('None', parsed_url.hostname)
- self.assertIn(parsed_url.scheme, valid_scheme)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.vnc_console,
- 'VNC Console feature is disabled')
- @test.attr(type='gate')
- def test_get_vnc_console(self):
- # Get the VNC console
- console_types = ['novnc', 'xvpvnc']
- for console_type in console_types:
- resp, body = self.servers_client.get_vnc_console(self.server_id,
- console_type)
- self.assertEqual(
- 200, resp.status,
- "Failed to get Console Type: %s" % (console_type))
- self.assertEqual(console_type, body['type'])
- self.assertNotEqual('', body['url'])
- self._validate_url(body['url'])
-
- @testtools.skipUnless(CONF.compute_feature_enabled.spice_console,
- 'Spice Console feature is disabled.')
- @test.attr(type='gate')
- def test_get_spice_console(self):
- # Get the Spice console of type "spice-html5"
- console_type = 'spice-html5'
- resp, body = self.servers_client.get_spice_console(self.server_id,
- console_type)
- self.assertEqual(200, resp.status)
- self.assertEqual(console_type, body['type'])
- self.assertNotEqual('', body['url'])
- self._validate_url(body['url'])
-
- @testtools.skipUnless(CONF.compute_feature_enabled.rdp_console,
- 'RDP Console feature is disabled.')
- @test.attr(type='gate')
- def test_get_rdp_console(self):
- # Get the RDP console of type "rdp-html5"
- console_type = 'rdp-html5'
- resp, body = self.servers_client.get_rdp_console(self.server_id,
- console_type)
- self.assertEqual(200, resp.status)
- self.assertEqual(console_type, body['type'])
- self.assertNotEqual('', body['url'])
- self._validate_url(body['url'])
diff --git a/tempest/api/compute/v3/servers/test_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
deleted file mode 100644
index 7b41d71..0000000
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class ServerAddressesV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- # This test module might use a network and a subnet
- cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesV3Test, cls).resource_setup()
- cls.client = cls.servers_client
-
- resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
-
- @test.attr(type='smoke')
- def test_list_server_addresses(self):
- # All public and private addresses for
- # a server should be returned
-
- resp, addresses = self.client.list_addresses(self.server['id'])
- self.assertEqual('200', resp['status'])
-
- # We do not know the exact network configuration, but an instance
- # should at least have a single public or private address
- self.assertTrue(len(addresses) >= 1)
- for network_name, network_addresses in addresses.iteritems():
- self.assertTrue(len(network_addresses) >= 1)
- for address in network_addresses:
- self.assertTrue(address['addr'])
- self.assertTrue(address['version'])
-
- @test.attr(type='smoke')
- def test_list_server_addresses_by_network(self):
- # Providing a network type should filter
- # the addresses return by that type
-
- resp, addresses = self.client.list_addresses(self.server['id'])
-
- # Once again we don't know the environment's exact network config,
- # but the response for each individual network should be the same
- # as the partial result of the full address list
- id = self.server['id']
- for addr_type in addresses:
- resp, addr = self.client.list_addresses_by_network(id, addr_type)
- self.assertEqual('200', resp['status'])
-
- addr = addr[addr_type]
- for address in addresses[addr_type]:
- self.assertTrue(any([a for a in addr if a == address]))
diff --git a/tempest/api/compute/v3/servers/test_server_addresses_negative.py b/tempest/api/compute/v3/servers/test_server_addresses_negative.py
deleted file mode 100644
index 7a1b6fc..0000000
--- a/tempest/api/compute/v3/servers/test_server_addresses_negative.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class ServerAddressesV3NegativeTest(base.BaseV3ComputeTest):
- _interface = 'json'
-
- @classmethod
- def resource_setup(cls):
- # This test module might use a network and a subnet
- cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesV3NegativeTest, cls).resource_setup()
- cls.client = cls.servers_client
-
- resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
-
- @test.attr(type=['negative', 'gate'])
- def test_list_server_addresses_nonexistent_server_id(self):
- # List addresses request should fail if server id not in system
- non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.list_addresses,
- non_existent_server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_list_server_addresses_by_network_neg(self):
- # List addresses by network should fail if network name not valid
- self.assertRaises(exceptions.NotFound,
- self.client.list_addresses_by_network,
- self.server['id'], 'invalid')
diff --git a/tempest/api/compute/v3/servers/test_server_metadata.py b/tempest/api/compute/v3/servers/test_server_metadata.py
deleted file mode 100644
index ccdfbad..0000000
--- a/tempest/api/compute/v3/servers/test_server_metadata.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class ServerMetadataV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(ServerMetadataV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- cls.quotas = cls.quotas_client
- resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
- cls.server_id = server['id']
-
- def setUp(self):
- super(ServerMetadataV3Test, self).setUp()
- meta = {'key1': 'value1', 'key2': 'value2'}
- resp, _ = self.client.set_server_metadata(self.server_id, meta)
- self.assertEqual(resp.status, 200)
-
- @test.attr(type='gate')
- def test_list_server_metadata(self):
- # All metadata key/value pairs for a server should be returned
- resp, resp_metadata = self.client.list_server_metadata(self.server_id)
-
- # Verify the expected metadata items are in the list
- self.assertEqual(200, resp.status)
- expected = {'key1': 'value1', 'key2': 'value2'}
- self.assertEqual(expected, resp_metadata)
-
- @test.attr(type='gate')
- def test_set_server_metadata(self):
- # The server's metadata should be replaced with the provided values
- # Create a new set of metadata for the server
- req_metadata = {'meta2': 'data2', 'meta3': 'data3'}
- resp, metadata = self.client.set_server_metadata(self.server_id,
- req_metadata)
- self.assertEqual(200, resp.status)
-
- # Verify the expected values are correct, and that the
- # previous values have been removed
- resp, resp_metadata = self.client.list_server_metadata(self.server_id)
- self.assertEqual(resp_metadata, req_metadata)
-
- @test.attr(type='gate')
- def test_update_server_metadata(self):
- # The server's metadata values should be updated to the
- # provided values
- meta = {'key1': 'alt1', 'key3': 'value3'}
- resp, metadata = self.client.update_server_metadata(self.server_id,
- meta)
- self.assertEqual(201, resp.status)
-
- # Verify the values have been updated to the proper values
- resp, resp_metadata = self.client.list_server_metadata(self.server_id)
- expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
- self.assertEqual(expected, resp_metadata)
-
- @test.attr(type='gate')
- def test_update_metadata_empty_body(self):
- # The original metadata should not be lost if empty metadata body is
- # passed
- meta = {}
- _, metadata = self.client.update_server_metadata(self.server_id, meta)
- resp, resp_metadata = self.client.list_server_metadata(self.server_id)
- expected = {'key1': 'value1', 'key2': 'value2'}
- self.assertEqual(expected, resp_metadata)
-
- @test.attr(type='gate')
- def test_get_server_metadata_item(self):
- # The value for a specific metadata key should be returned
- resp, meta = self.client.get_server_metadata_item(self.server_id,
- 'key2')
- self.assertEqual('value2', meta['key2'])
-
- @test.attr(type='gate')
- def test_set_server_metadata_item(self):
- # The item's value should be updated to the provided value
- # Update the metadata value
- meta = {'nova': 'alt'}
- resp, body = self.client.set_server_metadata_item(self.server_id,
- 'nova', meta)
- self.assertEqual(200, resp.status)
-
- # Verify the meta item's value has been updated
- resp, resp_metadata = self.client.list_server_metadata(self.server_id)
- expected = {'key1': 'value1', 'key2': 'value2', 'nova': 'alt'}
- self.assertEqual(expected, resp_metadata)
-
- @test.attr(type='gate')
- def test_delete_server_metadata_item(self):
- # The metadata value/key pair should be deleted from the server
- resp, meta = self.client.delete_server_metadata_item(self.server_id,
- 'key1')
- self.assertEqual(204, resp.status)
-
- # Verify the metadata item has been removed
- resp, resp_metadata = self.client.list_server_metadata(self.server_id)
- expected = {'key2': 'value2'}
- self.assertEqual(expected, resp_metadata)
diff --git a/tempest/api/compute/v3/servers/test_server_metadata_negative.py b/tempest/api/compute/v3/servers/test_server_metadata_negative.py
deleted file mode 100644
index 036b126..0000000
--- a/tempest/api/compute/v3/servers/test_server_metadata_negative.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest import test
-
-
-class ServerMetadataV3NegativeTest(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(ServerMetadataV3NegativeTest, cls).resource_setup()
- cls.client = cls.servers_client
- cls.quotas = cls.quotas_client
- cls.tenant_id = cls.client.tenant_id
- resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
-
- cls.server_id = server['id']
-
- @test.skip_because(bug="1273948")
- @test.attr(type=['gate', 'negative'])
- def test_server_create_metadata_key_too_long(self):
- # Attempt to start a server with a meta-data key that is > 255
- # characters
-
- # Tryset_server_metadata_item a few values
- for sz in [256, 257, 511, 1023]:
- key = "k" * sz
- meta = {key: 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- meta=meta)
-
- # no teardown - all creates should fail
-
- @test.attr(type=['negative', 'gate'])
- def test_create_server_metadata_blank_key(self):
- # Blank key should trigger an error.
- meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- meta=meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_server_metadata_non_existent_server(self):
- # GET on a non-existent server should not succeed
- non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.get_server_metadata_item,
- non_existent_server_id,
- 'test2')
-
- @test.attr(type=['negative', 'gate'])
- def test_list_server_metadata_non_existent_server(self):
- # List metadata on a non-existent server should not succeed
- non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.list_server_metadata,
- non_existent_server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_wrong_key_passed_in_body(self):
- # Raise BadRequest if key in uri does not match
- # the key passed in body.
- meta = {'testkey': 'testvalue'}
- self.assertRaises(exceptions.BadRequest,
- self.client.set_server_metadata_item,
- self.server_id, 'key', meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_set_metadata_non_existent_server(self):
- # Set metadata on a non-existent server should not succeed
- non_existent_server_id = data_utils.rand_uuid()
- meta = {'meta1': 'data1'}
- self.assertRaises(exceptions.NotFound,
- self.client.set_server_metadata,
- non_existent_server_id,
- meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_metadata_non_existent_server(self):
- # An update should not happen for a non-existent server
- non_existent_server_id = data_utils.rand_uuid()
- meta = {'key1': 'value1', 'key2': 'value2'}
- self.assertRaises(exceptions.NotFound,
- self.client.update_server_metadata,
- non_existent_server_id,
- meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_metadata_with_blank_key(self):
- # Blank key should trigger an error
- meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.client.update_server_metadata,
- self.server_id, meta=meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_metadata_non_existent_server(self):
- # Should not be able to delete metadata item from a non-existent server
- non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.delete_server_metadata_item,
- non_existent_server_id,
- 'd')
-
- @test.attr(type=['negative', 'gate'])
- def test_metadata_items_limit(self):
- # Raise a 413 OverLimit exception while exceeding metadata items limit
- # for tenant.
- _, quota_set = self.quotas.get_quota_set(self.tenant_id)
- quota_metadata = quota_set['metadata_items']
- req_metadata = {}
- for num in range(1, quota_metadata + 2):
- req_metadata['key' + str(num)] = 'val' + str(num)
- self.assertRaises(exceptions.OverLimit,
- self.client.set_server_metadata,
- self.server_id, req_metadata)
-
- # Raise a 413 OverLimit exception while exceeding metadata items limit
- # for tenant (update).
- self.assertRaises(exceptions.OverLimit,
- self.client.update_server_metadata,
- self.server_id, req_metadata)
-
- @test.attr(type=['negative', 'gate'])
- def test_set_server_metadata_blank_key(self):
- # Raise a bad request error for blank key.
- # set_server_metadata will replace all metadata with new value
- meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.client.set_server_metadata,
- self.server_id, meta=meta)
-
- @test.attr(type=['negative', 'gate'])
- def test_set_server_metadata_missing_metadata(self):
- # Raise a bad request error for a missing metadata field
- # set_server_metadata will replace all metadata with new value
- meta = {'meta1': 'data1'}
- self.assertRaises(exceptions.BadRequest,
- self.client.set_server_metadata,
- self.server_id, meta=meta, no_metadata_field=True)
diff --git a/tempest/api/compute/v3/servers/test_server_password.py b/tempest/api/compute/v3/servers/test_server_password.py
deleted file mode 100644
index bb0e310..0000000
--- a/tempest/api/compute/v3/servers/test_server_password.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class ServerPasswordV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(ServerPasswordV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- resp, cls.server = cls.create_test_server(wait_until="ACTIVE")
-
- @test.attr(type='gate')
- def test_get_server_password(self):
- resp, body = self.client.get_password(self.server['id'])
- self.assertEqual(200, resp.status)
-
- @test.attr(type='gate')
- def test_delete_server_password(self):
- resp, body = self.client.delete_password(self.server['id'])
- self.assertEqual(204, resp.status)
diff --git a/tempest/api/compute/v3/servers/test_server_rescue.py b/tempest/api/compute/v3/servers/test_server_rescue.py
deleted file mode 100644
index ae21a7e..0000000
--- a/tempest/api/compute/v3/servers/test_server_rescue.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class ServerRescueV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- if not CONF.compute_feature_enabled.rescue:
- msg = "Server rescue not available."
- raise cls.skipException(msg)
- super(ServerRescueV3Test, cls).resource_setup()
-
- # Server for positive tests
- resp, server = cls.create_test_server(wait_until='BUILD')
- cls.server_id = server['id']
- cls.password = server['admin_password']
- cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
-
- @test.attr(type='smoke')
- def test_rescue_unrescue_instance(self):
- resp, body = self.servers_client.rescue_server(
- self.server_id, admin_password=self.password)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- resp, body = self.servers_client.unrescue_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
diff --git a/tempest/api/compute/v3/servers/test_server_rescue_negative.py b/tempest/api/compute/v3/servers/test_server_rescue_negative.py
deleted file mode 100644
index db26298..0000000
--- a/tempest/api/compute/v3/servers/test_server_rescue_negative.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-import testtools
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class ServerRescueNegativeV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- if not CONF.compute_feature_enabled.rescue:
- msg = "Server rescue not available."
- raise cls.skipException(msg)
-
- super(ServerRescueNegativeV3Test, cls).resource_setup()
- cls.device = CONF.compute.volume_device_name
-
- # Create a volume and wait for it to become ready for attach
- resp, cls.volume = cls.volumes_client.create_volume(
- 1, display_name=data_utils.rand_name(cls.__name__ + '_volume'))
- cls.volumes_client.wait_for_volume_status(
- cls.volume['id'], 'available')
-
- # Server for negative tests
- resp, server = cls.create_test_server(wait_until='BUILD')
- resp, resc_server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
- cls.password = server['admin_password']
- cls.rescue_id = resc_server['id']
- cls.rescue_password = resc_server['admin_password']
-
- cls.servers_client.rescue_server(
- cls.rescue_id, admin_password=cls.rescue_password)
- cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
- cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
-
- @classmethod
- def resource_cleanup(cls):
- if hasattr(cls, 'volume'):
- cls.delete_volume(cls.volume['id'])
- super(ServerRescueNegativeV3Test, cls).resource_cleanup()
-
- def _detach(self, server_id, volume_id):
- self.servers_client.detach_volume(server_id, volume_id)
- self.volumes_client.wait_for_volume_status(volume_id,
- 'available')
-
- def _unrescue(self, server_id):
- resp, body = self.servers_client.unrescue_server(server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
- def _unpause(self, server_id):
- resp, body = self.servers_client.unpause_server(server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
-
- @testtools.skipUnless(CONF.compute_feature_enabled.pause,
- 'Pause is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_rescue_paused_instance(self):
- # Rescue a paused server
- resp, body = self.servers_client.pause_server(
- self.server_id)
- self.addCleanup(self._unpause, self.server_id)
- self.assertEqual(202, resp.status)
- self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
- self.assertRaises(exceptions.Conflict,
- self.servers_client.rescue_server,
- self.server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_rescued_vm_reboot(self):
- self.assertRaises(exceptions.Conflict, self.servers_client.reboot,
- self.rescue_id, 'HARD')
-
- @test.attr(type=['negative', 'gate'])
- def test_rescue_non_existent_server(self):
- # Rescue a non-existing server
- self.assertRaises(exceptions.NotFound,
- self.servers_client.rescue_server,
- data_utils.rand_uuid())
-
- @test.attr(type=['negative', 'gate'])
- def test_rescued_vm_rebuild(self):
- self.assertRaises(exceptions.Conflict,
- self.servers_client.rebuild,
- self.rescue_id,
- self.image_ref_alt)
-
- @test.attr(type=['negative', 'gate'])
- def test_rescued_vm_attach_volume(self):
- # Rescue the server
- self.servers_client.rescue_server(self.server_id,
- admin_password=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- self.addCleanup(self._unrescue, self.server_id)
-
- # Attach the volume to the server
- self.assertRaises(exceptions.Conflict,
- self.servers_client.attach_volume,
- self.server_id,
- self.volume['id'],
- device='/dev/%s' % self.device)
-
- @test.attr(type=['negative', 'gate'])
- def test_rescued_vm_detach_volume(self):
- # Attach the volume to the server
- self.servers_client.attach_volume(self.server_id,
- self.volume['id'],
- device='/dev/%s' % self.device)
- self.volumes_client.wait_for_volume_status(self.volume['id'], 'in-use')
-
- # Rescue the server
- self.servers_client.rescue_server(self.server_id,
- admin_password=self.password)
- self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
- # addCleanup is a LIFO queue
- self.addCleanup(self._detach, self.server_id, self.volume['id'])
- self.addCleanup(self._unrescue, self.server_id)
-
- # Detach the volume from the server expecting failure
- self.assertRaises(exceptions.Conflict,
- self.servers_client.detach_volume,
- self.server_id,
- self.volume['id'])
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
deleted file mode 100644
index e09f4a8..0000000
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-class ServersV3Test(base.BaseV3ComputeTest):
-
- @classmethod
- def resource_setup(cls):
- super(ServersV3Test, cls).resource_setup()
- cls.client = cls.servers_client
-
- def tearDown(self):
- self.clear_servers()
- super(ServersV3Test, self).tearDown()
-
- @test.attr(type='gate')
- def test_create_server_with_admin_password(self):
- # If an admin password is provided on server creation, the server's
- # root password should be set to that password.
- resp, server = self.create_test_server(admin_password='testpassword')
-
- # Verify the password is set correctly in the response
- self.assertEqual('testpassword', server['admin_password'])
-
- @test.attr(type='gate')
- def test_create_with_existing_server_name(self):
- # Creating a server with a name that already exists is allowed
-
- # TODO(sdague): clear out try, we do cleanup one layer up
- server_name = data_utils.rand_name('server')
- resp, server = self.create_test_server(name=server_name,
- wait_until='ACTIVE')
- id1 = server['id']
- resp, server = self.create_test_server(name=server_name,
- wait_until='ACTIVE')
- id2 = server['id']
- self.assertNotEqual(id1, id2, "Did not create a new server")
- resp, server = self.client.get_server(id1)
- name1 = server['name']
- resp, server = self.client.get_server(id2)
- name2 = server['name']
- self.assertEqual(name1, name2)
-
- @test.attr(type='gate')
- def test_create_specify_keypair(self):
- # Specify a keypair while creating a server
-
- key_name = data_utils.rand_name('key')
- resp, keypair = self.keypairs_client.create_keypair(key_name)
- resp, body = self.keypairs_client.list_keypairs()
- resp, server = self.create_test_server(key_name=key_name)
- self.assertEqual('202', resp['status'])
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
- resp, server = self.client.get_server(server['id'])
- self.assertEqual(key_name, server['key_name'])
-
- @test.attr(type='gate')
- def test_update_server_name(self):
- # The server name should be changed to the the provided value
- resp, server = self.create_test_server(wait_until='ACTIVE')
-
- # Update the server with a new name
- resp, server = self.client.update_server(server['id'],
- name='newname')
- self.assertEqual(200, resp.status)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
-
- # Verify the name of the server has changed
- resp, server = self.client.get_server(server['id'])
- self.assertEqual('newname', server['name'])
-
- @test.attr(type='gate')
- def test_update_access_server_address(self):
- # The server's access addresses should reflect the provided values
- resp, server = self.create_test_server(wait_until='ACTIVE')
-
- # Update the IPv4 and IPv6 access addresses
- resp, body = self.client.update_server(server['id'],
- access_ip_v4='1.1.1.1',
- access_ip_v6='::babe:202:202')
- self.assertEqual(200, resp.status)
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
-
- # Verify the access addresses have been updated
- resp, server = self.client.get_server(server['id'])
- self.assertEqual('1.1.1.1', server['os-access-ips:access_ip_v4'])
- self.assertEqual('::babe:202:202',
- server['os-access-ips:access_ip_v6'])
-
- @test.attr(type='gate')
- def test_create_server_with_ipv6_addr_only(self):
- # Create a server without an IPv4 address(only IPv6 address).
- resp, server = self.create_test_server(access_ip_v6='2001:2001::3')
- self.assertEqual('202', resp['status'])
- self.client.wait_for_server_status(server['id'], 'ACTIVE')
- resp, server = self.client.get_server(server['id'])
- self.assertEqual('2001:2001::3', server['os-access-ips:access_ip_v6'])
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
deleted file mode 100644
index 4b1fe04..0000000
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ /dev/null
@@ -1,451 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import base64
-import sys
-
-import testtools
-
-from tempest.api.compute import base
-from tempest import clients
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class ServersNegativeV3Test(base.BaseV3ComputeTest):
-
- def setUp(self):
- super(ServersNegativeV3Test, self).setUp()
- try:
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- except Exception:
- self.__class__.server_id = self.rebuild_server(self.server_id)
-
- def tearDown(self):
- self.server_check_teardown()
- super(ServersNegativeV3Test, self).tearDown()
-
- @classmethod
- def resource_setup(cls):
- super(ServersNegativeV3Test, cls).resource_setup()
- cls.client = cls.servers_client
- cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
- cls.alt_client = cls.alt_os.servers_v3_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.server_id = server['id']
-
- @test.attr(type=['negative', 'gate'])
- def test_server_name_blank(self):
- # Create a server with name parameter empty
-
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- name='')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_with_invalid_image(self):
- # Create a server with an unknown image
-
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- image_id=-1)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_with_invalid_flavor(self):
- # Create a server with an unknown flavor
-
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- flavor=-1,)
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_access_ip_v4_address(self):
- # An access IPv4 address must match a valid address pattern
-
- IPv4 = '1.1.1.1.1.1'
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server, access_ip_v4=IPv4)
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_ip_v6_address(self):
- # An access IPv6 address must match a valid address pattern
-
- IPv6 = 'notvalid'
-
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server, access_ip_v6=IPv6)
-
- @test.attr(type=['negative', 'gate'])
- def test_resize_nonexistent_server(self):
- # Resize a non-existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.resize,
- nonexistent_server, self.flavor_ref)
-
- @test.attr(type=['negative', 'gate'])
- def test_resize_server_with_non_existent_flavor(self):
- # Resize a server with non-existent flavor
- nonexistent_flavor = data_utils.rand_uuid()
- self.assertRaises(exceptions.BadRequest, self.client.resize,
- self.server_id, flavor_ref=nonexistent_flavor)
-
- @test.attr(type=['negative', 'gate'])
- def test_resize_server_with_null_flavor(self):
- # Resize a server with null flavor
- self.assertRaises(exceptions.BadRequest, self.client.resize,
- self.server_id, flavor_ref="")
-
- @test.attr(type=['negative', 'gate'])
- def test_reboot_non_existent_server(self):
- # Reboot a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.reboot,
- nonexistent_server, 'SOFT')
-
- @testtools.skipUnless(CONF.compute_feature_enabled.pause,
- 'Pause is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_pause_paused_server(self):
- # Pause a paused server.
- self.client.pause_server(self.server_id)
- self.client.wait_for_server_status(self.server_id, 'PAUSED')
- self.assertRaises(exceptions.Conflict,
- self.client.pause_server,
- self.server_id)
- self.client.unpause_server(self.server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_rebuild_reboot_deleted_server(self):
- # Rebuild and Reboot a deleted server
- _, server = self.create_test_server()
- self.client.delete_server(server['id'])
- self.client.wait_for_server_termination(server['id'])
-
- self.assertRaises(exceptions.NotFound,
- self.client.rebuild,
- server['id'], self.image_ref_alt)
- self.assertRaises(exceptions.NotFound, self.client.reboot,
- server['id'], 'SOFT')
-
- @test.attr(type=['negative', 'gate'])
- def test_rebuild_non_existent_server(self):
- # Rebuild a non existent server
- nonexistent_server = data_utils.rand_uuid()
- meta = {'rebuild': 'server'}
- new_name = data_utils.rand_name('server')
- file_contents = 'Test server rebuild.'
- personality = [{'path': '/etc/rebuild.txt',
- 'contents': base64.b64encode(file_contents)}]
- self.assertRaises(exceptions.NotFound,
- self.client.rebuild,
- nonexistent_server,
- self.image_ref_alt,
- name=new_name, meta=meta,
- personality=personality,
- adminPass='rebuild')
-
- @test.attr(type=['negative', 'gate'])
- def test_create_numeric_server_name(self):
- # Create a server with a numeric name
- server_name = 12345
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- name=server_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_server_name_length_exceeds_256(self):
- # Create a server with name length exceeding 256 characters
-
- server_name = 'a' * 256
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- name=server_name)
-
- @test.skip_because(bug="1208743")
- @test.attr(type=['negative', 'gate'])
- def test_create_with_invalid_network_uuid(self):
- # Pass invalid network uuid while creating a server
-
- networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}]
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- networks=networks)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_with_non_existent_keypair(self):
- # Pass a non-existent keypair while creating a server
-
- key_name = data_utils.rand_name('key')
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- key_name=key_name)
-
- @test.skip_because(bug="1273948")
- @test.attr(type=['negative', 'gate'])
- def test_create_server_metadata_exceeds_length_limit(self):
- # Pass really long metadata while creating a server
-
- metadata = {'a': 'b' * 260}
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- meta=metadata)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_name_of_non_existent_server(self):
- # Update name of a non-existent server
-
- server_name = data_utils.rand_name('server')
- new_name = data_utils.rand_name('server') + '_updated'
-
- self.assertRaises(exceptions.NotFound, self.client.update_server,
- server_name, name=new_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_server_set_empty_name(self):
- # Update name of the server to an empty string
-
- server_name = data_utils.rand_name('server')
- new_name = ''
-
- self.assertRaises(exceptions.BadRequest, self.client.update_server,
- server_name, name=new_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_server_of_another_tenant(self):
- # Update name of a server that belongs to another tenant
-
- new_name = self.server_id + '_new'
- self.assertRaises(exceptions.NotFound,
- self.alt_client.update_server, self.server_id,
- name=new_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_update_server_name_length_exceeds_256(self):
- # Update name of server exceed the name length limit
-
- new_name = 'a' * 256
- self.assertRaises(exceptions.BadRequest,
- self.client.update_server,
- self.server_id,
- name=new_name)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_non_existent_server(self):
- # Delete a non existent server
-
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.delete_server,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_a_server_of_another_tenant(self):
- # Delete a server that belongs to another tenant
- self.assertRaises(exceptions.NotFound,
- self.alt_client.delete_server,
- self.server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_server_pass_negative_id(self):
- # Pass an invalid string parameter to delete server
-
- self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_server_pass_id_exceeding_length_limit(self):
- # Pass a server ID that exceeds length limit to delete server
-
- self.assertRaises(exceptions.NotFound, self.client.delete_server,
- sys.maxint + 1)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_with_nonexistent_security_group(self):
- # Create a server with a nonexistent security group
-
- security_groups = [{'name': 'does_not_exist'}]
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- security_groups=security_groups)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_non_existent_server(self):
- # Get a non existent server details
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.get_server,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_stop_non_existent_server(self):
- # Stop a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.servers_client.stop,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_pause_non_existent_server(self):
- # pause a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.pause_server,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_unpause_non_existent_server(self):
- # unpause a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.unpause_server,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_unpause_server_invalid_state(self):
- # unpause an active server.
- self.assertRaises(exceptions.Conflict,
- self.client.unpause_server,
- self.server_id)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
- 'Suspend is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_suspend_non_existent_server(self):
- # suspend a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.suspend_server,
- nonexistent_server)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
- 'Suspend is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_suspend_server_invalid_state(self):
- # suspend a suspended server.
- resp, _ = self.client.suspend_server(self.server_id)
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'SUSPENDED')
- self.assertRaises(exceptions.Conflict,
- self.client.suspend_server,
- self.server_id)
- self.client.resume_server(self.server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_resume_non_existent_server(self):
- # resume a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.resume_server,
- nonexistent_server)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
- 'Suspend is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_resume_server_invalid_state(self):
- # resume an active server.
- self.assertRaises(exceptions.Conflict,
- self.client.resume_server,
- self.server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_get_console_output_of_non_existent_server(self):
- # get the console output for a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.get_console_output,
- nonexistent_server, 10)
-
- @test.attr(type=['negative', 'gate'])
- def test_force_delete_nonexistent_server_id(self):
- # force-delete a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.force_delete_server,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_force_delete_server_invalid_state(self):
- # we can only force-delete a server in 'soft-delete' state
- self.assertRaises(exceptions.Conflict,
- self.client.force_delete_server,
- self.server_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_restore_nonexistent_server_id(self):
- # restore-delete a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
- self.client.restore_soft_deleted_server,
- nonexistent_server)
-
- @test.attr(type=['negative', 'gate'])
- def test_restore_server_invalid_state(self):
- # we can only restore-delete a server in 'soft-delete' state
- self.assertRaises(exceptions.Conflict,
- self.client.restore_soft_deleted_server,
- self.server_id)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_shelve_non_existent_server(self):
- # shelve a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.shelve_server,
- nonexistent_server)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_shelve_shelved_server(self):
- # shelve a shelved server.
- resp, server = self.client.shelve_server(self.server_id)
- self.assertEqual(202, resp.status)
-
- offload_time = CONF.compute.shelved_offload_time
- if offload_time >= 0:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED_OFFLOADED',
- extra_timeout=offload_time)
- else:
- self.client.wait_for_server_status(self.server_id,
- 'SHELVED')
-
- resp, server = self.client.get_server(self.server_id)
- image_name = server['name'] + '-shelved'
- resp, images = self.images_client.image_list(name=image_name)
- self.assertEqual(1, len(images))
- self.assertEqual(image_name, images[0]['name'])
-
- self.assertRaises(exceptions.Conflict,
- self.client.shelve_server,
- self.server_id)
-
- self.client.unshelve_server(self.server_id)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_unshelve_non_existent_server(self):
- # unshelve a non existent server
- nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
- nonexistent_server)
-
- @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
- 'Shelve is not available.')
- @test.attr(type=['negative', 'gate'])
- def test_unshelve_server_invalid_state(self):
- # unshelve an active server.
- self.assertRaises(exceptions.Conflict,
- self.client.unshelve_server,
- self.server_id)
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
deleted file mode 100644
index 3c612df..0000000
--- a/tempest/api/compute/v3/test_extensions.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.api.compute import base
-from tempest import config
-from tempest.openstack.common import log as logging
-from tempest import test
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class ExtensionsV3Test(base.BaseV3ComputeTest):
-
- @test.attr(type='gate')
- def test_list_extensions(self):
- # List of all extensions
- if len(CONF.compute_feature_enabled.api_v3_extensions) == 0:
- raise self.skipException('There are not any extensions configured')
- resp, extensions = self.extensions_client.list_extensions()
- self.assertEqual(200, resp.status)
- ext = CONF.compute_feature_enabled.api_v3_extensions[0]
- if ext == 'all':
- self.assertIn('Hosts', map(lambda x: x['name'], extensions))
- elif ext:
- self.assertIn(ext, map(lambda x: x['name'], extensions))
- else:
- raise self.skipException('There are not any extensions configured')
- # Log extensions list
- extension_list = map(lambda x: x['name'], extensions)
- LOG.debug("Nova extensions: %s" % ','.join(extension_list))
-
- @test.attr(type='gate')
- def test_get_extension(self):
- # get the specified extensions
- resp, extension = self.extensions_client.get_extension('servers')
- self.assertEqual(200, resp.status)
- self.assertEqual('servers', extension['alias'])
diff --git a/tempest/api/compute/v3/test_live_block_migration.py b/tempest/api/compute/v3/test_live_block_migration.py
deleted file mode 100644
index d6231b7..0000000
--- a/tempest/api/compute/v3/test_live_block_migration.py
+++ /dev/null
@@ -1,132 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import testtools
-
-from tempest.api.compute import base
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class LiveBlockMigrationV3Test(base.BaseV3ComputeAdminTest):
- _host_key = 'os-extended-server-attributes:host'
-
- @classmethod
- def resource_setup(cls):
- super(LiveBlockMigrationV3Test, cls).resource_setup()
-
- cls.admin_hosts_client = cls.hosts_admin_client
- cls.admin_servers_client = cls.servers_admin_client
-
- cls.created_server_ids = []
-
- def _get_compute_hostnames(self):
- _resp, body = self.admin_hosts_client.list_hosts()
- return [
- host_record['host_name']
- for host_record in body
- if host_record['service'] == 'compute'
- ]
-
- def _get_server_details(self, server_id):
- _resp, body = self.admin_servers_client.get_server(server_id)
- return body
-
- def _get_host_for_server(self, server_id):
- return self._get_server_details(server_id)[self._host_key]
-
- def _migrate_server_to(self, server_id, dest_host):
- _resp, body = self.admin_servers_client.live_migrate_server(
- server_id, dest_host,
- CONF.compute_feature_enabled.
- block_migration_for_live_migration)
- return body
-
- def _get_host_other_than(self, host):
- for target_host in self._get_compute_hostnames():
- if host != target_host:
- return target_host
-
- def _get_server_status(self, server_id):
- return self._get_server_details(server_id)['status']
-
- def _get_an_active_server(self):
- for server_id in self.created_server_ids:
- if 'ACTIVE' == self._get_server_status(server_id):
- return server_id
- else:
- _, server = self.create_test_server(wait_until="ACTIVE")
- server_id = server['id']
- self.password = server['admin_password']
- self.password = 'password'
- self.created_server_ids.append(server_id)
- return server_id
-
- def _volume_clean_up(self, server_id, volume_id):
- resp, body = self.volumes_client.get_volume(volume_id)
- if body['status'] == 'in-use':
- self.servers_client.detach_volume(server_id, volume_id)
- self.volumes_client.wait_for_volume_status(volume_id, 'available')
- self.volumes_client.delete_volume(volume_id)
-
- @testtools.skipIf(not CONF.compute_feature_enabled.live_migration,
- 'Live migration not available')
- @test.attr(type='gate')
- def test_live_block_migration(self):
- # Live block migrate an instance to another host
- if len(self._get_compute_hostnames()) < 2:
- raise self.skipTest(
- "Less than 2 compute nodes, skipping migration test.")
- server_id = self._get_an_active_server()
- actual_host = self._get_host_for_server(server_id)
- target_host = self._get_host_other_than(actual_host)
- self._migrate_server_to(server_id, target_host)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
- self.assertEqual(target_host, self._get_host_for_server(server_id))
-
- @testtools.skipIf(not CONF.compute_feature_enabled.live_migration or not
- CONF.compute_feature_enabled.
- block_migration_for_live_migration,
- 'Block Live migration not available')
- @testtools.skipIf(not CONF.compute_feature_enabled.
- block_migrate_cinder_iscsi,
- 'Block Live migration not configured for iSCSI')
- @test.attr(type='gate')
- def test_iscsi_volume(self):
- # Live block migrate an instance to another host
- if len(self._get_compute_hostnames()) < 2:
- raise self.skipTest(
- "Less than 2 compute nodes, skipping migration test.")
- server_id = self._get_an_active_server()
- actual_host = self._get_host_for_server(server_id)
- target_host = self._get_host_other_than(actual_host)
-
- resp, volume = self.volumes_client.create_volume(1,
- display_name='test')
-
- self.volumes_client.wait_for_volume_status(volume['id'],
- 'available')
- self.addCleanup(self._volume_clean_up, server_id, volume['id'])
-
- # Attach the volume to the server
- self.servers_client.attach_volume(server_id, volume['id'],
- device='/dev/xvdb')
- self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
-
- self._migrate_server_to(server_id, target_host)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
- self.assertEqual(target_host, self._get_host_for_server(server_id))
diff --git a/tempest/api/compute/v3/test_live_block_migration_negative.py b/tempest/api/compute/v3/test_live_block_migration_negative.py
deleted file mode 100644
index 93127f3..0000000
--- a/tempest/api/compute/v3/test_live_block_migration_negative.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.api.compute import base
-from tempest.common.utils import data_utils
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class LiveBlockMigrationV3NegativeTest(base.BaseV3ComputeAdminTest):
- _host_key = 'os-extended-server-attributes:host'
-
- @classmethod
- def resource_setup(cls):
- super(LiveBlockMigrationV3NegativeTest, cls).resource_setup()
- if not CONF.compute_feature_enabled.live_migration:
- raise cls.skipException("Live migration is not enabled")
-
- cls.admin_hosts_client = cls.hosts_admin_client
- cls.admin_servers_client = cls.servers_admin_client
-
- def _migrate_server_to(self, server_id, dest_host):
- _resp, body = self.admin_servers_client.live_migrate_server(
- server_id, dest_host,
- CONF.compute_feature_enabled.
- block_migration_for_live_migration)
- return body
-
- @test.attr(type=['negative', 'gate'])
- def test_invalid_host_for_migration(self):
- # Migrating to an invalid host should not change the status
- target_host = data_utils.rand_name('host-')
- _, server = self.create_test_server(wait_until="ACTIVE")
- server_id = server['id']
- self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
- server_id, target_host)
- self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
diff --git a/tempest/api/compute/v3/test_quotas.py b/tempest/api/compute/v3/test_quotas.py
deleted file mode 100644
index f6d8b3f..0000000
--- a/tempest/api/compute/v3/test_quotas.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api.compute import base
-from tempest.common import tempest_fixtures as fixtures
-from tempest import test
-
-
-class QuotasV3Test(base.BaseV3ComputeTest):
-
- def setUp(self):
- # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
- self.useFixture(fixtures.LockFixture('compute_quotas'))
- super(QuotasV3Test, self).setUp()
-
- @classmethod
- def resource_setup(cls):
- super(QuotasV3Test, cls).resource_setup()
- cls.client = cls.quotas_client
- cls.tenant_id = cls.client.tenant_id
- cls.user_id = cls.client.user_id
- cls.default_quota_set = set(('metadata_items',
- 'ram', 'floating_ips',
- 'fixed_ips', 'key_pairs',
- 'instances', 'security_group_rules',
- 'cores', 'security_groups'))
-
- @test.attr(type='smoke')
- def test_get_quotas(self):
- # User can get the quota set for it's tenant
- expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.client.get_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
- self.assertEqual(quota_set['id'], self.tenant_id)
-
- # get the quota set using user id
- resp, quota_set = self.client.get_quota_set(self.tenant_id,
- self.user_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
- self.assertEqual(quota_set['id'], self.tenant_id)
-
- @test.attr(type='smoke')
- def test_get_default_quotas(self):
- # User can get the default quota set for it's tenant
- expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
- self.assertEqual(quota_set['id'], self.tenant_id)
-
- @test.attr(type='smoke')
- def test_compare_tenant_quotas_with_default_quotas(self):
- # Tenants are created with the default quota values
- resp, defualt_quota_set = \
- self.client.get_default_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
- resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(defualt_quota_set, tenant_quota_set)
diff --git a/tempest/api/compute/v3/test_version.py b/tempest/api/compute/v3/test_version.py
deleted file mode 100644
index 1a74e35..0000000
--- a/tempest/api/compute/v3/test_version.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2014 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.api.compute import base
-from tempest import test
-
-
-class VersionV3Test(base.BaseV3ComputeTest):
-
- @test.attr(type='gate')
- def test_version(self):
- # Get version information
- resp, version = self.version_client.get_version()
- self.assertEqual(200, resp.status)
- self.assertIn("id", version)
- self.assertEqual("v3.0", version["id"])
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 75f9795..1d22fbd 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -111,7 +111,6 @@
partitions = linux_client.get_partitions()
self.assertNotIn(self.device, partitions)
- @test.skip_because(bug="1323591", interface="xml")
@test.attr(type='gate')
def test_list_get_volume_attachments(self):
# Create Server, Volume and attach that Volume to Server
@@ -129,7 +128,3 @@
self.assertEqual(self.server['id'], body['serverId'])
self.assertEqual(self.volume['id'], body['volumeId'])
self.assertEqual(self.attachment['id'], body['id'])
-
-
-class AttachVolumeTestXML(AttachVolumeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index 4f77fa7..d441427 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -71,7 +71,3 @@
matchers.ContainsAll(metadata.items()),
'The fetched Volume metadata misses data '
'from the created Volume')
-
-
-class VolumesGetTestXML(VolumesGetTestJSON):
- _interface = "xml"
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index dc54c67..6bf9519 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -165,7 +165,3 @@
all_vol_list[index + params['offset']]['id'],
"Failed to list volume details by "
"offset and limit")
-
-
-class VolumesTestXML(VolumesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index ad94ea7..f0f9879 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -98,7 +98,3 @@
def test_delete_volume_without_passing_volume_id(self):
# Negative: Should not be able to delete volume when empty ID is passed
self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
-
-
-class VolumesNegativeTestXML(VolumesNegativeTest):
- _interface = "xml"
diff --git a/tempest/api/identity/admin/test_roles.py b/tempest/api/identity/admin/test_roles.py
index d87d5c1..fabc0ed 100644
--- a/tempest/api/identity/admin/test_roles.py
+++ b/tempest/api/identity/admin/test_roles.py
@@ -105,7 +105,3 @@
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
_, roles = self.client.list_user_roles(tenant['id'], user['id'])
self.assert_role_in_role_list(role, roles)
-
-
-class RolesTestXML(RolesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index 37a981e..d0eb334 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -223,7 +223,3 @@
user['id'])
finally:
self.client.auth_provider.clear_auth()
-
-
-class RolesTestXML(RolesNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_services.py b/tempest/api/identity/admin/test_services.py
index a9782a9..b8f09ad 100644
--- a/tempest/api/identity/admin/test_services.py
+++ b/tempest/api/identity/admin/test_services.py
@@ -98,7 +98,3 @@
_, body = self.client.list_services()
found = [serv for serv in body if serv['id'] in service_ids]
self.assertEqual(len(found), len(services), 'Services not found')
-
-
-class ServicesTestXML(ServicesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_tenant_negative.py b/tempest/api/identity/admin/test_tenant_negative.py
index dcfacee..57a2fec 100644
--- a/tempest/api/identity/admin/test_tenant_negative.py
+++ b/tempest/api/identity/admin/test_tenant_negative.py
@@ -135,7 +135,3 @@
self.assertRaises(exceptions.Unauthorized, self.client.update_tenant,
tenant['id'])
self.client.auth_provider.clear_auth()
-
-
-class TenantsNegativeTestXML(TenantsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_tenants.py b/tempest/api/identity/admin/test_tenants.py
index 8d3b402..778bd5c 100644
--- a/tempest/api/identity/admin/test_tenants.py
+++ b/tempest/api/identity/admin/test_tenants.py
@@ -178,7 +178,3 @@
self.client.delete_tenant(t_id)
self.data.tenants.remove(tenant)
-
-
-class TenantsTestXML(TenantsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_tokens.py b/tempest/api/identity/admin/test_tokens.py
index 2c5fb74..bfdc7d6 100644
--- a/tempest/api/identity/admin/test_tokens.py
+++ b/tempest/api/identity/admin/test_tokens.py
@@ -104,7 +104,3 @@
# Use the unscoped token to get a token scoped to tenant2
_, body = self.token_client.auth_token(token_id,
tenant=tenant2_name)
-
-
-class TokensTestXML(TokensTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 66a1737..84a8103 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -206,7 +206,3 @@
_, body = self.token_client.auth(self.data.test_user, new_pass,
self.data.test_tenant)
self.assertTrue('id' in body['token'])
-
-
-class UsersTestXML(UsersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index bad2b89..c039da6 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -227,7 +227,3 @@
for invalid in invalid_id:
self.assertRaises(exceptions.NotFound,
self.client.list_users_for_tenant, invalid)
-
-
-class UsersNegativeTestXML(UsersNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 7a0edb0..9b30166 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -105,7 +105,3 @@
self.assertEqual(0, len(missing_creds),
"Failed to find cred %s in fetched list" %
', '.join(m_cred for m_cred in missing_creds))
-
-
-class CredentialsTestXML(CredentialsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_default_project_id.py b/tempest/api/identity/admin/v3/test_default_project_id.py
new file mode 100644
index 0000000..8ffd1ed
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_default_project_id.py
@@ -0,0 +1,84 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.identity import base
+from tempest import auth
+from tempest import clients
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class TestDefaultProjectId (base.BaseIdentityV3AdminTest):
+ _interface = 'json'
+
+ @classmethod
+ def resource_setup(cls):
+ cls.set_network_resources()
+ super(TestDefaultProjectId, cls).resource_setup()
+
+ def _delete_domain(self, domain_id):
+ # It is necessary to disable the domain before deleting,
+ # or else it would result in unauthorized error
+ self.client.update_domain(domain_id, enabled=False)
+ self.client.delete_domain(domain_id)
+
+ @test.attr(type='smoke')
+ def test_default_project_id(self):
+ # create a domain
+ dom_name = data_utils.rand_name('dom')
+ _, domain_body = self.client.create_domain(dom_name)
+ dom_id = domain_body['id']
+ self.addCleanup(self._delete_domain, dom_id)
+
+ # create a project in the domain
+ proj_name = data_utils.rand_name('proj')
+ _, proj_body = self.client.create_project(proj_name, domain_id=dom_id)
+ proj_id = proj_body['id']
+ self.addCleanup(self.client.delete_project, proj_id)
+ self.assertEqual(proj_body['domain_id'], dom_id,
+ "project " + proj_name +
+ "doesn't have domain id " + dom_id)
+
+ # create a user in the domain, with the previous project as his
+ # default project
+ user_name = data_utils.rand_name('user')
+ _, user_body = self.client.create_user(user_name, password=user_name,
+ domain_id=dom_id,
+ default_project_id=proj_id)
+ user_id = user_body['id']
+ self.addCleanup(self.client.delete_user, user_id)
+ self.assertEqual(user_body['domain_id'], dom_id,
+ "user " + user_name +
+ "doesn't have domain id " + dom_id)
+
+ # get roles and find the admin role
+ admin_role = self.get_role_by_name("admin")
+ admin_role_id = admin_role['id']
+
+ # grant the admin role to the user on his project
+ self.client.assign_user_role_on_project(proj_id, user_id,
+ admin_role_id)
+
+ # create a new client with user's credentials (NOTE: unscoped token!)
+ creds = auth.KeystoneV3Credentials(username=user_name,
+ password=user_name,
+ domain_name=dom_name)
+ auth_provider = auth.KeystoneV3AuthProvider(creds)
+ creds = auth_provider.fill_credentials()
+ admin_client = clients.Manager(interface=self._interface,
+ credentials=creds)
+
+ # verify the user's token and see that it is scoped to the project
+ token, auth_data = admin_client.auth_provider.get_auth()
+ _, result = admin_client.identity_v3_client.get_token(token)
+ self.assertEqual(result['project']['domain']['id'], dom_id)
+ self.assertEqual(result['project']['id'], proj_id)
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index 5b73df1..286ef97 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -85,7 +85,3 @@
self.assertEqual(new_name, fetched_domain['name'])
self.assertEqual(new_desc, fetched_domain['description'])
self.assertEqual('true', str(fetched_domain['enabled']).lower())
-
-
-class DomainsTestXML(DomainsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index 676f101..6044d2b 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -122,7 +122,3 @@
self.assertEqual(url2, endpoint['url'])
self.assertEqual(region2, endpoint['region'])
self.assertEqual('false', str(endpoint['enabled']).lower())
-
-
-class EndPointsTestXML(EndPointsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index b987d12..4308d44 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -88,7 +88,3 @@
def test_update_with_enabled_True(self):
# Enabled should be a boolean, not a string like 'True'
self._assert_update_raises_bad_request('True')
-
-
-class EndpointsNegativeTestXML(EndpointsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index 987a9d5..3f2069d 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -91,7 +91,3 @@
_, user_groups = self.client.list_user_groups(user['id'])
self.assertEqual(sorted(groups), sorted(user_groups))
self.assertEqual(2, len(user_groups))
-
-
-class GroupsV3TestXML(GroupsV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py
index be06c7f..2065de3 100644
--- a/tempest/api/identity/admin/v3/test_list_projects.py
+++ b/tempest/api/identity/admin/v3/test_list_projects.py
@@ -67,7 +67,3 @@
resp, body = self.client.list_projects(params)
self.assertIn(self.p1[key], map(lambda x: x[key], body))
self.assertNotIn(self.p2[key], map(lambda x: x[key], body))
-
-
-class ListProjectsTestXML(ListProjectsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index 903ad5c..70c8ec6 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -94,7 +94,3 @@
self.assertEqual(self.data.v3_users[0]['name'], user['name'])
self.assertEqual(self.alt_email, user['email'])
self.assertEqual(self.data.domain['id'], user['domain_id'])
-
-
-class UsersV3TestXML(UsersV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 65c5230..23df13d 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -32,13 +32,13 @@
for _ in range(3):
blob = data_utils.rand_name('BlobName-')
policy_type = data_utils.rand_name('PolicyType-')
- resp, policy = self.policy_client.create_policy(blob,
- policy_type)
+ policy = self.policy_client.create_policy(blob,
+ policy_type)
# Delete the Policy at the end of this method
self.addCleanup(self._delete_policy, policy['id'])
policy_ids.append(policy['id'])
# List and Verify Policies
- _, body = self.policy_client.list_policies()
+ body = self.policy_client.list_policies()
for p in body:
fetched_ids.append(p['id'])
missing_pols = [p for p in policy_ids if p not in fetched_ids]
@@ -49,7 +49,7 @@
# Test to update policy
blob = data_utils.rand_name('BlobName-')
policy_type = data_utils.rand_name('PolicyType-')
- _, policy = self.policy_client.create_policy(blob, policy_type)
+ policy = self.policy_client.create_policy(blob, policy_type)
self.addCleanup(self._delete_policy, policy['id'])
self.assertIn('id', policy)
self.assertIn('type', policy)
@@ -59,18 +59,14 @@
self.assertEqual(policy_type, policy['type'])
# Update policy
update_type = data_utils.rand_name('UpdatedPolicyType-')
- _, data = self.policy_client.update_policy(
+ data = self.policy_client.update_policy(
policy['id'], type=update_type)
self.assertIn('type', data)
# Assertion for updated value with fetched value
- _, fetched_policy = self.policy_client.get_policy(policy['id'])
+ fetched_policy = self.policy_client.get_policy(policy['id'])
self.assertIn('id', fetched_policy)
self.assertIn('blob', fetched_policy)
self.assertIn('type', fetched_policy)
self.assertEqual(fetched_policy['id'], policy['id'])
self.assertEqual(fetched_policy['blob'], policy['blob'])
self.assertEqual(update_type, fetched_policy['type'])
-
-
-class PoliciesTestXML(PoliciesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index 5890eab..e7fd2b5 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -176,7 +176,3 @@
self.assertEqual(project['id'],
new_user_get['project_id'])
self.assertEqual(u_email, new_user_get['email'])
-
-
-class ProjectsTestXML(ProjectsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py
index 9e8f613..da35ace 100644
--- a/tempest/api/identity/admin/v3/test_projects_negative.py
+++ b/tempest/api/identity/admin/v3/test_projects_negative.py
@@ -74,7 +74,3 @@
# Attempt to delete a non existent project should fail
self.assertRaises(exceptions.NotFound, self.client.delete_project,
data_utils.rand_uuid_hex())
-
-
-class ProjectsNegativeTestXML(ProjectsNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index c5d5824..4305060 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -89,7 +89,3 @@
self.assertEqual(0, len(missing_regions),
"Failed to find region %s in fetched list" %
', '.join(str(e) for e in missing_regions))
-
-
-class RegionsTestXML(RegionsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index 5e14a04..3c0a180 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -173,7 +173,3 @@
_, body = self.client.list_roles()
found = [role for role in body if role in self.data.v3_roles]
self.assertEqual(len(found), len(self.data.v3_roles))
-
-
-class RolesV3TestXML(RolesV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index 7e21cc3..a871f17 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -91,7 +91,3 @@
fetched_ids = [service['id'] for service in services]
found = [s for s in fetched_ids if s in service_ids]
self.assertEqual(len(found), len(service_ids))
-
-
-class ServicesTestXML(ServicesTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 230e09f..aef8239 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -145,7 +145,3 @@
token_auth['token']['project']['id'])
self.assertEqual(project2['name'],
token_auth['token']['project']['name'])
-
-
-class TokensV3TestXML(TokensV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 898bcd0..1b003c3 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -144,7 +144,3 @@
self.data.setup_test_v3_user()
_, user = self.client.get_user(self.data.v3_user['id'])
self.assertEqual(self.data.v3_user['id'], user['id'])
-
-
-class UsersV3TestXML(UsersV3TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 244323e..1e4973b 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -31,9 +31,6 @@
@classmethod
def resource_setup(cls):
super(BaseIdentityAdminTest, cls).resource_setup()
- if getattr(cls, '_interface', None) == 'xml':
- if not CONF.identity_feature_enabled.xml_api:
- raise cls.skipException('XML API is not enabled')
cls.os_adm = clients.AdminManager(interface=cls._interface)
cls.os = clients.Manager(interface=cls._interface)
diff --git a/tempest/api/identity/test_extension.py b/tempest/api/identity/test_extension.py
index a06ee53..829628a 100644
--- a/tempest/api/identity/test_extension.py
+++ b/tempest/api/identity/test_extension.py
@@ -30,7 +30,3 @@
for value in body:
for key in keys:
self.assertIn(key, value)
-
-
-class ExtensionTestXML(ExtensionTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 74baba6..76b6f17 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -15,7 +15,7 @@
import cStringIO as StringIO
from tempest import clients
-from tempest.common import isolated_creds
+from tempest.common import credentials
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -36,7 +36,7 @@
super(BaseImageTest, cls).resource_setup()
cls.created_images = []
cls._interface = 'json'
- cls.isolated_creds = isolated_creds.IsolatedCreds(
+ cls.isolated_creds = credentials.get_isolated_credentials(
cls.__name__, network_resources=cls.network_resources)
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index 0d27afa..53b9ddd 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -83,7 +83,3 @@
origin_agent = {'description': description}
self.admin_client.update_agent(agent_id=self.agent['id'],
agent_info=origin_agent)
-
-
-class AgentManagementTestXML(AgentManagementTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index 78f211d..a938fa6 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -93,7 +93,3 @@
network_id)
self.assertTrue(self._check_network_in_dhcp_agent(
network_id, agent))
-
-
-class DHCPAgentSchedulersTestXML(DHCPAgentSchedulersTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index 5e6d8f3..75ee217 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -118,7 +118,3 @@
(s['id'] for s in subnet_list))
# Removes subnet from the cleanup list
self.subnets.remove(subnet)
-
-
-class ExternalNetworksTestXML(ExternalNetworksTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index 46c5e76..2fe7bf8 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -63,7 +63,3 @@
self.assertNotIn(floating_ip_admin['floatingip']['id'],
floating_ip_ids)
self.assertNotIn(floating_ip_alt['id'], floating_ip_ids)
-
-
-class FloatingIPAdminTestXML(FloatingIPAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 567af24..8fccb1f 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -76,7 +76,3 @@
router['router']['id'])
# NOTE(afazekas): The deletion not asserted, because neutron
# is not forbidden to reschedule the router to the same agent
-
-
-class L3AgentSchedulerTestXML(L3AgentSchedulerTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
index 1476f30..03296a4 100644
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
@@ -69,7 +69,3 @@
_, body = self.admin_client.show_lbaas_agent_hosting_pool(
self.pool['id'])
self.assertEqual('Loadbalancer agent', body['agent']['agent_type'])
-
-
-class LBaaSAgentSchedulerTestXML(LBaaSAgentSchedulerTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
index 6d115e8..15d06e3 100644
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ b/tempest/api/network/admin/test_load_balancer_admin_actions.py
@@ -109,7 +109,3 @@
self.addCleanup(self.admin_client.delete_member, member['id'])
self.assertIsNotNone(member['id'])
self.assertEqual(self.tenant_id, member['tenant_id'])
-
-
-class LoadBalancerAdminTestXML(LoadBalancerAdminTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 4b5f107..b13dd22 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -62,9 +62,6 @@
super(BaseNetworkTest, cls).resource_setup()
if not CONF.service_available.neutron:
raise cls.skipException("Neutron support is required")
- if getattr(cls, '_interface', None) == 'xml':
- if not CONF.network_feature_enabled.xml_api:
- raise cls.skipException('XML API is not enabled')
if cls._ip_version == 6 and not CONF.network_feature_enabled.ipv6:
raise cls.skipException("IPv6 Tests are disabled.")
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index a1166c8..7b7a5db 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -129,7 +129,3 @@
class AllowedAddressPairIpV6TestJSON(AllowedAddressPairTestJSON):
_ip_version = 6
-
-
-class AllowedAddressPairTestXML(AllowedAddressPairTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index 715136c..1c7feb3 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -73,7 +73,3 @@
for e in expected_alias:
if test.is_extension_enabled(e, 'network'):
self.assertIn(e, actual_alias)
-
-
-class ExtensionsTestXML(ExtensionsTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 52672ea..9beae0a 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -213,7 +213,3 @@
update_floating_ip = body['floatingip']
self.assertEqual(update_floating_ip['fixed_ip_address'],
list_ips[1])
-
-
-class FloatingIPTestXML(FloatingIPTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 8e2b7f5..0c36820 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -38,6 +38,8 @@
Update firewall policy
Insert firewall rule to policy
Remove firewall rule from policy
+ Insert firewall rule after/before rule in policy
+ Update firewall policy audited attribute
Delete firewall policy
Show firewall policy
List firewall
@@ -222,14 +224,14 @@
self.client.delete_firewall(firewall_id)
@test.attr(type='smoke')
- def test_insert_remove_firewall_rule_from_policy(self):
+ def test_firewall_rule_insertion_position_removal_rule_from_policy(self):
# Create firewall rule
resp, body = self.client.create_firewall_rule(
name=data_utils.rand_name("fw-rule"),
action="allow",
protocol="tcp")
- fw_rule_id = body['firewall_rule']['id']
- self.addCleanup(self._try_delete_rule, fw_rule_id)
+ fw_rule_id1 = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id1)
# Create firewall policy
_, body = self.client.create_firewall_policy(
name=data_utils.rand_name("fw-policy"))
@@ -238,16 +240,49 @@
# Insert rule to firewall policy
self.client.insert_firewall_rule_in_policy(
- fw_policy_id, fw_rule_id, '', '')
+ fw_policy_id, fw_rule_id1, '', '')
# Verify insertion of rule in policy
- self.assertIn(fw_rule_id, self._get_list_fw_rule_ids(fw_policy_id))
+ self.assertIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
+ # Create another firewall rule
+ _, body = self.client.create_firewall_rule(
+ name=data_utils.rand_name("fw-rule"),
+ action="allow",
+ protocol="icmp")
+ fw_rule_id2 = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id2)
+
+ # Insert rule to firewall policy after the first rule
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id2, fw_rule_id1, '')
+
+ # Verify the posiition of rule after insertion
+ _, fw_rule = self.client.show_firewall_rule(
+ fw_rule_id2)
+
+ self.assertEqual(int(fw_rule['firewall_rule']['position']), 2)
# Remove rule from the firewall policy
self.client.remove_firewall_rule_from_policy(
- fw_policy_id, fw_rule_id)
+ fw_policy_id, fw_rule_id2)
+ # Insert rule to firewall policy before the first rule
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id2, '', fw_rule_id1)
+ # Verify the posiition of rule after insertion
+ _, fw_rule = self.client.show_firewall_rule(
+ fw_rule_id2)
+ self.assertEqual(int(fw_rule['firewall_rule']['position']), 1)
+ # Remove rule from the firewall policy
+ self.client.remove_firewall_rule_from_policy(
+ fw_policy_id, fw_rule_id2)
+ # Verify removal of rule from firewall policy
+ self.assertNotIn(fw_rule_id2, self._get_list_fw_rule_ids(fw_policy_id))
+
+ # Remove rule from the firewall policy
+ self.client.remove_firewall_rule_from_policy(
+ fw_policy_id, fw_rule_id1)
# Verify removal of rule from firewall policy
- self.assertNotIn(fw_rule_id, self._get_list_fw_rule_ids(fw_policy_id))
+ self.assertNotIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
def _get_list_fw_rule_ids(self, fw_policy_id):
_, fw_policy = self.client.show_firewall_policy(
@@ -255,6 +290,26 @@
return [ruleid for ruleid in fw_policy['firewall_policy']
['firewall_rules']]
-
-class FWaaSExtensionTestXML(FWaaSExtensionTestJSON):
- _interface = 'xml'
+ def test_update_firewall_policy_audited_attribute(self):
+ # Create firewall rule
+ _, body = self.client.create_firewall_rule(
+ name=data_utils.rand_name("fw-rule"),
+ action="allow",
+ protocol="icmp")
+ fw_rule_id = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id)
+ # Create firewall policy
+ _, body = self.client.create_firewall_policy(
+ name=data_utils.rand_name('fw-policy'))
+ fw_policy_id = body['firewall_policy']['id']
+ self.addCleanup(self._try_delete_policy, fw_policy_id)
+ self.assertFalse(body['firewall_policy']['audited'])
+ # Update firewall policy audited attribute to ture
+ self.client.update_firewall_policy(fw_policy_id,
+ audited=True)
+ # Insert Firewall rule to firewall policy
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id, '', '')
+ _, body = self.client.show_firewall_policy(
+ fw_policy_id)
+ self.assertFalse(body['firewall_policy']['audited'])
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index 8b8e3b1..41294f6 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -424,7 +424,3 @@
class LoadBalancerIpV6TestJSON(LoadBalancerTestJSON):
_ip_version = 6
-
-
-class LoadBalancerTestXML(LoadBalancerTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 07ebd8c..daf9948 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -147,7 +147,3 @@
class MeteringIpV6JSON(MeteringJSON):
_ip_version = 6
-
-
-class MeteringXML(MeteringJSON):
- interface = 'xml'
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index be23a82..ccc489e 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -370,10 +370,6 @@
self.assertEmpty(subnets, "Public subnets visible")
-class NetworksTestXML(NetworksTestJSON):
- _interface = 'xml'
-
-
class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
_interface = 'json'
@@ -495,10 +491,6 @@
self.assertIn(n['id'], ports_list)
-class BulkNetworkOpsTestXML(BulkNetworkOpsTestJSON):
- _interface = 'xml'
-
-
class NetworksIpV6TestJSON(NetworksTestJSON):
_ip_version = 6
@@ -577,7 +569,3 @@
self._create_verify_delete_subnet(
ipv6_ra_mode='dhcpv6-stateless',
ipv6_address_mode='dhcpv6-stateless')
-
-
-class NetworksIpV6TestXML(NetworksIpV6TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
index 53dfc52..bc3ab68 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -52,7 +52,3 @@
non_exist_id = data_utils.rand_name('network')
self.assertRaises(exceptions.NotFound, self.client.delete_network,
non_exist_id)
-
-
-class NetworksNegativeTestXML(NetworksNegativeTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 7c5bdfe..9cd5e2e 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -66,6 +66,23 @@
self.assertEqual(updated_port['name'], new_name)
self.assertFalse(updated_port['admin_state_up'])
+ def test_create_bulk_port(self):
+ network1 = self.network
+ name = data_utils.rand_name('network-')
+ network2 = self.create_network(network_name=name)
+ network_list = [network1['id'], network2['id']]
+ port_list = [{'network_id': net_id} for net_id in network_list]
+ _, body = self.client.create_bulk_port(port_list)
+ created_ports = body['ports']
+ port1 = created_ports[0]
+ port2 = created_ports[1]
+ self.addCleanup(self._delete_port, port1['id'])
+ self.addCleanup(self._delete_port, port2['id'])
+ self.assertEqual(port1['network_id'], network1['id'])
+ self.assertEqual(port2['network_id'], network2['id'])
+ self.assertTrue(port1['admin_state_up'])
+ self.assertTrue(port2['admin_state_up'])
+
@test.attr(type='smoke')
def test_show_port(self):
# Verify the details of port
@@ -186,9 +203,22 @@
[data_utils.rand_name('secgroup'),
data_utils.rand_name('secgroup')])
-
-class PortsTestXML(PortsTestJSON):
- _interface = 'xml'
+ @test.attr(type='smoke')
+ def test_create_show_delete_port_user_defined_mac(self):
+ # Create a port for a legal mac
+ _, body = self.client.create_port(network_id=self.network['id'])
+ old_port = body['port']
+ free_mac_address = old_port['mac_address']
+ self.client.delete_port(old_port['id'])
+ # Create a new port with user defined mac
+ _, body = self.client.create_port(network_id=self.network['id'],
+ mac_address=free_mac_address)
+ self.addCleanup(self.client.delete_port, body['port']['id'])
+ port = body['port']
+ _, body = self.client.show_port(port['id'])
+ show_port = body['port']
+ self.assertEqual(free_mac_address,
+ show_port['mac_address'])
class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
@@ -267,25 +297,13 @@
show_port['binding:vif_details'])
-class PortsAdminExtendedAttrsTestXML(PortsAdminExtendedAttrsTestJSON):
- _interface = 'xml'
-
-
class PortsIpV6TestJSON(PortsTestJSON):
_ip_version = 6
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
-class PortsIpV6TestXML(PortsIpV6TestJSON):
- _interface = 'xml'
-
-
class PortsAdminExtendedAttrsIpV6TestJSON(PortsAdminExtendedAttrsTestJSON):
_ip_version = 6
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
-
-
-class PortsAdminExtendedAttrsIpV6TestXML(PortsAdminExtendedAttrsIpV6TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 2b4e60a..34650c5 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -190,11 +190,12 @@
self.assertEqual(len(list_body['ports']), 1)
gw_port = list_body['ports'][0]
fixed_ips = gw_port['fixed_ips']
- self.assertEqual(len(fixed_ips), 1)
+ self.assertGreaterEqual(len(fixed_ips), 1)
resp, public_net_body = self.admin_client.show_network(
CONF.network.public_network_id)
public_subnet_id = public_net_body['network']['subnets'][0]
- self.assertEqual(fixed_ips[0]['subnet_id'], public_subnet_id)
+ self.assertIn(public_subnet_id,
+ map(lambda x: x['subnet_id'], fixed_ips))
@test.attr(type='smoke')
def test_update_router_set_gateway(self):
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index 47f2b52..b995b1d 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -212,15 +212,25 @@
port_range_max,
remote_ip_prefix=ip_prefix)
-
-class SecGroupTestXML(SecGroupTest):
- _interface = 'xml'
+ @test.attr(type='smoke')
+ def test_create_security_group_rule_with_protocol_integer_value(self):
+ # Verify creating security group rule with the
+ # protocol as integer value
+ # arguments : "protocol": 17
+ group_create_body, _ = self._create_security_group()
+ direction = 'ingress'
+ protocol = 17
+ security_group_id = group_create_body['security_group']['id']
+ _, rule_create_body = self.client.create_security_group_rule(
+ security_group_id=security_group_id,
+ direction=direction,
+ protocol=protocol
+ )
+ sec_group_rule = rule_create_body['security_group_rule']
+ self.assertEqual(sec_group_rule['direction'], direction)
+ self.assertEqual(int(sec_group_rule['protocol']), protocol)
class SecGroupIPv6Test(SecGroupTest):
_ip_version = 6
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
-
-
-class SecGroupIPv6TestXML(SecGroupIPv6Test):
- _interface = 'xml'
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 42f7f71..b9e8666 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -138,6 +138,7 @@
# Create rule for icmp protocol with invalid ports
states = [(1, 256, 'Invalid value for ICMP code'),
+ (None, 6, 'ICMP type (port-range-min) is missing'),
(300, 1, 'Invalid value for ICMP type')]
for pmin, pmax, msg in states:
ex = self.assertRaises(
@@ -189,14 +190,6 @@
direction='ingress', ethertype=self.ethertype)
-class NegativeSecGroupTestXML(NegativeSecGroupTest):
- _interface = 'xml'
-
-
class NegativeSecGroupIPv6Test(NegativeSecGroupTest):
_ip_version = 6
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
-
-
-class NegativeSecGroupIPv6TestXML(NegativeSecGroupIPv6Test):
- _interface = 'xml'
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index 302069f..7f8b479 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -24,11 +24,8 @@
msg = "Neutron Service Type Management not enabled."
raise cls.skipException(msg)
+ @test.skip_because(bug="1400370")
@test.attr(type='smoke')
def test_service_provider_list(self):
_, body = self.client.list_service_providers()
self.assertIsInstance(body['service_providers'], list)
-
-
-class ServiceTypeManagementTestXML(ServiceTypeManagementTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 96b9804..46f10c4 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -313,7 +313,3 @@
_, body = self.client.show_ipsecpolicy(self.ipsecpolicy['id'])
ipsecpolicy = body['ipsecpolicy']
self._assertExpected(self.ipsecpolicy, ipsecpolicy)
-
-
-class VPNaaSTestXML(VPNaaSTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index 2e39cf9..7fabb7d 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -16,8 +16,8 @@
from tempest.api.identity import base
from tempest import clients
+from tempest.common import credentials
from tempest.common import custom_matchers
-from tempest.common import isolated_creds
from tempest import config
from tempest import exceptions
import tempest.test
@@ -34,7 +34,7 @@
if not CONF.service_available.swift:
skip_msg = ("%s skipped as swift is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- cls.isolated_creds = isolated_creds.IsolatedCreds(
+ cls.isolated_creds = credentials.get_isolated_credentials(
cls.__name__, network_resources=cls.network_resources)
# Get isolated creds for normal user
cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
diff --git a/tempest/api/orchestration/stacks/templates/non_empty_stack.yaml b/tempest/api/orchestration/stacks/templates/non_empty_stack.yaml
index 8690941..4f9df91 100644
--- a/tempest/api/orchestration/stacks/templates/non_empty_stack.yaml
+++ b/tempest/api/orchestration/stacks/templates/non_empty_stack.yaml
@@ -7,6 +7,8 @@
Default: not_yet
image:
Type: String
+ flavor:
+ Type: String
Resources:
fluffy:
Type: AWS::AutoScaling::LaunchConfiguration
@@ -16,7 +18,7 @@
- Stinky
Properties:
ImageId: {Ref: image}
- InstanceType: not_used
+ InstanceType: {Ref: flavor}
UserData:
Fn::Replace:
- variable_a: {Ref: trigger}
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index 759cbbe..bf6c79c 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -31,13 +31,15 @@
template = cls.read_template('non_empty_stack')
image_id = (CONF.orchestration.image_ref or
cls._create_image()['id'])
+ flavor = CONF.orchestration.instance_type
# create the stack
cls.stack_identifier = cls.create_stack(
cls.stack_name,
template,
parameters={
'trigger': 'start',
- 'image': image_id
+ 'image': image_id,
+ 'flavor': flavor
})
cls.stack_id = cls.stack_identifier.split('/')[1]
cls.resource_name = 'fluffy'
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index 42e2a2d..7267183 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -73,7 +73,3 @@
for metric in self.glance_v2_notifications:
self.await_samples(metric, query)
-
-
-class TelemetryNotificationAPITestXML(TelemetryNotificationAPITestJSON):
- _interface = 'xml'
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 02a2526..31dc09f 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -128,11 +128,3 @@
class SnapshotsActionsV1Test(SnapshotsActionsV2Test):
_api_version = 1
-
-
-class SnapshotsActionsV1TestXML(SnapshotsActionsV1Test):
- _interface = "xml"
-
- def _get_progress_alias(self):
- return '{http://docs.openstack.org/volume/ext' \
- '/extended_snapshot_attributes/api/v1}progress'
diff --git a/tempest/api/volume/admin/test_volume_hosts.py b/tempest/api/volume/admin/test_volume_hosts.py
index c92a60c..e966613 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -29,7 +29,3 @@
class VolumeHostsAdminV1TestsJSON(VolumeHostsAdminV2TestsJSON):
_api_version = 1
-
-
-class VolumeHostsAdminV1TestsXML(VolumeHostsAdminV1TestsJSON):
- _interface = 'xml'
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index 6e45b0f..50bab56 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -22,13 +22,13 @@
QUOTA_USAGE_KEYS = ['reserved', 'limit', 'in_use']
-class VolumeQuotasAdminTestJSON(base.BaseVolumeV1AdminTest):
+class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
_interface = "json"
force_tenant_isolation = True
@classmethod
def resource_setup(cls):
- super(VolumeQuotasAdminTestJSON, cls).resource_setup()
+ super(BaseVolumeQuotasAdminV2TestJSON, cls).resource_setup()
cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
@test.attr(type='gate')
@@ -115,5 +115,5 @@
self.assertEqual(volume_default, quota_set_new['volumes'])
-class VolumeQuotasAdminTestXML(VolumeQuotasAdminTestJSON):
- _interface = "xml"
+class VolumeQuotasAdminV1TestJSON(BaseVolumeQuotasAdminV2TestJSON):
+ _api_version = 1
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index 60a0adb..c367ebb 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.py
@@ -18,13 +18,13 @@
from tempest import test
-class VolumeQuotasNegativeTestJSON(base.BaseVolumeV1AdminTest):
+class BaseVolumeQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
_interface = "json"
force_tenant_isolation = True
@classmethod
def resource_setup(cls):
- super(VolumeQuotasNegativeTestJSON, cls).resource_setup()
+ super(BaseVolumeQuotasNegativeV2TestJSON, cls).resource_setup()
demo_user = cls.isolated_creds.get_primary_creds()
cls.demo_tenant_id = demo_user.tenant_id
cls.shared_quota_set = {'gigabytes': 3, 'volumes': 1, 'snapshots': 1}
@@ -78,5 +78,5 @@
self.volume['id'])
-class VolumeQuotasNegativeTestXML(VolumeQuotasNegativeTestJSON):
- _interface = "xml"
+class VolumeQuotasNegativeV1TestJSON(BaseVolumeQuotasNegativeV2TestJSON):
+ _api_version = 1
diff --git a/tempest/api/volume/admin/test_volume_services.py b/tempest/api/volume/admin/test_volume_services.py
index 7820148..fffc5cb 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -17,7 +17,7 @@
from tempest import test
-class VolumesServicesTestJSON(base.BaseVolumeV1AdminTest):
+class VolumesServicesV2TestJSON(base.BaseVolumeAdminTest):
"""
Tests Volume Services API.
volume service list requires admin privileges.
@@ -26,21 +26,20 @@
@classmethod
def resource_setup(cls):
- super(VolumesServicesTestJSON, cls).resource_setup()
- cls.client = cls.os_adm.volume_services_client
- _, cls.services = cls.client.list_services()
+ super(VolumesServicesV2TestJSON, cls).resource_setup()
+ _, cls.services = cls.admin_volume_services_client.list_services()
cls.host_name = cls.services[0]['host']
cls.binary_name = cls.services[0]['binary']
@test.attr(type='gate')
def test_list_services(self):
- _, services = self.client.list_services()
+ _, services = self.admin_volume_services_client.list_services()
self.assertNotEqual(0, len(services))
@test.attr(type='gate')
def test_get_service_by_service_binary_name(self):
params = {'binary': self.binary_name}
- _, services = self.client.list_services(params)
+ _, services = self.admin_volume_services_client.list_services(params)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(self.binary_name, service['binary'])
@@ -51,7 +50,7 @@
service['host'] == self.host_name]
params = {'host': self.host_name}
- _, services = self.client.list_services(params)
+ _, services = self.admin_volume_services_client.list_services(params)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -65,7 +64,11 @@
def test_get_service_by_service_and_host_name(self):
params = {'host': self.host_name, 'binary': self.binary_name}
- _, services = self.client.list_services(params)
+ _, services = self.admin_volume_services_client.list_services(params)
self.assertEqual(1, len(services))
self.assertEqual(self.host_name, services[0]['host'])
self.assertEqual(self.binary_name, services[0]['binary'])
+
+
+class VolumesServicesV1TestJSON(VolumesServicesV2TestJSON):
+ _api_version = 1
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index e474aa0..40af37e 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -142,7 +142,3 @@
class ExtraSpecsNegativeV1Test(ExtraSpecsNegativeV2Test):
_api_version = 1
-
-
-class ExtraSpecsNegativeV1TestXML(ExtraSpecsNegativeV1Test):
- _interface = 'xml'
diff --git a/tempest/api/volume/admin/test_volume_types_negative.py b/tempest/api/volume/admin/test_volume_types_negative.py
index 9c9913f..4144270 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -56,7 +56,3 @@
class VolumeTypesNegativeV1Test(VolumeTypesNegativeV2Test):
_api_version = 1
-
-
-class VolumeTypesNegativeV1TestXML(VolumeTypesNegativeV1Test):
- _interface = 'xml'
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 1c3e04a..8db6106 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -97,7 +97,3 @@
class VolumesActionsV1Test(VolumesActionsV2Test):
_api_version = 1
-
-
-class VolumesActionsV1TestXML(VolumesActionsV1Test):
- _interface = "xml"
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index bf014a8..1357d31 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -23,17 +23,16 @@
LOG = logging.getLogger(__name__)
-class VolumesBackupsTest(base.BaseVolumeV1AdminTest):
+class VolumesBackupsV2Test(base.BaseVolumeAdminTest):
_interface = "json"
@classmethod
def resource_setup(cls):
- super(VolumesBackupsTest, cls).resource_setup()
+ super(VolumesBackupsV2Test, cls).resource_setup()
if not CONF.volume_feature_enabled.backup:
raise cls.skipException("Cinder backup feature disabled")
- cls.backups_adm_client = cls.os_adm.backups_client
cls.volume = cls.create_volume()
@test.attr(type='smoke')
@@ -71,3 +70,7 @@
'available')
self.admin_volume_client.wait_for_volume_status(
restore['volume_id'], 'available')
+
+
+class VolumesBackupsV1Test(VolumesBackupsV2Test):
+ _api_version = 1
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index f9f03ac..52e48f3 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -145,10 +145,6 @@
pass
-class BaseVolumeV1Test(BaseVolumeTest):
- _api_version = 1
-
-
class BaseVolumeAdminTest(BaseVolumeTest):
"""Base test case class for all Volume Admin API tests."""
@classmethod
@@ -165,26 +161,32 @@
cls.qos_specs = []
- cls.quotas_client = cls.os_adm.volume_quotas_client
-
if cls._api_version == 1:
if not CONF.volume_feature_enabled.api_v1:
msg = "Volume API v1 is disabled"
raise cls.skipException(msg)
cls.volume_qos_client = cls.os_adm.volume_qos_client
+ cls.admin_volume_services_client = \
+ cls.os_adm.volume_services_client
cls.volume_types_client = cls.os_adm.volume_types_client
cls.admin_volume_client = cls.os_adm.volumes_client
cls.hosts_client = cls.os_adm.volume_hosts_client
cls.admin_snapshots_client = cls.os_adm.snapshots_client
+ cls.backups_adm_client = cls.os_adm.backups_client
+ cls.quotas_client = cls.os_adm.volume_quotas_client
elif cls._api_version == 2:
if not CONF.volume_feature_enabled.api_v2:
msg = "Volume API v2 is disabled"
raise cls.skipException(msg)
cls.volume_qos_client = cls.os_adm.volume_qos_v2_client
+ cls.admin_volume_services_client = \
+ cls.os_adm.volume_services_v2_client
cls.volume_types_client = cls.os_adm.volume_types_v2_client
cls.admin_volume_client = cls.os_adm.volumes_v2_client
cls.hosts_client = cls.os_adm.volume_hosts_v2_client
cls.admin_snapshots_client = cls.os_adm.snapshots_v2_client
+ cls.backups_adm_client = cls.os_adm.backups_v2_client
+ cls.quotas_client = cls.os_adm.volume_quotas_v2_client
@classmethod
def resource_cleanup(cls):
@@ -216,7 +218,3 @@
except exceptions.NotFound:
# The qos_specs may have already been deleted which is OK.
pass
-
-
-class BaseVolumeV1AdminTest(BaseVolumeAdminTest):
- _api_version = 1
diff --git a/tempest/api/volume/test_availability_zone.py b/tempest/api/volume/test_availability_zone.py
index 648bd8b..c3d5d02 100644
--- a/tempest/api/volume/test_availability_zone.py
+++ b/tempest/api/volume/test_availability_zone.py
@@ -35,13 +35,5 @@
self.assertTrue(len(availability_zone) > 0)
-class AvailabilityZoneV2TestXML(AvailabilityZoneV2TestJSON):
- _interface = 'xml'
-
-
class AvailabilityZoneV1TestJSON(AvailabilityZoneV2TestJSON):
_api_version = 1
-
-
-class AvailabilityZoneV1TestXML(AvailabilityZoneV1TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
index 4fc6ee4..0f6c2d6 100644
--- a/tempest/api/volume/test_extensions.py
+++ b/tempest/api/volume/test_extensions.py
@@ -39,18 +39,10 @@
if ext == 'all':
self.assertIn('Hosts', map(lambda x: x['name'], extensions))
elif ext:
- self.assertIn(ext, map(lambda x: x['name'], extensions))
+ self.assertIn(ext, map(lambda x: x['alias'], extensions))
else:
raise self.skipException('There are not any extensions configured')
-class ExtensionsV2TestXML(ExtensionsV2TestJSON):
- _interface = 'xml'
-
-
class ExtensionsV1TestJSON(ExtensionsV2TestJSON):
_api_version = 1
-
-
-class ExtensionsV1TestXML(ExtensionsV1TestJSON):
- _interface = 'xml'
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 777d3de..0dceb3d 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -98,13 +98,5 @@
self.assertEqual(expect, body)
-class SnapshotV2MetadataTestXML(SnapshotV2MetadataTestJSON):
- _interface = "xml"
-
-
class SnapshotV1MetadataTestJSON(SnapshotV2MetadataTestJSON):
_api_version = 1
-
-
-class SnapshotV1MetadataTestXML(SnapshotV1MetadataTestJSON):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
index 2ec8667..ac5d016 100644
--- a/tempest/api/volume/test_volume_metadata.py
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -99,13 +99,5 @@
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))
-class VolumesV2MetadataTestXML(VolumesV2MetadataTest):
- _interface = "xml"
-
-
class VolumesV1MetadataTest(VolumesV2MetadataTest):
_api_version = 1
-
-
-class VolumesV1MetadataTestXML(VolumesV1MetadataTest):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index fe217c1..2011c1b 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -102,13 +102,5 @@
self.client.wait_for_volume_status(volume['id'], 'available')
-class VolumesV2TransfersTestXML(VolumesV2TransfersTest):
- _interface = "xml"
-
-
class VolumesV1TransfersTest(VolumesV2TransfersTest):
_api_version = 1
-
-
-class VolumesV1TransfersTestXML(VolumesV1TransfersTest):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index a9bc70a..4fd27b1 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -142,13 +142,5 @@
self.assertEqual(False, bool_flag)
-class VolumesV2ActionsTestXML(VolumesV2ActionsTest):
- _interface = "xml"
-
-
class VolumesV1ActionsTest(VolumesV2ActionsTest):
_api_version = 1
-
-
-class VolumesV1ActionsTestXML(VolumesV1ActionsTest):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volumes_extend.py b/tempest/api/volume/test_volumes_extend.py
index edd497c..2b816ef 100644
--- a/tempest/api/volume/test_volumes_extend.py
+++ b/tempest/api/volume/test_volumes_extend.py
@@ -38,13 +38,5 @@
self.assertEqual(int(volume['size']), extend_size)
-class VolumesV2ExtendTestXML(VolumesV2ExtendTest):
- _interface = "xml"
-
-
class VolumesV1ExtendTest(VolumesV2ExtendTest):
_api_version = 1
-
-
-class VolumesV1ExtendTestXML(VolumesV1ExtendTest):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 033beb4..a9c10aa 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -149,13 +149,5 @@
self._volume_create_get_update_delete(source_volid=origin['id'])
-class VolumesV2GetTestXML(VolumesV2GetTest):
- _interface = "xml"
-
-
class VolumesV1GetTest(VolumesV2GetTest):
_api_version = 1
-
-
-class VolumesV1GetTestXML(VolumesV1GetTest):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 016e9ab..9c0d238 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -205,14 +205,6 @@
self._list_by_param_value_and_assert(params, with_detail=True)
-class VolumesV2ListTestXML(VolumesV2ListTestJSON):
- _interface = 'xml'
-
-
class VolumesV1ListTestJSON(VolumesV2ListTestJSON):
_api_version = 1
VOLUME_FIELDS = ('id', 'display_name')
-
-
-class VolumesV1ListTestXML(VolumesV1ListTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 2b43c63..5d3fdef 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -259,14 +259,6 @@
self.assertEqual(0, len(fetched_volume))
-class VolumesV2NegativeTestXML(VolumesV2NegativeTest):
- _interface = 'xml'
-
-
class VolumesV1NegativeTest(VolumesV2NegativeTest):
_api_version = 1
_name = 'display_name'
-
-
-class VolumesV1NegativeTestXML(VolumesV1NegativeTest):
- _interface = 'xml'
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 78df1df..21d0a86 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -178,13 +178,5 @@
self.clear_snapshots()
-class VolumesV2SnapshotTestXML(VolumesV2SnapshotTestJSON):
- _interface = "xml"
-
-
class VolumesV1SnapshotTestJSON(VolumesV2SnapshotTestJSON):
_api_version = 1
-
-
-class VolumesV1SnapshotTestXML(VolumesV1SnapshotTestJSON):
- _interface = "xml"
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 75a62a8..2d7b6de 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -47,13 +47,5 @@
None, display_name=s_name)
-class VolumesV2SnapshotNegativeTestXML(VolumesV2SnapshotNegativeTestJSON):
- _interface = "xml"
-
-
class VolumesV1SnapshotNegativeTestJSON(VolumesV2SnapshotNegativeTestJSON):
_api_version = 1
-
-
-class VolumesV1SnapshotNegativeTestXML(VolumesV1SnapshotNegativeTestJSON):
- _interface = "xml"
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index cc56873..c20f3d8 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -82,7 +82,3 @@
_list_details_with_multiple_params()
_list_details_with_multiple_params(sort_dir='desc')
-
-
-class VolumesV2ListTestXML(VolumesV2ListTestJSON):
- _interface = 'xml'
diff --git a/tempest/api_schema/request/compute/v3/__init__.py b/tempest/api_schema/request/compute/v3/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api_schema/request/compute/v3/__init__.py
+++ /dev/null
diff --git a/tempest/api_schema/request/compute/v3/flavors.py b/tempest/api_schema/request/compute/v3/flavors.py
deleted file mode 100644
index b913aca..0000000
--- a/tempest/api_schema/request/compute/v3/flavors.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# (c) 2014 Deutsche Telekom AG
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import copy
-
-from tempest.api_schema.request.compute import flavors
-
-flavors_details = copy.deepcopy(flavors.common_flavor_details)
-
-flavor_list = copy.deepcopy(flavors.common_flavor_list)
-
-flavor_list["json-schema"]["properties"] = {
- "min_ram": {
- "type": "integer",
- "results": {
- "gen_none": 400,
- "gen_string": 400
- }
- },
- "min_disk": {
- "type": "integer",
- "results": {
- "gen_none": 400,
- "gen_string": 400
- }
- }
-}
diff --git a/tempest/api_schema/response/compute/services.py b/tempest/api_schema/response/compute/services.py
index fc42b89..6f361ef 100644
--- a/tempest/api_schema/response/compute/services.py
+++ b/tempest/api_schema/response/compute/services.py
@@ -22,7 +22,8 @@
'items': {
'type': 'object',
'properties': {
- 'id': {'type': 'integer'},
+ 'id': {'type': ['integer', 'string'],
+ 'pattern': '^[a-zA-Z!]*@[0-9]+$'},
'zone': {'type': 'string'},
'host': {'type': 'string'},
'state': {'type': 'string'},
diff --git a/tempest/api_schema/response/compute/v3/__init__.py b/tempest/api_schema/response/compute/v3/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/api_schema/response/compute/v3/__init__.py
+++ /dev/null
diff --git a/tempest/api_schema/response/compute/v3/agents.py b/tempest/api_schema/response/compute/v3/agents.py
deleted file mode 100644
index 9ef05df..0000000
--- a/tempest/api_schema/response/compute/v3/agents.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api_schema.response.compute import agents
-
-create_agent = {
- 'status_code': [201],
- 'response_body': agents.common_create_agent
-}
-
-delete_agent = {
- 'status_code': [204]
-}
diff --git a/tempest/api_schema/response/compute/v3/aggregates.py b/tempest/api_schema/response/compute/v3/aggregates.py
deleted file mode 100644
index e3bae13..0000000
--- a/tempest/api_schema/response/compute/v3/aggregates.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import aggregates
-
-delete_aggregate = {
- 'status_code': [204]
-}
-
-create_aggregate = copy.deepcopy(aggregates.common_create_aggregate)
-# V3 API's response status_code is 201
-create_aggregate['status_code'] = [201]
-
-aggregate_add_remove_host = copy.deepcopy(aggregates.aggregate_add_remove_host)
-# V3 API's response status_code is 202
-aggregate_add_remove_host['status_code'] = [202]
diff --git a/tempest/api_schema/response/compute/v3/availability_zone.py b/tempest/api_schema/response/compute/v3/availability_zone.py
deleted file mode 100644
index dbb1d41..0000000
--- a/tempest/api_schema/response/compute/v3/availability_zone.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import availability_zone as common
-
-
-base = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'availability_zone_info': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'zone_name': {'type': 'string'},
- 'zone_state': {
- 'type': 'object',
- 'properties': {
- 'available': {'type': 'boolean'}
- },
- 'required': ['available']
- },
- # NOTE: Here is the difference between detail and
- # non-detail
- 'hosts': {'type': 'null'}
- },
- 'required': ['zone_name', 'zone_state', 'hosts']
- }
- }
- },
- 'required': ['availability_zone_info']
- }
-}
-
-get_availability_zone_list = copy.deepcopy(base)
-get_availability_zone_list_detail = copy.deepcopy(base)
-get_availability_zone_list_detail['response_body']['properties'][
- 'availability_zone_info']['items']['properties']['hosts'] = common.detail
diff --git a/tempest/api_schema/response/compute/v3/certificates.py b/tempest/api_schema/response/compute/v3/certificates.py
deleted file mode 100644
index c768391..0000000
--- a/tempest/api_schema/response/compute/v3/certificates.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import certificates
-
-create_certificate = copy.deepcopy(certificates._common_schema)
-create_certificate['status_code'] = [201]
diff --git a/tempest/api_schema/response/compute/v3/extensions.py b/tempest/api_schema/response/compute/v3/extensions.py
deleted file mode 100644
index ceb0ce2..0000000
--- a/tempest/api_schema/response/compute/v3/extensions.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-list_extensions = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'extensions': {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- 'name': {'type': 'string'},
- 'alias': {'type': 'string'},
- 'description': {'type': 'string'},
- 'version': {'type': 'integer'}
- },
- 'required': ['name', 'alias', 'description', 'version']
- }
- }
- },
- 'required': ['extensions']
- }
-}
diff --git a/tempest/api_schema/response/compute/v3/flavors.py b/tempest/api_schema/response/compute/v3/flavors.py
deleted file mode 100644
index d6c2c85..0000000
--- a/tempest/api_schema/response/compute/v3/flavors.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import flavors
-from tempest.api_schema.response.compute import flavors_extra_specs
-
-list_flavors_details = copy.deepcopy(flavors.common_flavor_list_details)
-
-# NOTE- In v3 API, 'swap' comes as '0' not empty string '""'
-# (In V2 API, it comes as empty string) So leaving 'swap'as integer type only.
-
-# Defining extra attributes for V3 flavor schema
-list_flavors_details['response_body']['properties']['flavors']['items'][
- 'properties'].update({'disabled': {'type': 'boolean'},
- 'ephemeral': {'type': 'integer'},
- 'flavor-access:is_public': {'type': 'boolean'},
- 'os-flavor-rxtx:rxtx_factor': {'type': 'number'}})
-# 'flavor-access' and 'os-flavor-rxtx' are API extensions.
-# So they are not 'required'.
-list_flavors_details['response_body']['properties']['flavors']['items'][
- 'required'].extend(['disabled', 'ephemeral'])
-
-set_flavor_extra_specs = copy.deepcopy(flavors_extra_specs.flavor_extra_specs)
-set_flavor_extra_specs['status_code'] = [201]
-
-unset_flavor_extra_specs = {
- 'status_code': [204]
-}
-
-get_flavor_details = copy.deepcopy(flavors.common_flavor_details)
-
-# NOTE- In v3 API, 'swap' comes as '0' not empty string '""'
-# (In V2 API, it comes as empty string) So leaving 'swap'as integer type only.
-
-# Defining extra attributes for V3 flavor schema
-get_flavor_details['response_body']['properties']['flavor'][
- 'properties'].update({'disabled': {'type': 'boolean'},
- 'ephemeral': {'type': 'integer'},
- 'flavor-access:is_public': {'type': 'boolean'},
- 'os-flavor-rxtx:rxtx_factor': {'type': 'number'}})
-
-# 'flavor-access' and 'os-flavor-rxtx' are API extensions.
-# So they are not 'required'.
-get_flavor_details['response_body']['properties']['flavor'][
- 'required'].extend(['disabled', 'ephemeral'])
-
-
-create_flavor_details = copy.deepcopy(get_flavor_details)
-
-# Overriding the status code for create flavor V3 API.
-create_flavor_details['status_code'] = [201]
-
-delete_flavor = {
- 'status_code': [204]
-}
diff --git a/tempest/api_schema/response/compute/v3/hosts.py b/tempest/api_schema/response/compute/v3/hosts.py
deleted file mode 100644
index f356371..0000000
--- a/tempest/api_schema/response/compute/v3/hosts.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import hosts
-
-startup_host = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'host': hosts.common_start_up_body
- },
- 'required': ['host']
- }
-}
-
-# The 'power_action' attribute of 'shutdown_host' API is 'shutdown'
-shutdown_host = copy.deepcopy(startup_host)
-
-shutdown_host['response_body']['properties']['power_action'] = {
- 'enum': ['shutdown']
-}
-
-# The 'power_action' attribute of 'reboot_host' API is 'reboot'
-reboot_host = copy.deepcopy(startup_host)
-
-reboot_host['response_body']['properties']['power_action'] = {
- 'enum': ['reboot']
-}
-
-update_host = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'host': hosts.update_host_common
- },
- 'required': ['host']
- }
-}
diff --git a/tempest/api_schema/response/compute/v3/hypervisors.py b/tempest/api_schema/response/compute/v3/hypervisors.py
deleted file mode 100644
index b36ae7e..0000000
--- a/tempest/api_schema/response/compute/v3/hypervisors.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import hypervisors
-
-
-list_hypervisors_detail = copy.deepcopy(
- hypervisors.common_list_hypervisors_detail)
-# Defining extra attributes for V3 show hypervisor schema
-list_hypervisors_detail['response_body']['properties']['hypervisors'][
- 'items']['properties']['os-pci:pci_stats'] = {'type': 'array'}
-
-show_hypervisor = copy.deepcopy(hypervisors.common_show_hypervisor)
-# Defining extra attributes for V3 show hypervisor schema
-show_hypervisor['response_body']['properties']['hypervisor']['properties'][
- 'os-pci:pci_stats'] = {'type': 'array'}
-
-hypervisors_servers = copy.deepcopy(hypervisors.common_hypervisors_info)
-
-# Defining extra attributes for V3 show hypervisor schema
-hypervisors_servers['response_body']['properties']['hypervisor']['properties'][
- 'servers'] = {
- 'type': 'array',
- 'items': {
- 'type': 'object',
- 'properties': {
- # NOTE: Now the type of 'id' is integer,
- # but here allows 'string' also because we
- # will be able to change it to 'uuid' in
- # the future.
- 'id': {'type': ['integer', 'string']},
- 'name': {'type': 'string'}
- }
- }
- }
-# V3 API response body always contains the 'servers' attribute even there
-# is no server (VM) are present on Hypervisor host.
-hypervisors_servers['response_body']['properties']['hypervisor'][
- 'required'] = ['id', 'hypervisor_hostname', 'servers']
diff --git a/tempest/api_schema/response/compute/v3/interfaces.py b/tempest/api_schema/response/compute/v3/interfaces.py
deleted file mode 100644
index 7f716ee..0000000
--- a/tempest/api_schema/response/compute/v3/interfaces.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api_schema.response.compute import interfaces as common_schema
-
-list_interfaces = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'interface_attachments': {
- 'type': 'array',
- 'items': common_schema.interface_common_info
- }
- },
- 'required': ['interface_attachments']
- }
-}
diff --git a/tempest/api_schema/response/compute/v3/keypairs.py b/tempest/api_schema/response/compute/v3/keypairs.py
deleted file mode 100644
index ea15405..0000000
--- a/tempest/api_schema/response/compute/v3/keypairs.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.api_schema.response.compute import keypairs
-
-get_keypair = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'keypair': {
- 'type': 'object',
- 'properties': {
- 'public_key': {'type': 'string'},
- 'name': {'type': 'string'},
- 'fingerprint': {'type': 'string'}
- },
- 'required': ['public_key', 'name', 'fingerprint']
- }
- },
- 'required': ['keypair']
- }
-}
-
-create_keypair = {
- 'status_code': [201],
- 'response_body': keypairs.create_keypair
-}
-
-delete_keypair = {
- 'status_code': [204],
-}
diff --git a/tempest/api_schema/response/compute/v3/quotas.py b/tempest/api_schema/response/compute/v3/quotas.py
deleted file mode 100644
index 85ed3b3..0000000
--- a/tempest/api_schema/response/compute/v3/quotas.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import quotas
-
-quota_set = copy.deepcopy(quotas.common_quota_set)
-quota_set['response_body']['properties']['quota_set']['properties'][
- 'id'] = {'type': 'string'}
-quota_set['response_body']['properties']['quota_set'][
- 'required'].extend(['id'])
-
-quota_common_info = {
- 'type': 'object',
- 'properties': {
- 'reserved': {'type': 'integer'},
- 'limit': {'type': 'integer'},
- 'in_use': {'type': 'integer'}
- },
- 'required': ['reserved', 'limit', 'in_use']
-}
-
-quota_set_detail = copy.deepcopy(quotas.common_quota_set)
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'id'] = {'type': 'string'}
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'instances'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'cores'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'ram'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'floating_ips'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'fixed_ips'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'metadata_items'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'key_pairs'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'security_groups'] = quota_common_info
-quota_set_detail['response_body']['properties']['quota_set']['properties'][
- 'security_group_rules'] = quota_common_info
-
-delete_quota = {
- 'status_code': [204]
-}
diff --git a/tempest/api_schema/response/compute/v3/servers.py b/tempest/api_schema/response/compute/v3/servers.py
deleted file mode 100644
index d0edd44..0000000
--- a/tempest/api_schema/response/compute/v3/servers.py
+++ /dev/null
@@ -1,210 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import copy
-
-from tempest.api_schema.response.compute import parameter_types
-from tempest.api_schema.response.compute import servers
-
-create_server = {
- 'status_code': [202],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'server': {
- 'type': 'object',
- 'properties': {
- 'id': {'type': 'string'},
- 'os-security-groups:security_groups': {'type': 'array'},
- 'links': parameter_types.links,
- 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4,
- 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6
- },
- # NOTE: os-access-ips:access_ip_v4/v6 are API extension,
- # and some environments return a response without these
- # attributes. So they are not 'required'.
- 'required': ['id', 'os-security-groups:security_groups',
- 'links']
- }
- },
- 'required': ['server']
- }
-}
-
-create_server_with_admin_pass = copy.deepcopy(create_server)
-create_server_with_admin_pass['response_body']['properties']['server'][
- 'properties'].update({'admin_password': {'type': 'string'}})
-create_server_with_admin_pass['response_body']['properties']['server'][
- 'required'].append('admin_password')
-
-addresses_v3 = copy.deepcopy(parameter_types.addresses)
-addresses_v3['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][
- 'properties'].update({
- 'type': {'type': 'string'},
- 'mac_addr': {'type': 'string'}
- })
-addresses_v3['patternProperties']['^[a-zA-Z0-9-_.]+$']['items'][
- 'required'].extend(['type', 'mac_addr'])
-
-update_server = copy.deepcopy(servers.base_update_get_server)
-update_server['response_body']['properties']['server']['properties'].update({
- 'addresses': addresses_v3,
- 'host_id': {'type': 'string'},
- 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4,
- 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6
-})
-update_server['response_body']['properties']['server']['required'].append(
- # NOTE: os-access-ips:access_ip_v4/v6 are API extension,
- # and some environments return a response without these
- # attributes. So they are not 'required'.
- 'host_id'
-)
-
-get_server = copy.deepcopy(servers.base_update_get_server)
-get_server['response_body']['properties']['server']['properties'].update({
- 'key_name': {'type': ['string', 'null']},
- 'host_id': {'type': 'string'},
-
- # NOTE: Non-admin users also can see "os-server-usage" and
- # "os-extended-availability-zone" attributes.
- 'os-server-usage:launched_at': {'type': ['string', 'null']},
- 'os-server-usage:terminated_at': {'type': ['string', 'null']},
- 'os-extended-availability-zone:availability_zone': {'type': 'string'},
-
- # NOTE: Admin users only can see "os-extended-status" and
- # "os-extended-server-attributes" attributes.
- 'os-extended-status:task_state': {'type': ['string', 'null']},
- 'os-extended-status:vm_state': {'type': 'string'},
- 'os-extended-status:power_state': {'type': 'integer'},
- 'os-extended-status:locked_by': {'type': ['string', 'null']},
- 'os-extended-server-attributes:host': {'type': ['string', 'null']},
- 'os-extended-server-attributes:instance_name': {'type': 'string'},
- 'os-extended-server-attributes:hypervisor_hostname': {
- 'type': ['string', 'null']
- },
- 'os-extended-volumes:volumes_attached': {'type': 'array'},
- 'os-pci:pci_devices': {'type': 'array'},
- 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4,
- 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6,
- 'os-config-drive:config_drive': {'type': 'string'}
-})
-get_server['response_body']['properties']['server']['required'].append(
- # NOTE: os-server-usage, os-extended-availability-zone,
- # os-extended-status, os-extended-server-attributes,
- # os-extended-volumes, os-pci, os-access-ips and
- # os-config-driveare API extension, and some environments
- # return a response without these attributes. So they are not 'required'.
- 'host_id'
-)
-
-attach_detach_volume = {
- 'status_code': [202]
-}
-
-set_get_server_metadata_item = copy.deepcopy(servers.set_server_metadata)
-
-list_addresses_by_network = {
- 'status_code': [200],
- 'response_body': addresses_v3
-}
-
-server_actions_change_password = copy.deepcopy(
- servers.server_actions_delete_password)
-
-list_addresses = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'addresses': addresses_v3
- },
- 'required': ['addresses']
- }
-}
-
-update_server_metadata = copy.deepcopy(servers.update_server_metadata)
-# V3 API's response status_code is 201
-update_server_metadata['status_code'] = [201]
-
-server_actions_object = copy.deepcopy(servers.common_instance_actions)
-server_actions_object['properties'].update({'server_uuid': {'type': 'string'}})
-server_actions_object['required'].extend(['server_uuid'])
-
-list_server_actions = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'server_actions': {
- 'type': 'array',
- 'items': server_actions_object
- }
- },
- 'required': ['server_actions']
- }
-}
-
-get_server_actions_object = copy.deepcopy(servers.common_get_instance_action)
-get_server_actions_object[
- 'properties'].update({'server_uuid': {'type': 'string'}})
-get_server_actions_object['required'].extend(['server_uuid'])
-
-get_server_action = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'server_action': get_server_actions_object
- },
- 'required': ['server_action']
- }
-}
-
-list_servers_detail = copy.deepcopy(servers.base_list_servers_detail)
-list_servers_detail['response_body']['properties']['servers']['items'][
- 'properties'].update({
- 'addresses': addresses_v3,
- 'host_id': {'type': 'string'},
- 'os-access-ips:access_ip_v4': parameter_types.access_ip_v4,
- 'os-access-ips:access_ip_v6': parameter_types.access_ip_v6
- })
-# NOTE(GMann): os-access-ips:access_ip_v4/v6 are API extension,
-# and some environments return a response without these
-# attributes. So they are not 'required'.
-list_servers_detail['response_body']['properties']['servers']['items'][
- 'required'].append('host_id')
-
-rebuild_server = copy.deepcopy(update_server)
-rebuild_server['status_code'] = [202]
-
-rebuild_server_with_admin_pass = copy.deepcopy(rebuild_server)
-rebuild_server_with_admin_pass['response_body']['properties']['server'][
- 'properties'].update({'admin_password': {'type': 'string'}})
-rebuild_server_with_admin_pass['response_body']['properties']['server'][
- 'required'].append('admin_password')
-
-rescue_server_with_admin_pass = {
- 'status_code': [202],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'admin_password': {'type': 'string'}
- },
- 'required': ['admin_password']
- }
-}
-
-rescue_server = copy.deepcopy(rescue_server_with_admin_pass)
-del rescue_server['response_body']['properties']
-del rescue_server['response_body']['required']
diff --git a/tempest/auth.py b/tempest/auth.py
index b1ead29..022a450 100644
--- a/tempest/auth.py
+++ b/tempest/auth.py
@@ -26,8 +26,6 @@
from tempest.openstack.common import log as logging
from tempest.services.identity.json import identity_client as json_id
from tempest.services.identity.v3.json import identity_client as json_v3id
-from tempest.services.identity.v3.xml import identity_client as xml_v3id
-from tempest.services.identity.xml import identity_client as xml_id
CONF = config.CONF
@@ -44,15 +42,14 @@
"""
:param credentials: credentials for authentication
:param interface: 'json' or 'xml'. Applicable for tempest client only
+ (deprecated: only json now supported)
"""
credentials = self._convert_credentials(credentials)
if self.check_credentials(credentials):
self.credentials = credentials
else:
raise TypeError("Invalid credentials")
- self.interface = interface
- if self.interface is None:
- self.interface = 'json'
+ self.interface = 'json'
self.cache = None
self.alt_auth_data = None
self.alt_part = None
@@ -255,10 +252,7 @@
EXPIRY_DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
def _auth_client(self):
- if self.interface == 'json':
- return json_id.TokenClientJSON()
- else:
- return xml_id.TokenClientXML()
+ return json_id.TokenClientJSON()
def _auth_params(self):
return dict(
@@ -336,10 +330,7 @@
EXPIRY_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
def _auth_client(self):
- if self.interface == 'json':
- return json_v3id.V3TokenClientJSON()
- else:
- return xml_v3id.V3TokenClientXML()
+ return json_v3id.V3TokenClientJSON()
def _auth_params(self):
return dict(
diff --git a/tempest/cli/simple_read_only/network/test_neutron.py b/tempest/cli/simple_read_only/network/test_neutron.py
index 6090882..6cf0640 100644
--- a/tempest/cli/simple_read_only/network/test_neutron.py
+++ b/tempest/cli/simple_read_only/network/test_neutron.py
@@ -198,6 +198,31 @@
'auth_mode', 'status'])
@test.attr(type='smoke')
+ @test.requires_ext(extension='fwaas', service='network')
+ def test_neutron_firewall_list(self):
+ firewall_list = self.parser.listing(self.neutron
+ ('firewall-list'))
+ self.assertTableStruct(firewall_list, ['id', 'name',
+ 'firewall_policy_id'])
+
+ @test.attr(type='smoke')
+ @test.requires_ext(extension='fwaas', service='network')
+ def test_neutron_firewall_policy_list(self):
+ firewall_policy = self.parser.listing(self.neutron
+ ('firewall-policy-list'))
+ self.assertTableStruct(firewall_policy, ['id', 'name',
+ 'firewall_rules'])
+
+ @test.attr(type='smoke')
+ @test.requires_ext(extension='fwaas', service='network')
+ def test_neutron_firewall_rule_list(self):
+ firewall_rule = self.parser.listing(self.neutron
+ ('firewall-rule-list'))
+ self.assertTableStruct(firewall_rule, ['id', 'name',
+ 'firewall_policy_id',
+ 'summary', 'enabled'])
+
+ @test.attr(type='smoke')
def test_neutron_help(self):
help_text = self.neutron('help')
lines = help_text.split('\n')
diff --git a/tempest/clients.py b/tempest/clients.py
index 9546502..261b27c 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -16,7 +16,6 @@
from tempest import auth
from tempest.common import rest_client
from tempest import config
-from tempest import exceptions
from tempest import manager
from tempest.openstack.common import log as logging
from tempest.services.baremetal.v1.client_json import BaremetalClientJSON
@@ -60,62 +59,6 @@
TenantUsagesClientJSON
from tempest.services.compute.json.volumes_extensions_client import \
VolumesExtensionsClientJSON
-from tempest.services.compute.v3.json.agents_client import AgentsV3ClientJSON
-from tempest.services.compute.v3.json.aggregates_client import \
- AggregatesV3ClientJSON
-from tempest.services.compute.v3.json.availability_zone_client import \
- AvailabilityZoneV3ClientJSON
-from tempest.services.compute.v3.json.certificates_client import \
- CertificatesV3ClientJSON
-from tempest.services.compute.v3.json.extensions_client import \
- ExtensionsV3ClientJSON
-from tempest.services.compute.v3.json.flavors_client import FlavorsV3ClientJSON
-from tempest.services.compute.v3.json.hosts_client import HostsV3ClientJSON
-from tempest.services.compute.v3.json.hypervisor_client import \
- HypervisorV3ClientJSON
-from tempest.services.compute.v3.json.interfaces_client import \
- InterfacesV3ClientJSON
-from tempest.services.compute.v3.json.keypairs_client import \
- KeyPairsV3ClientJSON
-from tempest.services.compute.v3.json.migration_client import \
- MigrationsV3ClientJSON
-from tempest.services.compute.v3.json.quotas_client import \
- QuotasV3ClientJSON
-from tempest.services.compute.v3.json.servers_client import \
- ServersV3ClientJSON
-from tempest.services.compute.v3.json.services_client import \
- ServicesV3ClientJSON
-from tempest.services.compute.v3.json.version_client import \
- VersionV3ClientJSON
-from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
-from tempest.services.compute.xml.availability_zone_client import \
- AvailabilityZoneClientXML
-from tempest.services.compute.xml.certificates_client import \
- CertificatesClientXML
-from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
-from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML
-from tempest.services.compute.xml.flavors_client import FlavorsClientXML
-from tempest.services.compute.xml.floating_ips_client import \
- FloatingIPsClientXML
-from tempest.services.compute.xml.hosts_client import HostsClientXML
-from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML
-from tempest.services.compute.xml.images_client import ImagesClientXML
-from tempest.services.compute.xml.instance_usage_audit_log_client import \
- InstanceUsagesAuditLogClientXML
-from tempest.services.compute.xml.interfaces_client import \
- InterfacesClientXML
-from tempest.services.compute.xml.keypairs_client import KeyPairsClientXML
-from tempest.services.compute.xml.limits_client import LimitsClientXML
-from tempest.services.compute.xml.quotas_client import QuotaClassesClientXML
-from tempest.services.compute.xml.quotas_client import QuotasClientXML
-from tempest.services.compute.xml.security_groups_client \
- import SecurityGroupsClientXML
-from tempest.services.compute.xml.servers_client import ServersClientXML
-from tempest.services.compute.xml.services_client import ServicesClientXML
-from tempest.services.compute.xml.tenant_usages_client import \
- TenantUsagesClientXML
-from tempest.services.compute.xml.volumes_extensions_client import \
- VolumesExtensionsClientXML
from tempest.services.data_processing.v1_1.client import DataProcessingClient
from tempest.services.database.json.flavors_client import \
DatabaseFlavorsClientJSON
@@ -134,24 +77,11 @@
from tempest.services.identity.v3.json.region_client import RegionClientJSON
from tempest.services.identity.v3.json.service_client import \
ServiceClientJSON
-from tempest.services.identity.v3.xml.credentials_client import \
- CredentialsClientXML
-from tempest.services.identity.v3.xml.endpoints_client import EndPointClientXML
-from tempest.services.identity.v3.xml.identity_client import \
- IdentityV3ClientXML
-from tempest.services.identity.v3.xml.identity_client import V3TokenClientXML
-from tempest.services.identity.v3.xml.policy_client import PolicyClientXML
-from tempest.services.identity.v3.xml.region_client import RegionClientXML
-from tempest.services.identity.v3.xml.service_client import \
- ServiceClientXML
-from tempest.services.identity.xml.identity_client import IdentityClientXML
-from tempest.services.identity.xml.identity_client import TokenClientXML
from tempest.services.image.v1.json.image_client import ImageClientJSON
from tempest.services.image.v2.json.image_client import ImageClientV2JSON
from tempest.services.messaging.json.messaging_client import \
MessagingClientJSON
from tempest.services.network.json.network_client import NetworkClientJSON
-from tempest.services.network.xml.network_client import NetworkClientXML
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.account_client import \
AccountClientCustomizedHeader
@@ -163,8 +93,6 @@
OrchestrationClient
from tempest.services.telemetry.json.telemetry_client import \
TelemetryClientJSON
-from tempest.services.telemetry.xml.telemetry_client import \
- TelemetryClientXML
from tempest.services.volume.json.admin.volume_hosts_client import \
VolumeHostsClientJSON
from tempest.services.volume.json.admin.volume_quotas_client import \
@@ -183,38 +111,21 @@
from tempest.services.volume.json.volumes_client import VolumesClientJSON
from tempest.services.volume.v2.json.admin.volume_hosts_client import \
VolumeHostsV2ClientJSON
+from tempest.services.volume.v2.json.admin.volume_quotas_client import \
+ VolumeQuotasV2Client
+from tempest.services.volume.v2.json.admin.volume_services_client import \
+ VolumesServicesV2ClientJSON
from tempest.services.volume.v2.json.admin.volume_types_client import \
VolumeTypesV2ClientJSON
from tempest.services.volume.v2.json.availability_zone_client import \
VolumeV2AvailabilityZoneClientJSON
+from tempest.services.volume.v2.json.backups_client import BackupsClientV2JSON
from tempest.services.volume.v2.json.extensions_client import \
ExtensionsV2ClientJSON as VolumeV2ExtensionClientJSON
from tempest.services.volume.v2.json.qos_client import QosSpecsV2ClientJSON
from tempest.services.volume.v2.json.snapshots_client import \
SnapshotsV2ClientJSON
from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
-from tempest.services.volume.v2.xml.availability_zone_client import \
- VolumeV2AvailabilityZoneClientXML
-from tempest.services.volume.v2.xml.extensions_client import \
- ExtensionsV2ClientXML as VolumeV2ExtensionClientXML
-from tempest.services.volume.v2.xml.snapshots_client import \
- SnapshotsV2ClientXML
-from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML
-from tempest.services.volume.xml.admin.volume_hosts_client import \
- VolumeHostsClientXML
-from tempest.services.volume.xml.admin.volume_quotas_client import \
- VolumeQuotasClientXML
-from tempest.services.volume.xml.admin.volume_services_client import \
- VolumesServicesClientXML
-from tempest.services.volume.xml.admin.volume_types_client import \
- VolumeTypesClientXML
-from tempest.services.volume.xml.availability_zone_client import \
- VolumeAvailabilityZoneClientXML
-from tempest.services.volume.xml.backups_client import BackupsClientXML
-from tempest.services.volume.xml.extensions_client import \
- ExtensionsClientXML as VolumeExtensionClientXML
-from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
-from tempest.services.volume.xml.volumes_client import VolumesClientXML
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -236,30 +147,19 @@
self._set_identity_clients(self.interface)
self._set_volume_clients(self.interface)
- if self.interface == 'xml':
- self.network_client = NetworkClientXML(self.auth_provider)
- if CONF.service_available.ceilometer:
- self.telemetry_client = TelemetryClientXML(
- self.auth_provider)
-
- elif self.interface == 'json':
- self.baremetal_client = BaremetalClientJSON(self.auth_provider)
- self.network_client = NetworkClientJSON(self.auth_provider)
- self.database_flavors_client = DatabaseFlavorsClientJSON(
+ self.baremetal_client = BaremetalClientJSON(self.auth_provider)
+ self.network_client = NetworkClientJSON(self.auth_provider)
+ self.database_flavors_client = DatabaseFlavorsClientJSON(
+ self.auth_provider)
+ self.database_versions_client = DatabaseVersionsClientJSON(
+ self.auth_provider)
+ self.messaging_client = MessagingClientJSON(self.auth_provider)
+ if CONF.service_available.ceilometer:
+ self.telemetry_client = TelemetryClientJSON(
self.auth_provider)
- self.database_versions_client = DatabaseVersionsClientJSON(
- self.auth_provider)
- self.messaging_client = MessagingClientJSON(self.auth_provider)
- if CONF.service_available.ceilometer:
- self.telemetry_client = TelemetryClientJSON(
- self.auth_provider)
- self.negative_client = rest_client.NegativeRestClient(
- self.auth_provider)
- self.negative_client.service = service
-
- else:
- msg = "Unsupported interface type `%s'" % interface
- raise exceptions.InvalidConfiguration(msg)
+ self.negative_client = rest_client.NegativeRestClient(
+ self.auth_provider)
+ self.negative_client.service = service
# TODO(andreaf) EC2 client still do their auth, v2 only
ec2_client_args = (self.credentials.username,
@@ -286,10 +186,7 @@
self.auth_provider)
def _set_compute_clients(self, type):
- if type == 'json':
- self._set_compute_json_clients()
- else:
- self._set_compute_xml_clients()
+ self._set_compute_json_clients()
# Common compute clients
self.agents_client = AgentsClientJSON(self.auth_provider)
@@ -298,94 +195,35 @@
self.security_group_default_rules_client = (
SecurityGroupDefaultRulesClientJSON(self.auth_provider))
- def _set_compute_xml_clients(self):
- self.certificates_client = CertificatesClientXML(self.auth_provider)
- self.servers_client = ServersClientXML(self.auth_provider)
- self.limits_client = LimitsClientXML(self.auth_provider)
- self.images_client = ImagesClientXML(self.auth_provider)
- self.keypairs_client = KeyPairsClientXML(self.auth_provider)
- self.quotas_client = QuotasClientXML(self.auth_provider)
- self.quota_classes_client = QuotaClassesClientXML(self.auth_provider)
- self.flavors_client = FlavorsClientXML(self.auth_provider)
- self.extensions_client = ExtensionsClientXML(self.auth_provider)
- self.volumes_extensions_client = VolumesExtensionsClientXML(
- self.auth_provider)
- self.floating_ips_client = FloatingIPsClientXML(self.auth_provider)
- self.security_groups_client = SecurityGroupsClientXML(
- self.auth_provider)
- self.interfaces_client = InterfacesClientXML(self.auth_provider)
- self.fixed_ips_client = FixedIPsClientXML(self.auth_provider)
- self.availability_zone_client = AvailabilityZoneClientXML(
- self.auth_provider)
- self.aggregates_client = AggregatesClientXML(self.auth_provider)
- self.services_client = ServicesClientXML(self.auth_provider)
- self.tenant_usages_client = TenantUsagesClientXML(self.auth_provider)
- self.hosts_client = HostsClientXML(self.auth_provider)
- self.hypervisor_client = HypervisorClientXML(self.auth_provider)
- self.instance_usages_audit_log_client = \
- InstanceUsagesAuditLogClientXML(self.auth_provider)
-
def _set_compute_json_clients(self):
self.certificates_client = CertificatesClientJSON(self.auth_provider)
- self.certificates_v3_client = CertificatesV3ClientJSON(
- self.auth_provider)
self.servers_client = ServersClientJSON(self.auth_provider)
- self.servers_v3_client = ServersV3ClientJSON(self.auth_provider)
self.limits_client = LimitsClientJSON(self.auth_provider)
self.images_client = ImagesClientJSON(self.auth_provider)
self.keypairs_client = KeyPairsClientJSON(self.auth_provider)
- self.keypairs_v3_client = KeyPairsV3ClientJSON(self.auth_provider)
self.quotas_client = QuotasClientJSON(self.auth_provider)
self.quota_classes_client = QuotaClassesClientJSON(self.auth_provider)
- self.quotas_v3_client = QuotasV3ClientJSON(self.auth_provider)
self.flavors_client = FlavorsClientJSON(self.auth_provider)
- self.flavors_v3_client = FlavorsV3ClientJSON(self.auth_provider)
self.extensions_client = ExtensionsClientJSON(self.auth_provider)
- self.extensions_v3_client = ExtensionsV3ClientJSON(self.auth_provider)
self.volumes_extensions_client = VolumesExtensionsClientJSON(
self.auth_provider)
self.floating_ips_client = FloatingIPsClientJSON(self.auth_provider)
self.security_groups_client = SecurityGroupsClientJSON(
self.auth_provider)
self.interfaces_client = InterfacesClientJSON(self.auth_provider)
- self.interfaces_v3_client = InterfacesV3ClientJSON(self.auth_provider)
self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider)
self.availability_zone_client = AvailabilityZoneClientJSON(
self.auth_provider)
- self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON(
- self.auth_provider)
- self.services_v3_client = ServicesV3ClientJSON(self.auth_provider)
- self.agents_v3_client = AgentsV3ClientJSON(self.auth_provider)
self.aggregates_client = AggregatesClientJSON(self.auth_provider)
- self.aggregates_v3_client = AggregatesV3ClientJSON(self.auth_provider)
self.services_client = ServicesClientJSON(self.auth_provider)
self.tenant_usages_client = TenantUsagesClientJSON(self.auth_provider)
- self.version_v3_client = VersionV3ClientJSON(self.auth_provider)
- self.migrations_v3_client = MigrationsV3ClientJSON(self.auth_provider)
self.hosts_client = HostsClientJSON(self.auth_provider)
- self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider)
self.hypervisor_client = HypervisorClientJSON(self.auth_provider)
- self.hypervisor_v3_client = HypervisorV3ClientJSON(self.auth_provider)
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientJSON(self.auth_provider)
def _set_identity_clients(self, type):
- if type == 'json':
- self._set_identity_json_clients()
- else:
- self._set_identity_xml_clients()
-
- def _set_identity_xml_clients(self):
- self.identity_client = IdentityClientXML(self.auth_provider)
- self.identity_v3_client = IdentityV3ClientXML(self.auth_provider)
- self.endpoints_client = EndPointClientXML(self.auth_provider)
- self.service_client = ServiceClientXML(self.auth_provider)
- self.policy_client = PolicyClientXML(self.auth_provider)
- self.region_client = RegionClientXML(self.auth_provider)
- self.token_client = TokenClientXML()
- if CONF.identity_feature_enabled.api_v3:
- self.token_v3_client = V3TokenClientXML()
- self.credentials_client = CredentialsClientXML(self.auth_provider)
+ self._set_identity_json_clients()
def _set_identity_json_clients(self):
self.identity_client = IdentityClientJSON(self.auth_provider)
@@ -400,11 +238,7 @@
self.credentials_client = CredentialsClientJSON(self.auth_provider)
def _set_volume_clients(self, type):
- if type == 'json':
- self._set_volume_json_clients()
- else:
- self._set_volume_xml_clients()
-
+ self._set_volume_json_clients()
# Common volume clients
# NOTE : As XML clients are not implemented for Qos-specs.
# So, setting the qos_client here. Once client are implemented,
@@ -413,29 +247,12 @@
self.volume_qos_client = QosSpecsClientJSON(self.auth_provider)
self.volume_qos_v2_client = QosSpecsV2ClientJSON(
self.auth_provider)
-
- def _set_volume_xml_clients(self):
- self.backups_client = BackupsClientXML(self.auth_provider)
- self.snapshots_client = SnapshotsClientXML(self.auth_provider)
- self.snapshots_v2_client = SnapshotsV2ClientXML(self.auth_provider)
- self.volumes_client = VolumesClientXML(self.auth_provider)
- self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider)
- self.volume_types_client = VolumeTypesClientXML(self.auth_provider)
- self.volume_services_client = VolumesServicesClientXML(
+ self.volume_services_v2_client = VolumesServicesV2ClientJSON(
self.auth_provider)
- self.volume_hosts_client = VolumeHostsClientXML(self.auth_provider)
- self.volume_quotas_client = VolumeQuotasClientXML(self.auth_provider)
- self.volumes_extension_client = VolumeExtensionClientXML(
- self.auth_provider)
- self.volumes_v2_extension_client = VolumeV2ExtensionClientXML(
- self.auth_provider)
- self.volume_availability_zone_client = \
- VolumeAvailabilityZoneClientXML(self.auth_provider)
- self.volume_v2_availability_zone_client = \
- VolumeV2AvailabilityZoneClientXML(self.auth_provider)
def _set_volume_json_clients(self):
self.backups_client = BackupsClientJSON(self.auth_provider)
+ self.backups_v2_client = BackupsClientV2JSON(self.auth_provider)
self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
self.snapshots_v2_client = SnapshotsV2ClientJSON(self.auth_provider)
self.volumes_client = VolumesClientJSON(self.auth_provider)
@@ -447,6 +264,7 @@
self.volume_hosts_v2_client = VolumeHostsV2ClientJSON(
self.auth_provider)
self.volume_quotas_client = VolumeQuotasClientJSON(self.auth_provider)
+ self.volume_quotas_v2_client = VolumeQuotasV2Client(self.auth_provider)
self.volumes_extension_client = VolumeExtensionClientJSON(
self.auth_provider)
self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON(
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
index a305e42..f36ef56 100755
--- a/tempest/cmd/cleanup.py
+++ b/tempest/cmd/cleanup.py
@@ -9,7 +9,7 @@
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
@@ -36,14 +36,14 @@
**NOTE**: The _tenants_to_clean array in dry-run.json lists the
tenants that cleanup will loop through and delete child objects, not
delete the tenant itself. This may differ from the tenants array as you
-can clean the tempest and alternate tempest tenants but not delete the
-tenants themselves. This is actually the default behavior.
+can clean the tempest and alternate tempest tenants but by default,
+cleanup deletes the objects in the tempest and alternate tempest tenants
+but does not delete those tenants unless the --delete-tempest-conf-objects
+flag is used to force their deletion.
**Normal mode**: running with no arguments, will query your deployment and
-build a list of objects to delete after filtering out out the objects
-found in saved_state.json and based on the
---preserve-tempest-conf-objects and
---delete-tempest-conf-objects flags.
+build a list of objects to delete after filtering out the objects found in
+saved_state.json and based on the --delete-tempest-conf-objects flag.
By default the tempest and alternate tempest users and tenants are not
deleted and the admin user specified in tempest.conf is never deleted.
@@ -84,7 +84,6 @@
# available services
self.tenant_services = cleanup_service.get_tenant_cleanup_services()
self.global_services = cleanup_service.get_global_cleanup_services()
- cleanup_service.init_conf()
def run(self):
opts = self.options
@@ -98,7 +97,7 @@
def _cleanup(self):
LOG.debug("Begin cleanup")
is_dry_run = self.options.dry_run
- is_preserve = self.options.preserve_tempest_conf_objects
+ is_preserve = not self.options.delete_tempest_conf_objects
is_save_state = False
if is_dry_run:
@@ -149,7 +148,7 @@
LOG.debug("Cleaning tenant: %s " % tenant['name'])
is_dry_run = self.options.dry_run
dry_run_data = self.dry_run_data
- is_preserve = self.options.preserve_tempest_conf_objects
+ is_preserve = not self.options.delete_tempest_conf_objects
tenant_id = tenant['id']
tenant_name = tenant['name']
tenant_data = None
@@ -194,23 +193,16 @@
dest='init_saved_state', default=False,
help="Creates JSON file: " + SAVED_STATE_JSON +
", representing the current state of your "
- "deployment, specifically objects types "
- "Tempest creates and destroys during a run. "
+ "deployment, specifically object types "
+ "tempest creates and destroys during a run. "
"You must run with this flag prior to "
- "executing cleanup.")
- parser.add_argument('--preserve-tempest-conf-objects',
- action="store_true",
- dest='preserve_tempest_conf_objects',
- default=True, help="Do not delete the "
- "tempest and alternate tempest users and "
- "tenants, so they may be used for future "
- "tempest runs. By default this is argument "
- "is true.")
+ "executing cleanup in normal mode, which is with "
+ "no arguments.")
parser.add_argument('--delete-tempest-conf-objects',
- action="store_false",
- dest='preserve_tempest_conf_objects',
+ action="store_true",
+ dest='delete_tempest_conf_objects',
default=False,
- help="Delete the tempest and "
+ help="Force deletion of the tempest and "
"alternate tempest users and tenants.")
parser.add_argument('--dry-run', action="store_true",
dest='dry_run', default=False,
@@ -291,6 +283,7 @@
def main():
+ cleanup_service.init_conf()
cleanup = Cleanup()
cleanup.run()
LOG.info('Cleanup finished!')
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 8adfbef..67843e6 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
# Copyright 2014 Dell Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -12,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest import clients
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
@@ -19,13 +22,14 @@
LOG = logging.getLogger(__name__)
CONF = config.CONF
-CONF_USERS = None
-CONF_TENANTS = None
-CONF_PUB_NETWORK = None
-CONF_PRIV_NETWORK_NAME = None
-CONF_PUB_ROUTER = None
CONF_FLAVORS = None
CONF_IMAGES = None
+CONF_NETWORKS = []
+CONF_PRIV_NETWORK_NAME = None
+CONF_PUB_NETWORK = None
+CONF_PUB_ROUTER = None
+CONF_TENANTS = None
+CONF_USERS = None
IS_CEILOMETER = None
IS_CINDER = None
@@ -36,14 +40,15 @@
def init_conf():
- global CONF_USERS
- global CONF_TENANTS
- global CONF_PUB_NETWORK
- global CONF_PRIV_NETWORK_NAME
- global CONF_PUB_ROUTER
global CONF_FLAVORS
global CONF_IMAGES
-
+ global CONF_NETWORKS
+ global CONF_PRIV_NETWORK
+ global CONF_PRIV_NETWORK_NAME
+ global CONF_PUB_NETWORK
+ global CONF_PUB_ROUTER
+ global CONF_TENANTS
+ global CONF_USERS
global IS_CEILOMETER
global IS_CINDER
global IS_GLANCE
@@ -51,17 +56,6 @@
global IS_NEUTRON
global IS_NOVA
- CONF_USERS = [CONF.identity.admin_username, CONF.identity.username,
- CONF.identity.alt_username]
- CONF_TENANTS = [CONF.identity.admin_tenant_name,
- CONF.identity.tenant_name,
- CONF.identity.alt_tenant_name]
- CONF_PUB_NETWORK = CONF.network.public_network_id
- CONF_PRIV_NETWORK_NAME = CONF.compute.fixed_network_name
- CONF_PUB_ROUTER = CONF.network.public_router_id
- CONF_FLAVORS = [CONF.compute.flavor_ref, CONF.compute.flavor_ref_alt]
- CONF_IMAGES = [CONF.compute.image_ref, CONF.compute.image_ref_alt]
-
IS_CEILOMETER = CONF.service_available.ceilometer
IS_CINDER = CONF.service_available.cinder
IS_GLANCE = CONF.service_available.glance
@@ -69,6 +63,38 @@
IS_NEUTRON = CONF.service_available.neutron
IS_NOVA = CONF.service_available.nova
+ CONF_FLAVORS = [CONF.compute.flavor_ref, CONF.compute.flavor_ref_alt]
+ CONF_IMAGES = [CONF.compute.image_ref, CONF.compute.image_ref_alt]
+ CONF_PRIV_NETWORK_NAME = CONF.compute.fixed_network_name
+ CONF_PUB_NETWORK = CONF.network.public_network_id
+ CONF_PUB_ROUTER = CONF.network.public_router_id
+ CONF_TENANTS = [CONF.identity.admin_tenant_name,
+ CONF.identity.tenant_name,
+ CONF.identity.alt_tenant_name]
+ CONF_USERS = [CONF.identity.admin_username, CONF.identity.username,
+ CONF.identity.alt_username]
+
+ if IS_NEUTRON:
+ CONF_PRIV_NETWORK = _get_priv_net_id(CONF.compute.fixed_network_name,
+ CONF.identity.tenant_name)
+ CONF_NETWORKS = [CONF_PUB_NETWORK, CONF_PRIV_NETWORK]
+
+
+def _get_priv_net_id(prv_net_name, tenant_name):
+ am = clients.AdminManager()
+ net_cl = am.network_client
+ id_cl = am.identity_client
+
+ _, networks = net_cl.list_networks()
+ tenant = id_cl.get_tenant_by_name(tenant_name)
+ t_id = tenant['id']
+ n_id = None
+ for net in networks['networks']:
+ if (net['tenant_id'] == t_id and net['name'] == prv_net_name):
+ n_id = net['id']
+ break
+ return n_id
+
class BaseService(object):
def __init__(self, kwargs):
@@ -84,11 +110,8 @@
or 'tenant_id' not in item_list[0]):
return item_list
- _filtered_list = []
- for item in item_list:
- if item['tenant_id'] == self.tenant_id:
- _filtered_list.append(item)
- return _filtered_list
+ return [item for item in item_list
+ if item['tenant_id'] == self.tenant_id]
def list(self):
pass
@@ -325,6 +348,13 @@
super(NetworkService, self).__init__(kwargs)
self.client = manager.network_client
+ def _filter_by_conf_networks(self, item_list):
+ if not item_list or not all(('network_id' in i for i in item_list)):
+ return item_list
+
+ return [item for item in item_list if item['network_id']
+ not in CONF_NETWORKS]
+
def list(self):
client = self.client
_, networks = client.list_networks()
@@ -332,8 +362,7 @@
# filter out networks declared in tempest.conf
if self.is_preserve:
networks = [network for network in networks
- if (network['name'] != CONF_PRIV_NETWORK_NAME
- and network['id'] != CONF_PUB_NETWORK)]
+ if network['id'] not in CONF_NETWORKS]
LOG.debug("List count, %s Networks" % networks)
return networks
@@ -527,7 +556,7 @@
for port in ports:
subid = port['fixed_ips'][0]['subnet_id']
client.remove_router_interface_with_subnet_id(rid, subid)
- client.delete_router(rid)
+ client.delete_router(rid)
except Exception as e:
LOG.exception("Delete Router exception: %s" % e)
pass
@@ -694,6 +723,8 @@
_, ports = client.list_ports()
ports = ports['ports']
ports = self._filter_by_tenant_id(ports)
+ if self.is_preserve:
+ ports = self._filter_by_conf_networks(ports)
LOG.debug("List count, %s Ports" % len(ports))
return ports
@@ -719,6 +750,8 @@
_, subnets = client.list_subnets()
subnets = subnets['subnets']
subnets = self._filter_by_tenant_id(subnets)
+ if self.is_preserve:
+ subnets = self._filter_by_conf_networks(subnets)
LOG.debug("List count, %s Subnets" % len(subnets))
return subnets
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index f426e4d..8707427 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -137,7 +137,6 @@
def get_extension_client(os, service):
extensions_client = {
'nova': os.extensions_client,
- 'nova_v3': os.extensions_v3_client,
'cinder': os.volumes_extension_client,
'neutron': os.network_client,
'swift': os.account_client,
@@ -151,7 +150,6 @@
def get_enabled_extensions(service):
extensions_options = {
'nova': CONF.compute_feature_enabled.api_extensions,
- 'nova_v3': CONF.compute_feature_enabled.api_v3_extensions,
'cinder': CONF.volume_feature_enabled.api_extensions,
'neutron': CONF.network_feature_enabled.api_extensions,
'swift': CONF.object_storage_feature_enabled.discoverable_apis,
@@ -165,21 +163,19 @@
def verify_extensions(os, service, results):
extensions_client = get_extension_client(os, service)
__, resp = extensions_client.list_extensions()
+ # For Nova, Cinder and Neutron we use the alias name rather than the
+ # 'name' field because the alias is considered to be the canonical
+ # name.
if isinstance(resp, dict):
- # For both Nova and Neutron we use the alias name rather than the
- # 'name' field because the alias is considered to be the canonical
- # name.
- if service in ['nova', 'nova_v3', 'neutron']:
- extensions = map(lambda x: x['alias'], resp['extensions'])
- elif service == 'swift':
+ if service == 'swift':
# Remove Swift general information from extensions list
resp.pop('swift')
extensions = resp.keys()
else:
- extensions = map(lambda x: x['name'], resp['extensions'])
+ extensions = map(lambda x: x['alias'], resp['extensions'])
else:
- extensions = map(lambda x: x['name'], resp)
+ extensions = map(lambda x: x['alias'], resp)
if not results.get(service):
results[service] = {}
extensions_opt = get_enabled_extensions(service)
@@ -201,7 +197,6 @@
update_dict = {
'swift': 'object-storage-feature-enabled',
'nova': 'compute-feature-enabled',
- 'nova_v3': 'compute-feature-enabled',
'cinder': 'volume-feature-enabled',
'neutron': 'network-feature-enabled',
}
@@ -236,9 +231,6 @@
if service == 'swift':
change_option('discoverable_apis', update_dict[service],
output_string)
- elif service == 'nova_v3':
- change_option('api_v3_extensions', update_dict[service],
- output_string)
else:
change_option('api_extensions', update_dict[service],
output_string)
@@ -343,10 +335,8 @@
os = clients.ComputeAdminManager(interface='json')
services = check_service_availability(os, update)
results = {}
- for service in ['nova', 'nova_v3', 'cinder', 'neutron', 'swift']:
- if service == 'nova_v3' and 'nova' not in services:
- continue
- elif service not in services:
+ for service in ['nova', 'cinder', 'neutron', 'swift']:
+ if service not in services:
continue
results = verify_extensions(os, service, results)
diff --git a/tempest/common/commands.py b/tempest/common/commands.py
index 6583475..e68c20e 100644
--- a/tempest/common/commands.py
+++ b/tempest/common/commands.py
@@ -19,63 +19,6 @@
LOG = logging.getLogger(__name__)
-# NOTE(afazekas):
-# These commands assumes the tempest node is the same as
-# the only one service node. all-in-one installation.
-
-
-def sudo_cmd_call(cmd):
- args = shlex.split(cmd.encode('utf-8'))
- subprocess_args = {'stdout': subprocess.PIPE,
- 'stderr': subprocess.STDOUT}
- proc = subprocess.Popen(['/usr/bin/sudo', '-n'] + args,
- **subprocess_args)
- stdout = proc.communicate()[0]
- if proc.returncode != 0:
- LOG.error(("Command {0} returned with exit status {1},"
- "output {2}").format(cmd, proc.returncode, stdout))
- return stdout
-
-
-def ip_addr_raw():
- return sudo_cmd_call("ip a")
-
-
-def ip_route_raw():
- return sudo_cmd_call("ip r")
-
-
-def ip_ns_raw():
- return sudo_cmd_call("ip netns list")
-
-
-def iptables_raw(table):
- return sudo_cmd_call("iptables --line-numbers -L -nv -t " + table)
-
-
-def ip_ns_list():
- return ip_ns_raw().split()
-
-
-def ip_ns_exec(ns, cmd):
- return sudo_cmd_call(" ".join(("ip netns exec", ns, cmd)))
-
-
-def ip_ns_addr(ns):
- return ip_ns_exec(ns, "ip a")
-
-
-def ip_ns_route(ns):
- return ip_ns_exec(ns, "ip r")
-
-
-def iptables_ns(ns, table):
- return ip_ns_exec(ns, "iptables -v -S -t " + table)
-
-
-def ovs_db_dump():
- return sudo_cmd_call("ovsdb-client dump")
-
def copy_file_to_host(file_from, dest, host, username, pkey):
dest = "%s@%s:%s" % (username, host, dest)
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
deleted file mode 100644
index 16e5ffe..0000000
--- a/tempest/common/debug.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common import commands
-from tempest import config
-from tempest.openstack.common import log as logging
-
-CONF = config.CONF
-LOG = logging.getLogger(__name__)
-
-TABLES = ['filter', 'nat', 'mangle']
-
-
-def log_ip_ns():
- if not CONF.debug.enable:
- return
- LOG.info("Host Addr:\n" + commands.ip_addr_raw())
- LOG.info("Host Route:\n" + commands.ip_route_raw())
- for table in TABLES:
- LOG.info('Host %s table:\n%s', table, commands.iptables_raw(table))
- ns_list = commands.ip_ns_list()
- LOG.info("Host ns list" + str(ns_list))
- for ns in ns_list:
- LOG.info("ns(%s) Addr:\n%s", ns, commands.ip_ns_addr(ns))
- LOG.info("ns(%s) Route:\n%s", ns, commands.ip_ns_route(ns))
- for table in TABLES:
- LOG.info('ns(%s) table(%s):\n%s', ns, table,
- commands.iptables_ns(ns, table))
-
-
-def log_ovs_db():
- if not CONF.debug.enable or not CONF.service_available.neutron:
- return
- db_dump = commands.ovs_db_dump()
- LOG.info("OVS DB:\n" + db_dump)
-
-
-def log_net_debug():
- log_ip_ns()
- log_ovs_db()
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 228e47c..1ce1e39 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -203,9 +203,8 @@
if 'overlaps with another subnet' not in str(e):
raise
else:
- e = exceptions.BuildErrorException()
- e.message = 'Available CIDR for subnet creation could not be found'
- raise e
+ message = 'Available CIDR for subnet creation could not be found'
+ raise Exception(message)
return resp_body['subnet']
def _create_router(self, router_name, tenant_id):
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 6f2e1bd..c54f698 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -21,12 +21,10 @@
import time
import jsonschema
-from lxml import etree
import six
from tempest.common import http
from tempest.common.utils import misc as misc_utils
-from tempest.common import xml_utils as common
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -35,41 +33,49 @@
# redrive rate limited calls at most twice
MAX_RECURSION_DEPTH = 2
-TOKEN_CHARS_RE = re.compile('^[-A-Za-z0-9+/=]*$')
# All the successful HTTP status codes from RFC 7231 & 4918
HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206, 207)
-# convert a structure into a string safely
-def safe_body(body, maxlen=4096):
- try:
- text = six.text_type(body)
- except UnicodeDecodeError:
- # if this isn't actually text, return marker that
- return "<BinaryData: removed>"
- if len(text) > maxlen:
- return text[:maxlen]
- else:
- return text
+class ResponseBody(dict):
+ """Class that wraps an http response and dict body into a single value.
+
+ Callers that receive this object will normally use it as a dict but
+ can extract the response if needed.
+ """
+
+ def __init__(self, response, body=None):
+ body_data = body or {}
+ self.update(body_data)
+ self.response = response
+
+ def __str__(self):
+ body = super.__str__(self)
+ return "response: %s\nBody: %s" % (self.response, body)
+
+
+class ResponseBodyList(list):
+ """Class that wraps an http response and list body into a single value.
+
+ Callers that receive this object will normally use it as a list but
+ can extract the response if needed.
+ """
+
+ def __init__(self, response, body=None):
+ body_data = body or []
+ self.extend(body_data)
+ self.response = response
+
+ def __str__(self):
+ body = super.__str__(self)
+ return "response: %s\nBody: %s" % (self.response, body)
class RestClient(object):
TYPE = "json"
- # This is used by _parse_resp method
- # Redefine it for purposes of your xml service client
- # List should contain top-xml_tag-names of data, which is like list/array
- # For example, in keystone it is users, roles, tenants and services
- # All of it has children with same tag-names
- list_tags = []
-
- # This is used by _parse_resp method too
- # Used for selection of dict-like xmls,
- # like metadata for Vms in nova, and volumes in cinder
- dict_tags = ["metadata", ]
-
LOG = logging.getLogger(__name__)
def __init__(self, auth_provider):
@@ -91,8 +97,9 @@
'retry-after', 'server',
'vary', 'www-authenticate'))
dscv = CONF.identity.disable_ssl_certificate_validation
+ ca_certs = CONF.identity.ca_certificates_file
self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv)
+ disable_ssl_certificate_validation=dscv, ca_certs=ca_certs)
def _get_type(self):
return self.TYPE
@@ -146,11 +153,6 @@
if catalog_type == service:
endpoint_type = getattr(cfg, 'endpoint_type', 'publicURL')
break
- # Special case for compute v3 service which hasn't its own
- # configuration group
- else:
- if service == CONF.compute.catalog_v3_type:
- endpoint_type = CONF.compute.endpoint_type
return endpoint_type
@property
@@ -263,6 +265,18 @@
return resp[i]
return ""
+ def _safe_body(self, body, maxlen=4096):
+ # convert a structure into a string safely
+ try:
+ text = six.text_type(body)
+ except UnicodeDecodeError:
+ # if this isn't actually text, return marker that
+ return "<BinaryData: removed>"
+ if len(text) > maxlen:
+ return text[:maxlen]
+ else:
+ return text
+
def _log_request_start(self, method, req_url, req_headers=None,
req_body=None):
if req_headers is None:
@@ -293,9 +307,9 @@
req_url,
secs,
str(req_headers),
- safe_body(req_body),
+ self._safe_body(req_body),
str(resp),
- safe_body(resp_body)),
+ self._safe_body(resp_body)),
extra=extra)
def _log_request(self, method, req_url, resp,
@@ -328,48 +342,30 @@
req_body, resp_body, caller_name, extra)
def _parse_resp(self, body):
- if self._get_type() is "json":
- body = json.loads(body)
+ body = json.loads(body)
- # We assume, that if the first value of the deserialized body's
- # item set is a dict or a list, that we just return the first value
- # of deserialized body.
- # Essentially "cutting out" the first placeholder element in a body
- # that looks like this:
- #
- # {
- # "users": [
- # ...
- # ]
- # }
- try:
- # Ensure there are not more than one top-level keys
- if len(body.keys()) > 1:
- return body
- # Just return the "wrapped" element
- first_key, first_item = body.items()[0]
- if isinstance(first_item, (dict, list)):
- return first_item
- except (ValueError, IndexError):
- pass
- return body
- elif self._get_type() is "xml":
- element = etree.fromstring(body)
- if any(s in element.tag for s in self.dict_tags):
- # Parse dictionary-like xmls (metadata, etc)
- dictionary = {}
- for el in element.getchildren():
- dictionary[u"%s" % el.get("key")] = u"%s" % el.text
- return dictionary
- if any(s in element.tag for s in self.list_tags):
- # Parse list-like xmls (users, roles, etc)
- array = []
- for child in element.getchildren():
- array.append(common.xml_to_json(child))
- return array
-
- # Parse one-item-like xmls (user, role, etc)
- return common.xml_to_json(element)
+ # We assume, that if the first value of the deserialized body's
+ # item set is a dict or a list, that we just return the first value
+ # of deserialized body.
+ # Essentially "cutting out" the first placeholder element in a body
+ # that looks like this:
+ #
+ # {
+ # "users": [
+ # ...
+ # ]
+ # }
+ try:
+ # Ensure there are not more than one top-level keys
+ if len(body.keys()) > 1:
+ return body
+ # Just return the "wrapped" element
+ first_key, first_item = body.items()[0]
+ if isinstance(first_item, (dict, list)):
+ return first_item
+ except (ValueError, IndexError):
+ pass
+ return body
def response_checker(self, method, resp, resp_body):
if (resp.status in set((204, 205, 304)) or resp.status < 200 or
@@ -482,9 +478,8 @@
# (and occasionally swift) are using.
TXT_ENC = ['text/plain', 'text/html', 'text/html; charset=utf-8',
'text/plain; charset=utf-8']
- XML_ENC = ['application/xml', 'application/xml; charset=utf-8']
- if ctype.lower() in JSON_ENC or ctype.lower() in XML_ENC:
+ if ctype.lower() in JSON_ENC:
parse_resp = True
elif ctype.lower() in TXT_ENC:
parse_resp = False
@@ -539,15 +534,17 @@
message = resp_body['cloudServersFault']['message']
elif 'computeFault' in resp_body:
message = resp_body['computeFault']['message']
- elif 'error' in resp_body: # Keystone errors
+ elif 'error' in resp_body:
message = resp_body['error']['message']
- raise exceptions.IdentityError(message)
elif 'message' in resp_body:
message = resp_body['message']
else:
message = resp_body
- raise exceptions.ServerFault(message)
+ if resp.status == 501:
+ raise exceptions.NotImplemented(message)
+ else:
+ raise exceptions.ServerFault(message)
if resp.status >= 400:
raise exceptions.UnexpectedResponseCode(str(resp.status))
@@ -556,13 +553,10 @@
if (not isinstance(resp_body, collections.Mapping) or
'retry-after' not in resp):
return True
- if self._get_type() is "json":
- over_limit = resp_body.get('overLimit', None)
- if not over_limit:
- return True
- return 'exceed' in over_limit.get('message', 'blabla')
- elif self._get_type() is "xml":
- return 'exceed' in resp_body.get('message', 'blabla')
+ over_limit = resp_body.get('overLimit', None)
+ if not over_limit:
+ return True
+ return 'exceed' in over_limit.get('message', 'blabla')
def wait_for_resource_deletion(self, id):
"""Waits for a resource to be deleted."""
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 6a238d0..d8bfef8 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import netaddr
import re
import time
@@ -87,7 +88,9 @@
return self.exec_command(cmd)
def ping_host(self, host):
- cmd = 'ping -c1 -w1 %s' % host
+ addr = netaddr.IPAddress(host)
+ cmd = 'ping6' if addr.version == 6 else 'ping'
+ cmd += ' -c1 -w1 {0}'.format(host)
return self.exec_command(cmd)
def get_mac_address(self):
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 52568cb..93f02c9 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -111,22 +111,24 @@
while image['status'] != status:
time.sleep(client.build_interval)
resp, image = client.get_image(image_id)
- if image['status'] == 'ERROR':
+ status_curr = image['status']
+ if status_curr == 'ERROR':
raise exceptions.AddImageException(image_id=image_id)
# check the status again to avoid a false negative where we hit
# the timeout at the same time that the image reached the expected
# status
- if image['status'] == status:
+ if status_curr == status:
return
if int(time.time()) - start >= client.build_timeout:
- message = ('Image %(image_id)s failed to reach %(status)s '
- 'status within the required time (%(timeout)s s).' %
+ message = ('Image %(image_id)s failed to reach %(status)s state'
+ '(current state %(status_curr)s) '
+ 'within the required time (%(timeout)s s).' %
{'image_id': image_id,
'status': status,
+ 'status_curr': status_curr,
'timeout': client.build_timeout})
- message += ' Current status: %s.' % image['status']
caller = misc_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
@@ -144,7 +146,8 @@
while node[attr] != status:
time.sleep(client.build_interval)
_, node = client.show_node(node_id)
- if node[attr] == status:
+ status_curr = node[attr]
+ if status_curr == status:
return
if int(time.time()) - start >= client.build_timeout:
@@ -154,7 +157,7 @@
'attr': attr,
'status': status,
'timeout': client.build_timeout})
- message += ' Current state of %s: %s.' % (attr, node[attr])
+ message += ' Current state of %s: %s.' % (attr, status_curr)
caller = misc_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
diff --git a/tempest/common/xml_utils.py b/tempest/common/xml_utils.py
deleted file mode 100644
index 7d460a4..0000000
--- a/tempest/common/xml_utils.py
+++ /dev/null
@@ -1,173 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import collections
-import copy
-
-XMLNS_11 = "http://docs.openstack.org/compute/api/v1.1"
-XMLNS_V3 = "http://docs.openstack.org/compute/api/v1.1"
-
-NEUTRON_NAMESPACES = {
- 'binding': "http://docs.openstack.org/ext/binding/api/v1.0",
- 'router': "http://docs.openstack.org/ext/neutron/router/api/v1.0",
- 'provider': 'http://docs.openstack.org/ext/provider/api/v1.0',
-}
-
-
-# NOTE(danms): This is just a silly implementation to help make generating
-# XML faster for prototyping. Could be replaced with proper etree gorp
-# if desired
-class Element(object):
- def __init__(self, element_name, *args, **kwargs):
- self.element_name = element_name
- self._attrs = kwargs
- self._elements = list(args)
-
- def add_attr(self, name, value):
- self._attrs[name] = value
-
- def append(self, element):
- self._elements.append(element)
-
- def __str__(self):
- args = " ".join(['%s="%s"' %
- (k, v if v is not None else "")
- for k, v in self._attrs.items()])
- string = '<%s %s' % (self.element_name, args)
- if not self._elements:
- string += '/>'
- return string
-
- string += '>'
-
- for element in self._elements:
- string += str(element)
-
- string += '</%s>' % self.element_name
-
- return string
-
- def __getitem__(self, name):
- for element in self._elements:
- if element.element_name == name:
- return element
- raise KeyError("No such element `%s'" % name)
-
- def __getattr__(self, name):
- if name in self._attrs:
- return self._attrs[name]
- return object.__getattr__(self, name)
-
- def attributes(self):
- return self._attrs.items()
-
- def children(self):
- return self._elements
-
-
-class Document(Element):
- def __init__(self, *args, **kwargs):
- Element.__init__(self, '?xml', *args, **kwargs)
-
- def __str__(self):
- attrs = copy.copy(self._attrs)
- # pop the required standard attrs out and render in required
- # order.
- vers = attrs.pop('version', '1.0')
- enc = attrs.pop('encoding', 'UTF-8')
- args = 'version="%s" encoding="%s"' % (vers, enc)
- if attrs:
- args = " ".join([args] + ['%s="%s"' %
- (k, v if v is not None else "")
- for k, v in attrs.items()])
- string = '<?xml %s?>\n' % args
- for element in self._elements:
- string += str(element)
- return string
-
-
-class Text(Element):
- def __init__(self, content=""):
- Element.__init__(self, None)
- self.__content = content
-
- def __str__(self):
- return self.__content
-
-
-def parse_array(node, plurals=None):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child,
- plurals))
- return array
-
-
-def xml_to_json(node, plurals=None):
- """This does a really braindead conversion of an XML tree to
- something that looks like a json dump. In cases where the XML
- and json structures are the same, then this "just works". In
- others, it requires a little hand-editing of the result.
- """
- json = {}
- bool_flag = False
- int_flag = False
- long_flag = False
- for attr in node.keys():
- if not attr.startswith("xmlns"):
- json[attr] = node.get(attr)
- if json[attr] == 'bool':
- bool_flag = True
- elif json[attr] == 'int':
- int_flag = True
- elif json[attr] == 'long':
- long_flag = True
- if not node.getchildren():
- if bool_flag:
- return node.text == 'True'
- elif int_flag:
- return int(node.text)
- elif long_flag:
- return long(node.text)
- else:
- return node.text or json
- for child in node.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- ns, tag = tag.split("}", 1)
- for key, uri in NEUTRON_NAMESPACES.iteritems():
- if uri == ns[1:]:
- tag = key + ":" + tag
- if plurals is not None and tag in plurals:
- json[tag] = parse_array(child, plurals)
- else:
- json[tag] = xml_to_json(child, plurals)
- return json
-
-
-def deep_dict_to_xml(dest, source):
- """Populates the ``dest`` xml element with the ``source`` ``Mapping``
- elements, if the source Mapping's value is also a ``Mapping``
- they will be recursively added as a child elements.
- :param source: A python ``Mapping`` (dict)
- :param dest: XML child element will be added to the ``dest``
- """
- for element, content in source.iteritems():
- if isinstance(content, collections.Mapping):
- xml_element = Element(element)
- deep_dict_to_xml(xml_element, content)
- dest.append(xml_element)
- else:
- dest.append(Element(element, content))
diff --git a/tempest/config.py b/tempest/config.py
index 63a7226..cc6d626 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -71,6 +71,10 @@
cfg.BoolOpt('disable_ssl_certificate_validation',
default=False,
help="Set to True if using self-signed SSL certificates."),
+ cfg.StrOpt('ca_certificates_file',
+ default=None,
+ help='Specify a CA bundle file to use in verifying a '
+ 'TLS (https) server certificate.'),
cfg.StrOpt('uri',
help="Full URI of the OpenStack Identity API (Keystone), v2"),
cfg.StrOpt('uri_v3',
@@ -143,9 +147,6 @@
cfg.BoolOpt('api_v3',
default=True,
help='Is the v3 identity API enabled'),
- cfg.BoolOpt('xml_api',
- default=False,
- help='If false, skip all identity api tests with xml'),
]
compute_group = cfg.OptGroup(name='compute',
@@ -222,10 +223,12 @@
"channel."),
cfg.StrOpt('fixed_network_name',
default='private',
- help="Visible fixed network name "),
+ help="Name of the fixed network that is visible to all test "
+ "tenants."),
cfg.StrOpt('network_for_ssh',
default='public',
- help="Network used for SSH connections."),
+ help="Network used for SSH connections. Ignored if "
+ "use_floatingip_for_ssh=true or run_ssh=false."),
cfg.IntOpt('ip_version_for_ssh',
default=4,
help="IP version used for SSH connections."),
@@ -266,7 +269,9 @@
cfg.StrOpt('floating_ip_range',
default='10.0.0.0/29',
help='Unallocated floating IP range, which will be used to '
- 'test the floating IP bulk feature for CRUD operation.')
+ 'test the floating IP bulk feature for CRUD operation. '
+ 'This block must not overlap an existing floating IP '
+ 'pool.')
]
compute_features_group = cfg.OptGroup(name='compute-feature-enabled',
@@ -276,9 +281,6 @@
cfg.BoolOpt('api_v3',
default=False,
help="If false, skip all nova v3 tests."),
- cfg.BoolOpt('xml_api_v2',
- default=True,
- help="If false skip all v2 api tests with xml"),
cfg.BoolOpt('disk_config',
default=True,
help="If false, skip disk config tests"),
@@ -487,9 +489,6 @@
"the extended IPv6 attributes ipv6_ra_mode "
"and ipv6_address_mode"
),
- cfg.BoolOpt('xml_api',
- default=False,
- help='If false, skip all network api tests with xml')
]
messaging_group = cfg.OptGroup(name='messaging',
@@ -927,9 +926,6 @@
title="Debug System")
DebugGroup = [
- cfg.BoolOpt('enable',
- default=True,
- help="Enable diagnostic commands"),
cfg.StrOpt('trace_requests',
default='',
help="""A regex to determine which requests should be traced.
@@ -975,7 +971,14 @@
baremetal_group = cfg.OptGroup(name='baremetal',
- title='Baremetal provisioning service options')
+ title='Baremetal provisioning service options',
+ help='When enabling baremetal tests, Nova '
+ 'must be configured to use the Ironic '
+ 'driver. The following paremeters for the '
+ '[compute] section must be disabled: '
+ 'console_output, interface_attach, '
+ 'live_migration, pause, rescue, resize '
+ 'shelve, snapshot, and suspend')
BaremetalGroup = [
cfg.StrOpt('catalog_type',
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index cc31fad..9b2b4d4 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -75,7 +75,7 @@
message = 'Unauthorized'
-class InvalidServiceTag(RestClientException):
+class InvalidServiceTag(TempestException):
message = "Invalid service tag"
@@ -140,18 +140,22 @@
message = "Endpoint not found"
-class RateLimitExceeded(TempestException):
+class RateLimitExceeded(RestClientException):
message = "Rate limit exceeded"
-class OverLimit(TempestException):
+class OverLimit(RestClientException):
message = "Quota exceeded"
-class ServerFault(TempestException):
+class ServerFault(RestClientException):
message = "Got server fault"
+class NotImplemented(RestClientException):
+ message = "Got NotImplemented error"
+
+
class ImageFault(TempestException):
message = "Got image fault"
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 6014cff..29898a9 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -30,18 +30,18 @@
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
-def import_no_clients_in_api(physical_line, filename):
- """Check for client imports from tempest/api tests
+def import_no_clients_in_api_and_scenario_tests(physical_line, filename):
+ """Check for client imports from tempest/api & tempest/scenario tests
T102: Cannot import OpenStack python clients
"""
- if "tempest/api" in filename:
+ if "tempest/api" in filename or "tempest/scenario" in filename:
res = PYTHON_CLIENT_RE.match(physical_line)
if res:
return (physical_line.find(res.group(1)),
("T102: python clients import not allowed"
- " in tempest/api/* tests"))
+ " in tempest/api/* or tempest/scenario/* tests"))
def scenario_tests_need_service_tags(physical_line, filename,
@@ -117,7 +117,7 @@
def factory(register):
- register(import_no_clients_in_api)
+ register(import_no_clients_in_api_and_scenario_tests)
register(scenario_tests_need_service_tags)
register(no_setup_teardown_class_for_tests)
register(no_vi_headers)
diff --git a/tempest/openstack/common/__init__.py b/tempest/openstack/common/__init__.py
index d1223ea..e69de29 100644
--- a/tempest/openstack/common/__init__.py
+++ b/tempest/openstack/common/__init__.py
@@ -1,17 +0,0 @@
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import six
-
-
-six.add_move(six.MovedModule('mox', 'mox', 'mox3.mox'))
diff --git a/tempest/openstack/common/_i18n.py b/tempest/openstack/common/_i18n.py
new file mode 100644
index 0000000..fdc8327
--- /dev/null
+++ b/tempest/openstack/common/_i18n.py
@@ -0,0 +1,45 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""oslo.i18n integration module.
+
+See http://docs.openstack.org/developer/oslo.i18n/usage.html
+
+"""
+
+try:
+ import oslo.i18n
+
+ # NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
+ # application name when this module is synced into the separate
+ # repository. It is OK to have more than one translation function
+ # using the same domain, since there will still only be one message
+ # catalog.
+ _translators = oslo.i18n.TranslatorFactory(domain='tempest')
+
+ # The primary translation function using the well-known name "_"
+ _ = _translators.primary
+
+ # Translators for log levels.
+ #
+ # The abbreviated names are meant to reflect the usual use of a short
+ # name like '_'. The "L" is for "log" and the other letter comes from
+ # the level.
+ _LI = _translators.log_info
+ _LW = _translators.log_warning
+ _LE = _translators.log_error
+ _LC = _translators.log_critical
+except ImportError:
+ # NOTE(dims): Support for cases where a project wants to use
+ # code from tempest-incubator, but is not ready to be internationalized
+ # (like tempest)
+ _ = _LI = _LW = _LE = _LC = lambda x: x
diff --git a/tempest/openstack/common/log.py b/tempest/openstack/common/log.py
index 44102c0..26cd6ad 100644
--- a/tempest/openstack/common/log.py
+++ b/tempest/openstack/common/log.py
@@ -33,20 +33,20 @@
import logging.config
import logging.handlers
import os
+import socket
import sys
import traceback
from oslo.config import cfg
+from oslo.serialization import jsonutils
+from oslo.utils import importutils
import six
from six import moves
-from tempest.openstack.common.gettextutils import _
-from tempest.openstack.common import importutils
-from tempest.openstack.common import jsonutils
+_PY26 = sys.version_info[0:2] == (2, 6)
+
+from tempest.openstack.common._i18n import _
from tempest.openstack.common import local
-# NOTE(flaper87): Pls, remove when graduating this module
-# from the incubator.
-from tempest.openstack.common.strutils import mask_password # noqa
_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
@@ -124,7 +124,9 @@
'qpid=WARN', 'sqlalchemy=WARN', 'suds=INFO',
'oslo.messaging=INFO', 'iso8601=WARN',
'requests.packages.urllib3.connectionpool=WARN',
- 'urllib3.connectionpool=WARN']
+ 'urllib3.connectionpool=WARN', 'websocket=WARN',
+ "keystonemiddleware=WARN", "routes.middleware=WARN",
+ "stevedore=WARN"]
log_opts = [
cfg.StrOpt('logging_context_format_string',
@@ -227,6 +229,15 @@
def audit(self, msg, *args, **kwargs):
self.log(logging.AUDIT, msg, *args, **kwargs)
+ def isEnabledFor(self, level):
+ if _PY26:
+ # This method was added in python 2.7 (and it does the exact
+ # same logic, so we need to do the exact same logic so that
+ # python 2.6 has this capability as well).
+ return self.logger.isEnabledFor(level)
+ else:
+ return super(BaseLoggerAdapter, self).isEnabledFor(level)
+
class LazyAdapter(BaseLoggerAdapter):
def __init__(self, name='unknown', version='unknown'):
@@ -289,11 +300,10 @@
self.warn(stdmsg, *args, **kwargs)
def process(self, msg, kwargs):
- # NOTE(mrodden): catch any Message/other object and
- # coerce to unicode before they can get
- # to the python logging and possibly
- # cause string encoding trouble
- if not isinstance(msg, six.string_types):
+ # NOTE(jecarey): If msg is not unicode, coerce it into unicode
+ # before it can get to the python logging and
+ # possibly cause string encoding trouble
+ if not isinstance(msg, six.text_type):
msg = six.text_type(msg)
if 'extra' not in kwargs:
@@ -410,18 +420,20 @@
sys.excepthook = _create_logging_excepthook(product_name)
-def set_defaults(logging_context_format_string,
+def set_defaults(logging_context_format_string=None,
default_log_levels=None):
# Just in case the caller is not setting the
# default_log_level. This is insurance because
# we introduced the default_log_level parameter
# later in a backwards in-compatible change
- if default_log_levels is None:
- default_log_levels = DEFAULT_LOG_LEVELS
- cfg.set_defaults(
+ if default_log_levels is not None:
+ cfg.set_defaults(
log_opts,
- logging_context_format_string=logging_context_format_string,
default_log_levels=default_log_levels)
+ if logging_context_format_string is not None:
+ cfg.set_defaults(
+ log_opts,
+ logging_context_format_string=logging_context_format_string)
def _find_facility_from_conf():
@@ -470,18 +482,6 @@
for handler in log_root.handlers:
log_root.removeHandler(handler)
- if CONF.use_syslog:
- facility = _find_facility_from_conf()
- # TODO(bogdando) use the format provided by RFCSysLogHandler
- # after existing syslog format deprecation in J
- if CONF.use_syslog_rfc_format:
- syslog = RFCSysLogHandler(address='/dev/log',
- facility=facility)
- else:
- syslog = logging.handlers.SysLogHandler(address='/dev/log',
- facility=facility)
- log_root.addHandler(syslog)
-
logpath = _get_log_file_path()
if logpath:
filelog = logging.handlers.WatchedFileHandler(logpath)
@@ -540,6 +540,20 @@
else:
logger.setLevel(level_name)
+ if CONF.use_syslog:
+ try:
+ facility = _find_facility_from_conf()
+ # TODO(bogdando) use the format provided by RFCSysLogHandler
+ # after existing syslog format deprecation in J
+ if CONF.use_syslog_rfc_format:
+ syslog = RFCSysLogHandler(facility=facility)
+ else:
+ syslog = logging.handlers.SysLogHandler(facility=facility)
+ log_root.addHandler(syslog)
+ except socket.error:
+ log_root.error('Unable to add syslog handler. Verify that syslog '
+ 'is running.')
+
_loggers = {}
@@ -609,6 +623,12 @@
def format(self, record):
"""Uses contextstring if request_id is set, otherwise default."""
+ # NOTE(jecarey): If msg is not unicode, coerce it into unicode
+ # before it can get to the python logging and
+ # possibly cause string encoding trouble
+ if not isinstance(record.msg, six.text_type):
+ record.msg = six.text_type(record.msg)
+
# store project info
record.project = self.project
record.version = self.version
diff --git a/tempest/scenario/README.rst b/tempest/scenario/README.rst
index 5a287d6..38e0de9 100644
--- a/tempest/scenario/README.rst
+++ b/tempest/scenario/README.rst
@@ -29,9 +29,9 @@
Scope of these tests
--------------------
-Scenario tests should use the official python client libraries for
-OpenStack, as they provide a more realistic approach in how people
-will interact with the services.
+Scenario tests should always use the Tempest implementation of the
+OpenStack API, as we want to ensure that bugs aren't hidden by the
+official clients.
Tests should be tagged with which services they exercise, as
determined by which client libraries are used directly by the test.
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index ea4365e..410d90a 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -24,7 +24,6 @@
from tempest import auth
from tempest import clients
from tempest.common import credentials
-from tempest.common import debug
from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
@@ -297,7 +296,19 @@
return secgroup
- def get_remote_client(self, server_or_ip, username=None, private_key=None):
+ def get_remote_client(self, server_or_ip, username=None, private_key=None,
+ log_console_of_servers=None):
+ """Get a SSH client to a remote server
+
+ @param server_or_ip a server object as returned by Tempest compute
+ client or an IP address to connect to
+ @param username name of the Linux account on the remote server
+ @param private_key the SSH private key to use
+ @param log_console_of_servers a list of server objects. Each server
+ in the list will have its console printed in the logs in case the
+ SSH connection failed to be established
+ @return a RemoteClient object
+ """
if isinstance(server_or_ip, six.string_types):
ip = server_or_ip
else:
@@ -312,9 +323,12 @@
pkey=private_key)
try:
linux_client.validate_authentication()
- except exceptions.SSHTimeout:
- LOG.exception('ssh connection to %s failed' % ip)
- debug.log_net_debug()
+ except Exception:
+ LOG.exception('Initializing SSH connection to %s failed' % ip)
+ # If we don't explicitely set for which servers we want to
+ # log the console output then all the servers will be logged.
+ # See the definition of _log_console_output()
+ self._log_console_output(log_console_of_servers)
raise
return linux_client
@@ -384,7 +398,6 @@
# network debug is called as part of ssh init
if not isinstance(exc, exceptions.SSHTimeout):
LOG.debug('Network information on a devstack host')
- debug.log_net_debug()
def create_server_snapshot(self, server, name=None):
# Glance client
@@ -456,6 +469,65 @@
return tempest.test.call_until_true(ping, timeout, 1)
+ def check_vm_connectivity(self, ip_address,
+ username=None,
+ private_key=None,
+ should_connect=True):
+ """
+ :param ip_address: server to test against
+ :param username: server's ssh username
+ :param private_key: server's ssh private key to be used
+ :param should_connect: True/False indicates positive/negative test
+ positive - attempt ping and ssh
+ negative - attempt ping and fail if succeed
+
+ :raises: AssertError if the result of the connectivity check does
+ not match the value of the should_connect param
+ """
+ if should_connect:
+ msg = "Timed out waiting for %s to become reachable" % ip_address
+ else:
+ msg = "ip address %s is reachable" % ip_address
+ self.assertTrue(self.ping_ip_address(ip_address,
+ should_succeed=should_connect),
+ msg=msg)
+ if should_connect:
+ # no need to check ssh for negative connectivity
+ self.get_remote_client(ip_address, username, private_key)
+
+ def check_public_network_connectivity(self, ip_address, username,
+ private_key, should_connect=True,
+ msg=None, servers=None):
+ # The target login is assumed to have been configured for
+ # key-based authentication by cloud-init.
+ LOG.debug('checking network connections to IP %s with user: %s' %
+ (ip_address, username))
+ try:
+ self.check_vm_connectivity(ip_address,
+ username,
+ private_key,
+ should_connect=should_connect)
+ except Exception:
+ ex_msg = 'Public network connectivity check failed'
+ if msg:
+ ex_msg += ": " + msg
+ LOG.exception(ex_msg)
+ self._log_console_output(servers)
+ raise
+
+ def create_floating_ip(self, thing, pool_name=None):
+ """Creates a floating IP and associates to a server using
+ Nova clients
+ """
+
+ _, floating_ip = self.floating_ips_client.create_floating_ip(pool_name)
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], thing['id'])
+ return floating_ip
+
class NetworkScenarioTest(ScenarioTest):
"""Base class for network scenario tests.
@@ -534,22 +606,31 @@
cidr_in_use = self._list_subnets(tenant_id=tenant_id, cidr=cidr)
return len(cidr_in_use) != 0
- tenant_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ ip_version = kwargs.pop('ip_version', 4)
+
+ if ip_version == 6:
+ tenant_cidr = netaddr.IPNetwork(
+ CONF.network.tenant_network_v6_cidr)
+ num_bits = CONF.network.tenant_network_v6_mask_bits
+ else:
+ tenant_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ num_bits = CONF.network.tenant_network_mask_bits
+
result = None
+ str_cidr = None
# Repeatedly attempt subnet creation with sequential cidr
# blocks until an unallocated block is found.
- for subnet_cidr in tenant_cidr.subnet(
- CONF.network.tenant_network_mask_bits):
+ for subnet_cidr in tenant_cidr.subnet(num_bits):
str_cidr = str(subnet_cidr)
if cidr_in_use(str_cidr, tenant_id=network.tenant_id):
continue
subnet = dict(
name=data_utils.rand_name(namestart),
- ip_version=4,
network_id=network.id,
tenant_id=network.tenant_id,
cidr=str_cidr,
+ ip_version=ip_version,
**kwargs
)
try:
@@ -580,27 +661,40 @@
self.addCleanup(self.delete_wrapper, port.delete)
return port
- def _get_server_port_id(self, server, ip_addr=None):
+ def _get_server_port_id_and_ip4(self, server, ip_addr=None):
ports = self._list_ports(device_id=server['id'],
fixed_ip=ip_addr)
self.assertEqual(len(ports), 1,
"Unable to determine which port to target.")
- return ports[0]['id']
+ # it might happen here that this port has more then one ip address
+ # as in case of dual stack- when this port is created on 2 subnets
+ for ip46 in ports[0]['fixed_ips']:
+ ip = ip46['ip_address']
+ if netaddr.valid_ipv4(ip):
+ return ports[0]['id'], ip
def _get_network_by_name(self, network_name):
net = self._list_networks(name=network_name)
return net_resources.AttributeDict(net[0])
- def _create_floating_ip(self, thing, external_network_id, port_id=None,
- client=None):
+ def create_floating_ip(self, thing, external_network_id=None,
+ port_id=None, client=None):
+ """Creates a floating IP and associates to a resource/port using
+ Neutron client
+ """
+ if not external_network_id:
+ external_network_id = CONF.network.public_network_id
if not client:
client = self.network_client
if not port_id:
- port_id = self._get_server_port_id(thing)
+ port_id, ip4 = self._get_server_port_id_and_ip4(thing)
+ else:
+ ip4 = None
_, result = client.create_floatingip(
floating_network_id=external_network_id,
port_id=port_id,
- tenant_id=thing['tenant_id']
+ tenant_id=thing['tenant_id'],
+ fixed_ip_address=ip4
)
floating_ip = net_resources.DeletableFloatingIp(
client=client,
@@ -609,7 +703,7 @@
return floating_ip
def _associate_floating_ip(self, floating_ip, server):
- port_id = self._get_server_port_id(server)
+ port_id, _ = self._get_server_port_id_and_ip4(server)
floating_ip.update(port_id=port_id)
self.assertEqual(port_id, floating_ip.port_id)
return floating_ip
@@ -645,53 +739,6 @@
LOG.info("FloatingIP: {fp} is at status: {st}"
.format(fp=floating_ip, st=status))
- def _check_vm_connectivity(self, ip_address,
- username=None,
- private_key=None,
- should_connect=True):
- """
- :param ip_address: server to test against
- :param username: server's ssh username
- :param private_key: server's ssh private key to be used
- :param should_connect: True/False indicates positive/negative test
- positive - attempt ping and ssh
- negative - attempt ping and fail if succeed
-
- :raises: AssertError if the result of the connectivity check does
- not match the value of the should_connect param
- """
- if should_connect:
- msg = "Timed out waiting for %s to become reachable" % ip_address
- else:
- msg = "ip address %s is reachable" % ip_address
- self.assertTrue(self.ping_ip_address(ip_address,
- should_succeed=should_connect),
- msg=msg)
- if should_connect:
- # no need to check ssh for negative connectivity
- self.get_remote_client(ip_address, username, private_key)
-
- def _check_public_network_connectivity(self, ip_address, username,
- private_key, should_connect=True,
- msg=None, servers=None):
- # The target login is assumed to have been configured for
- # key-based authentication by cloud-init.
- LOG.debug('checking network connections to IP %s with user: %s' %
- (ip_address, username))
- try:
- self._check_vm_connectivity(ip_address,
- username,
- private_key,
- should_connect=should_connect)
- except Exception as e:
- ex_msg = 'Public network connectivity check failed'
- if msg:
- ex_msg += ": " + msg
- LOG.exception(ex_msg)
- self._log_console_output(servers)
- self._log_net_info(e)
- raise
-
def _check_tenant_network_connectivity(self, server,
username,
private_key,
@@ -706,10 +753,10 @@
try:
for net_name, ip_addresses in server['networks'].iteritems():
for ip_address in ip_addresses:
- self._check_vm_connectivity(ip_address,
- username,
- private_key,
- should_connect=should_connect)
+ self.check_vm_connectivity(ip_address,
+ username,
+ private_key,
+ should_connect=should_connect)
except Exception as e:
LOG.exception('Tenant network connectivity check failed')
self._log_console_output(servers_for_debug)
@@ -969,6 +1016,10 @@
self.addCleanup(self.delete_wrapper, router.delete)
return router
+ def _update_router_admin_state(self, router, admin_state_up):
+ router.update(admin_state_up=admin_state_up)
+ self.assertEqual(admin_state_up, router.admin_state_up)
+
def create_networks(self, client=None, tenant_id=None):
"""Create a network with a subnet connected to a router.
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index ddfabe4..f09f00c 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -119,14 +119,8 @@
if self.keypair:
# Check that the user can authenticate with the generated
# keypair
- try:
- linux_client = self.get_remote_client(
- server_ip, username='ec2-user')
- linux_client.validate_authentication()
- except (exceptions.ServerUnreachable,
- exceptions.SSHTimeout) as e:
- self._log_console_output(servers=[server])
- raise e
+ self.get_remote_client(server_ip, username='ec2-user',
+ log_console_of_servers=[server])
@test.attr(type='slow')
@test.skip_because(bug='1374175')
diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py
index 875a1d9..2014293 100644
--- a/tempest/scenario/test_dashboard_basic_ops.py
+++ b/tempest/scenario/test_dashboard_basic_ops.py
@@ -12,11 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import HTMLParser
import urllib
import urllib2
-from lxml import html
-
from tempest import config
from tempest.scenario import manager
from tempest import test
@@ -24,6 +23,30 @@
CONF = config.CONF
+class HorizonHTMLParser(HTMLParser.HTMLParser):
+ csrf_token = None
+ region = None
+
+ def _find_name(self, attrs, name):
+ for attrpair in attrs:
+ if attrpair[0] == 'name' and attrpair[1] == name:
+ return True
+ return False
+
+ def _find_value(self, attrs):
+ for attrpair in attrs:
+ if attrpair[0] == 'value':
+ return attrpair[1]
+ return None
+
+ def handle_starttag(self, tag, attrs):
+ if tag == 'input':
+ if self._find_name(attrs, 'csrfmiddlewaretoken'):
+ self.csrf_token = self._find_value(attrs)
+ if self._find_name(attrs, 'region'):
+ self.region = self._find_value(attrs)
+
+
class TestDashboardBasicOps(manager.ScenarioTest):
"""
@@ -42,17 +65,15 @@
def check_login_page(self):
response = urllib2.urlopen(CONF.dashboard.dashboard_url)
- self.assertIn("<h3>Log In</h3>", response.read())
+ self.assertIn("Log In", response.read())
def user_login(self):
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
response = self.opener.open(CONF.dashboard.dashboard_url).read()
# Grab the CSRF token and default region
- csrf_token = html.fromstring(response).xpath(
- '//input[@name="csrfmiddlewaretoken"]/@value')[0]
- region = html.fromstring(response).xpath(
- '//input[@name="region"]/@value')[0]
+ parser = HorizonHTMLParser()
+ parser.feed(response)
# Prepare login form request
req = urllib2.Request(CONF.dashboard.login_url)
@@ -60,8 +81,8 @@
req.add_header('Referer', CONF.dashboard.dashboard_url)
params = {'username': CONF.identity.username,
'password': CONF.identity.password,
- 'region': region,
- 'csrfmiddlewaretoken': csrf_token}
+ 'region': parser.region,
+ 'csrfmiddlewaretoken': parser.csrf_token}
self.opener.open(req, urllib.urlencode(params))
def check_home_page(self):
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index 91b95a8..60fd2bd 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -12,6 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions
from tempest.common.utils import data_utils
from tempest import config
@@ -44,6 +45,22 @@
"instances")
cls.set_network_resources()
super(TestLargeOpsScenario, cls).resource_setup()
+ # list of cleanup calls to be executed in reverse order
+ cls._cleanup_resources = []
+
+ @classmethod
+ def resource_cleanup(cls):
+ while cls._cleanup_resources:
+ function, args, kwargs = cls._cleanup_resources.pop(-1)
+ try:
+ function(*args, **kwargs)
+ except exceptions.NotFound:
+ pass
+ super(TestLargeOpsScenario, cls).resource_cleanup()
+
+ @classmethod
+ def addCleanupClass(cls, function, *arguments, **keywordArguments):
+ cls._cleanup_resources.append((function, arguments, keywordArguments))
def _wait_for_server_status(self, status):
for server in self.servers:
@@ -54,13 +71,20 @@
def nova_boot(self):
name = data_utils.rand_name('scenario-server-')
flavor_id = CONF.compute.flavor_ref
- secgroup = self._create_security_group()
+ # Explicitly create secgroup to avoid cleanup at the end of testcases.
+ # Since no traffic is tested, we don't need to actually add rules to
+ # secgroup
+ _, secgroup = self.security_groups_client.create_security_group(
+ 'secgroup-%s' % name, 'secgroup-desc-%s' % name)
+ self.addCleanupClass(self.security_groups_client.delete_security_group,
+ secgroup['id'])
+
self.servers_client.create_server(
name,
self.image,
flavor_id,
min_count=CONF.scenario.large_ops_number,
- security_groups=[secgroup])
+ security_groups=[{'name': secgroup['name']}])
# needed because of bug 1199788
params = {'name': name}
_, server_list = self.servers_client.list_servers(params)
@@ -68,15 +92,12 @@
for server in self.servers:
# after deleting all servers - wait for all servers to clear
# before cleanup continues
- self.addCleanup(self.servers_client.wait_for_server_termination,
- server['id'])
+ self.addCleanupClass(self.servers_client.
+ wait_for_server_termination,
+ server['id'])
for server in self.servers:
- self.addCleanup_with_wait(
- waiter_callable=(self.servers_client.
- wait_for_server_termination),
- thing_id=server['id'], thing_id_param='server_id',
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[self.servers_client.delete_server, server['id']])
+ self.addCleanupClass(self.servers_client.delete_server,
+ server['id'])
self._wait_for_server_status('ACTIVE')
def _large_ops_scenario(self):
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index 9e404c8..57a5406 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -48,12 +48,10 @@
cfg = config.network
if not test.is_extension_enabled('lbaas', 'network'):
msg = 'LBaaS Extension is not enabled'
- cls.enabled = False
raise cls.skipException(msg)
if not (cfg.tenant_networks_reachable or cfg.public_network_id):
msg = ('Either tenant_networks_reachable must be "true", or '
'public_network_id must be defined.')
- cls.enabled = False
raise cls.skipException(msg)
@classmethod
@@ -123,10 +121,10 @@
def _create_server(self, name):
keypair = self.create_keypair()
- security_groups = [self.security_group]
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
- 'nics': [
- {'net-id': self.network['id']},
+ 'networks': [
+ {'uuid': self.network['id']},
],
'key_name': keypair['name'],
'security_groups': security_groups,
@@ -137,7 +135,7 @@
if (config.network.public_network_id and not
config.network.tenant_networks_reachable):
public_network_id = config.network.public_network_id
- floating_ip = self._create_floating_ip(
+ floating_ip = self.create_floating_ip(
server, public_network_id)
self.floating_ips[floating_ip] = server
self.server_ips[server['id']] = floating_ip.floating_ip_address
@@ -170,9 +168,9 @@
private_key=private_key)
# Write a backend's response into a file
- resp = """echo -ne "HTTP/1.1 200 OK\r\nContent-Length: 7\r\n""" \
- """Connection: close\r\nContent-Type: text/html; """ \
- """charset=UTF-8\r\n\r\n%s"; cat >/dev/null"""
+ resp = ('echo -ne "HTTP/1.1 200 OK\r\nContent-Length: 7\r\n'
+ 'Connection: close\r\nContent-Type: text/html; '
+ 'charset=UTF-8\r\n\r\n%s"; cat >/dev/null')
with tempfile.NamedTemporaryFile() as script:
script.write(resp % server_name)
@@ -186,8 +184,9 @@
username, key.name)
# Start netcat
- start_server = """sudo nc -ll -p %(port)s -e sh """ \
- """/tmp/%(script)s &"""
+ start_server = ('while true; do '
+ 'sudo nc -l -p %(port)s -e sh /tmp/%(script)s; '
+ 'done &')
cmd = start_server % {'port': self.port1,
'script': 'script1'}
ssh_client.exec_command(cmd)
@@ -215,6 +214,8 @@
return False
except IOError:
return False
+ except urllib2.HTTPError:
+ return False
timeout = config.compute.ping_timeout
start = time.time()
while not try_connect(check_ip, port):
@@ -257,8 +258,8 @@
def _assign_floating_ip_to_vip(self, vip):
public_network_id = config.network.public_network_id
port_id = vip.port_id
- floating_ip = self._create_floating_ip(vip, public_network_id,
- port_id=port_id)
+ floating_ip = self.create_floating_ip(vip, public_network_id,
+ port_id=port_id)
self.floating_ips.setdefault(vip.id, [])
self.floating_ips[vip.id].append(floating_ip)
@@ -297,8 +298,13 @@
def _send_requests(self, vip_ip, servers):
counters = dict.fromkeys(servers, 0)
for i in range(self.num):
- server = urllib2.urlopen("http://{0}/".format(vip_ip)).read()
- counters[server] += 1
+ try:
+ server = urllib2.urlopen("http://{0}/".format(vip_ip)).read()
+ counters[server] += 1
+ # HTTP exception means fail of server, so don't increase counter
+ # of success and continue connection tries
+ except urllib2.HTTPError:
+ continue
# Assert that each member of the pool gets balanced at least once
for member, counter in counters.iteritems():
self.assertGreater(counter, 0, 'Member %s never balanced' % member)
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index ead021e..16a65c9 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -14,7 +14,6 @@
# under the License.
from tempest.common import custom_matchers
-from tempest.common import debug
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -89,27 +88,6 @@
self.servers_client.reboot(self.server['id'], 'SOFT')
self._wait_for_server_status('ACTIVE')
- def nova_floating_ip_create(self):
- _, self.floating_ip = self.floating_ips_client.create_floating_ip()
- self.addCleanup(self.delete_wrapper,
- self.floating_ips_client.delete_floating_ip,
- self.floating_ip['id'])
-
- def nova_floating_ip_add(self):
- self.floating_ips_client.associate_floating_ip_to_server(
- self.floating_ip['ip'], self.server['id'])
-
- def ssh_to_server(self):
- try:
- self.linux_client = self.get_remote_client(self.floating_ip['ip'])
- except Exception as e:
- LOG.exception('ssh to server failed')
- self._log_console_output()
- # network debug is called as part of ssh init
- if not isinstance(e, test.exceptions.SSHTimeout):
- debug.log_net_debug()
- raise
-
def check_partitions(self):
# NOTE(andreaf) The device name may be different on different guest OS
partitions = self.linux_client.get_partitions()
@@ -155,10 +133,11 @@
self.addCleanup(self.nova_volume_detach)
self.cinder_show()
- self.nova_floating_ip_create()
- self.nova_floating_ip_add()
+ self.floating_ip = self.create_floating_ip(self.server)
self.create_and_add_security_group()
- self.ssh_to_server()
+
+ self.linux_client = self.get_remote_client(self.floating_ip['ip'])
self.nova_reboot()
- self.ssh_to_server()
+
+ self.linux_client = self.get_remote_client(self.floating_ip['ip'])
self.check_partitions()
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 0c48334..194a0bd 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -46,7 +46,6 @@
or CONF.network.public_network_id):
msg = ('Either tenant_networks_reachable must be "true", or '
'public_network_id must be defined.')
- cls.enabled = False
raise cls.skipException(msg)
@classmethod
@@ -65,13 +64,13 @@
{'uuid': network.id},
],
'key_name': self.keypair['name'],
- 'security_groups': [security_group],
+ 'security_groups': [{'name': security_group['name']}],
}
server_name = data_utils.rand_name('server-smoke')
self.server = self.create_server(name=server_name,
create_kwargs=create_kwargs)
- self.floating_ip = self._create_floating_ip(self.server,
- public_network_id)
+ self.floating_ip = self.create_floating_ip(self.server,
+ public_network_id)
# Verify that we can indeed connect to the server before we mess with
# it's state
self._wait_server_status_and_check_network_connectivity()
@@ -84,9 +83,9 @@
should_connect=should_connect,
servers_for_debug=[self.server])
floating_ip = self.floating_ip.floating_ip_address
- self._check_public_network_connectivity(floating_ip, username,
- private_key, should_connect,
- servers=[self.server])
+ self.check_public_network_connectivity(floating_ip, username,
+ private_key, should_connect,
+ servers=[self.server])
self.check_floating_ip_status(self.floating_ip, 'ACTIVE')
def _wait_server_status_and_check_network_connectivity(self):
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index e3f87e9..30c3b9d 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -18,7 +18,6 @@
import testtools
-from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -84,7 +83,6 @@
or CONF.network.public_network_id):
msg = ('Either tenant_networks_reachable must be "true", or '
'public_network_id must be defined.')
- cls.enabled = False
raise cls.skipException(msg)
@classmethod
@@ -112,7 +110,8 @@
server = self._create_server(name, self.network)
self._check_tenant_network_connectivity()
- self._create_and_associate_floating_ips(server)
+ floating_ip = self.create_floating_ip(server)
+ self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
def check_networks(self):
"""
@@ -145,7 +144,7 @@
def _create_server(self, name, network):
keypair = self.create_keypair()
self.keypairs[keypair['name']] = keypair
- security_groups = [self.security_group]
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'networks': [
{'uuid': network.id},
@@ -169,13 +168,9 @@
server, ssh_login, self._get_server_key(server),
servers_for_debug=self.servers)
- def _create_and_associate_floating_ips(self, server):
- public_network_id = CONF.network.public_network_id
- floating_ip = self._create_floating_ip(server, public_network_id)
- self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
-
- def _check_public_network_connectivity(self, should_connect=True,
- msg=None):
+ def check_public_network_connectivity(
+ self, should_connect=True, msg=None,
+ should_check_floating_ip_status=True):
"""Verifies connectivty to a VM via public network and floating IP,
and verifies floating IP has resource status is correct.
@@ -184,6 +179,8 @@
:param msg: Failure message to add to Error message. Should describe
the place in the test scenario where the method was called,
to indicate the context of the failure
+ :param should_check_floating_ip_status: bool. should status of
+ floating_ip be checked or not
"""
ssh_login = CONF.compute.image_ssh_user
floating_ip, server = self.floating_ip_tuple
@@ -194,10 +191,11 @@
private_key = self._get_server_key(server)
floatingip_status = 'ACTIVE'
# call the common method in the parent class
- super(TestNetworkBasicOps, self)._check_public_network_connectivity(
+ super(TestNetworkBasicOps, self).check_public_network_connectivity(
ip_address, ssh_login, private_key, should_connect, msg,
self.servers)
- self.check_floating_ip_status(floating_ip, floatingip_status)
+ if should_check_floating_ip_status:
+ self.check_floating_ip_status(floating_ip, floatingip_status)
def _disassociate_floating_ips(self):
floating_ip, server = self.floating_ip_tuple
@@ -325,7 +323,6 @@
LOG.exception("Unable to access {dest} via ssh to "
"floating-ip {src}".format(dest=remote_ip,
src=floating_ip))
- debug.log_ip_ns()
raise
@test.attr(type='smoke')
@@ -367,17 +364,17 @@
"""
self._setup_network_and_servers()
- self._check_public_network_connectivity(should_connect=True)
+ self.check_public_network_connectivity(should_connect=True)
self._check_network_internal_connectivity(network=self.network)
self._check_network_external_connectivity()
self._disassociate_floating_ips()
- self._check_public_network_connectivity(should_connect=False,
- msg="after disassociate "
- "floating ip")
+ self.check_public_network_connectivity(should_connect=False,
+ msg="after disassociate "
+ "floating ip")
self._reassociate_floating_ips()
- self._check_public_network_connectivity(should_connect=True,
- msg="after re-associate "
- "floating ip")
+ self.check_public_network_connectivity(should_connect=True,
+ msg="after re-associate "
+ "floating ip")
@testtools.skipUnless(CONF.compute_feature_enabled.interface_attach,
'NIC hotplug not available')
@@ -393,7 +390,38 @@
"""
self._setup_network_and_servers()
- self._check_public_network_connectivity(should_connect=True)
+ self.check_public_network_connectivity(should_connect=True)
self._create_new_network()
self._hotplug_server()
self._check_network_internal_connectivity(network=self.new_net)
+
+ @testtools.skipIf(CONF.baremetal.driver_enabled,
+ 'Router state cannot be altered on a shared baremetal '
+ 'network')
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
+ def test_update_router_admin_state(self):
+ """
+ 1. Check public connectivity before updating
+ admin_state_up attribute of router to False
+ 2. Check public connectivity after updating
+ admin_state_up attribute of router to False
+ 3. Check public connectivity after updating
+ admin_state_up attribute of router to True
+ """
+ self._setup_network_and_servers()
+ self.check_public_network_connectivity(
+ should_connect=True, msg="before updating "
+ "admin_state_up of router to False")
+ self._update_router_admin_state(self.router, False)
+ # TODO(alokmaurya): Remove should_check_floating_ip_status=False check
+ # once bug 1396310 is fixed
+
+ self.check_public_network_connectivity(
+ should_connect=False, msg="after updating "
+ "admin_state_up of router to False",
+ should_check_floating_ip_status=False)
+ self._update_router_admin_state(self.router, True)
+ self.check_public_network_connectivity(
+ should_connect=True, msg="after updating "
+ "admin_state_up of router to True")
diff --git a/tempest/scenario/test_network_v6.py b/tempest/scenario/test_network_v6.py
new file mode 100644
index 0000000..a75fa02
--- /dev/null
+++ b/tempest/scenario/test_network_v6.py
@@ -0,0 +1,148 @@
+# Copyright 2014 Cisco Systems, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+import netaddr
+from tempest import config
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest import test
+
+
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
+
+class TestGettingAddress(manager.NetworkScenarioTest):
+ """Create network with 2 subnets: IPv4 and IPv6 in a given address mode
+ Boot 2 VMs on this network
+ Allocate and assign 2 FIP4
+ Check that vNIC of server matches port data from OpenStack DB
+ Ping4 tenant IPv4 of one VM from another one
+ Will do the same with ping6 when available in VM
+ """
+
+ @classmethod
+ def resource_setup(cls):
+ # Create no network resources for these tests.
+ cls.set_network_resources()
+ super(TestGettingAddress, cls).resource_setup()
+
+ @classmethod
+ def check_preconditions(cls):
+ if not (CONF.network_feature_enabled.ipv6
+ and CONF.network_feature_enabled.ipv6_subnet_attributes):
+ raise cls.skipException('IPv6 or its attributes not supported')
+ if not (CONF.network.tenant_networks_reachable
+ or CONF.network.public_network_id):
+ msg = ('Either tenant_networks_reachable must be "true", or '
+ 'public_network_id must be defined.')
+ raise cls.skipException(msg)
+ if CONF.baremetal.driver_enabled:
+ msg = ('Baremetal does not currently support network isolation')
+ raise cls.skipException(msg)
+
+ super(TestGettingAddress, cls).check_preconditions()
+
+ def setUp(self):
+ super(TestGettingAddress, self).setUp()
+ self.keypair = self.create_keypair()
+ self.sec_grp = self._create_security_group(tenant_id=self.tenant_id)
+ self.srv_kwargs = {
+ 'key_name': self.keypair['name'],
+ 'security_groups': [self.sec_grp]}
+
+ def prepare_network(self, address6_mode):
+ """Creates network with
+ one IPv6 subnet in the given mode and
+ one IPv4 subnet
+ Creates router with ports on both subnets
+ """
+ net = self._create_network(tenant_id=self.tenant_id)
+ sub4 = self._create_subnet(network=net,
+ namestart='sub4',
+ ip_version=4,)
+ # since https://bugs.launchpad.net/neutron/+bug/1394112 we need
+ # to specify gateway_ip manually
+ net_range = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ gateway_ip = (netaddr.IPAddress(net_range) + 1).format()
+ sub6 = self._create_subnet(network=net,
+ namestart='sub6',
+ ip_version=6,
+ gateway_ip=gateway_ip,
+ ipv6_ra_mode=address6_mode,
+ ipv6_address_mode=address6_mode)
+
+ router = self._get_router(tenant_id=self.tenant_id)
+ sub4.add_to_router(router_id=router['id'])
+ sub6.add_to_router(router_id=router['id'])
+ self.addCleanup(sub4.delete)
+ self.addCleanup(sub6.delete)
+
+ @staticmethod
+ def define_server_ips(srv):
+ for net_name, nics in srv['addresses'].iteritems():
+ for nic in nics:
+ if nic['version'] == 6:
+ srv['accessIPv6'] = nic['addr']
+ else:
+ srv['accessIPv4'] = nic['addr']
+
+ def prepare_server(self):
+ username = CONF.compute.image_ssh_user
+
+ srv = self.create_server(create_kwargs=self.srv_kwargs)
+ fip = self.create_floating_ip(thing=srv)
+ self.define_server_ips(srv=srv)
+ ssh = self.get_remote_client(
+ server_or_ip=fip.floating_ip_address,
+ username=username)
+ return ssh, srv
+
+ def _prepare_and_test(self, address6_mode):
+ self.prepare_network(address6_mode=address6_mode)
+
+ ssh1, srv1 = self.prepare_server()
+ ssh2, srv2 = self.prepare_server()
+
+ result = ssh1.get_ip_list()
+ self.assertIn(srv1['accessIPv4'], result)
+ # v6 should be configured since the image supports it
+ self.assertIn(srv1['accessIPv6'], result)
+ result = ssh2.get_ip_list()
+ self.assertIn(srv2['accessIPv4'], result)
+ # v6 should be configured since the image supports it
+ self.assertIn(srv2['accessIPv6'], result)
+ result = ssh1.ping_host(srv2['accessIPv4'])
+ self.assertIn('0% packet loss', result)
+ result = ssh2.ping_host(srv1['accessIPv4'])
+ self.assertIn('0% packet loss', result)
+
+ # Some VM (like cirros) may not have ping6 utility
+ result = ssh1.exec_command('whereis ping6')
+ is_ping6 = False if result == 'ping6:\n' else True
+ if is_ping6:
+ result = ssh1.ping_host(srv2['accessIPv6'])
+ self.assertIn('0% packet loss', result)
+ result = ssh2.ping_host(srv1['accessIPv6'])
+ self.assertIn('0% packet loss', result)
+ else:
+ LOG.warning('Ping6 is not available, skipping')
+
+ @test.services('compute', 'network')
+ def test_slaac_from_os(self):
+ self._prepare_and_test(address6_mode='slaac')
+
+ @test.services('compute', 'network')
+ def test_dhcp6_stateless_from_os(self):
+ self._prepare_and_test(address6_mode='dhcpv6-stateless')
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 6ea3253..5e2a9d0 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -14,7 +14,6 @@
# under the License.
from tempest import clients
-from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
@@ -117,14 +116,12 @@
def check_preconditions(cls):
if CONF.baremetal.driver_enabled:
msg = ('Not currently supported by baremetal.')
- cls.enabled = False
raise cls.skipException(msg)
super(TestSecurityGroupsBasicOps, cls).check_preconditions()
if not (CONF.network.tenant_networks_reachable or
CONF.network.public_network_id):
msg = ('Either tenant_networks_reachable must be "true", or '
'public_network_id must be defined.')
- cls.enabled = False
raise cls.skipException(msg)
@classmethod
@@ -230,12 +227,13 @@
self._set_compute_context(tenant)
if security_groups is None:
security_groups = [tenant.security_groups['default']]
+ security_groups_names = [{'name': s['name']} for s in security_groups]
create_kwargs = {
'networks': [
{'uuid': tenant.network.id},
],
'key_name': tenant.keypair['name'],
- 'security_groups': security_groups,
+ 'security_groups': security_groups_names,
'tenant_id': tenant.creds.tenant_id
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
@@ -271,7 +269,7 @@
def _assign_floating_ips(self, tenant, server):
public_network_id = CONF.network.public_network_id
- floating_ip = self._create_floating_ip(
+ floating_ip = self.create_floating_ip(
server, public_network_id,
client=tenant.manager.network_client)
self.floating_ips.setdefault(server['id'], floating_ip)
@@ -333,15 +331,8 @@
msg = "Timed out waiting for %s to become reachable" % ip
else:
msg = "%s is reachable" % ip
- try:
- self.assertTrue(self._check_remote_connectivity(access_point, ip,
- should_succeed),
- msg)
- except test.exceptions.SSHTimeout:
- raise
- except Exception:
- debug.log_net_debug()
- raise
+ self.assertTrue(self._check_remote_connectivity(access_point, ip,
+ should_succeed), msg)
def _test_in_tenant_block(self, tenant):
access_point_ssh = self._connect_to_access_point(tenant)
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index eb636f7..23743c5 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -68,7 +68,7 @@
def boot_instance(self):
# Create server with image and flavor from input scenario
- security_groups = [self.security_group]
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'key_name': self.keypair['name'],
'security_groups': security_groups
@@ -88,15 +88,10 @@
self.floating_ips_client.associate_floating_ip_to_server(
floating_ip['ip'], self.instance['id'])
# Check ssh
- try:
- self.get_remote_client(
- server_or_ip=floating_ip['ip'],
- username=self.image_utils.ssh_user(self.image_ref),
- private_key=self.keypair['private_key'])
- except Exception:
- LOG.exception('ssh to server failed')
- self._log_console_output()
- raise
+ self.get_remote_client(
+ server_or_ip=floating_ip['ip'],
+ username=self.image_utils.ssh_user(self.image_ref),
+ private_key=self.keypair['private_key'])
@test.services('compute', 'network')
def test_server_basicops(self):
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
new file mode 100644
index 0000000..8882177
--- /dev/null
+++ b/tempest/scenario/test_shelve_instance.py
@@ -0,0 +1,97 @@
+# Copyright 2014 Scality
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from tempest import config
+from tempest.openstack.common import log
+from tempest.scenario import manager
+from tempest import test
+
+CONF = config.CONF
+
+LOG = log.getLogger(__name__)
+
+
+class TestShelveInstance(manager.ScenarioTest):
+ """
+ This test shelves then unshelves a Nova instance
+ The following is the scenario outline:
+ * boot a instance and create a timestamp file in it
+ * shelve the instance
+ * unshelve the instance
+ * check the existence of the timestamp file in the unshelved instance
+
+ """
+
+ def _write_timestamp(self, server_or_ip):
+ ssh_client = self.get_remote_client(server_or_ip)
+ ssh_client.exec_command('date > /tmp/timestamp; sync')
+ self.timestamp = ssh_client.exec_command('cat /tmp/timestamp')
+
+ def _check_timestamp(self, server_or_ip):
+ ssh_client = self.get_remote_client(server_or_ip)
+ got_timestamp = ssh_client.exec_command('cat /tmp/timestamp')
+ self.assertEqual(self.timestamp, got_timestamp)
+
+ def _shelve_then_unshelve_server(self, server):
+ self.servers_client.shelve_server(server['id'])
+ offload_time = CONF.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.servers_client.wait_for_server_status(
+ server['id'], 'SHELVED_OFFLOADED', extra_timeout=offload_time)
+ else:
+ self.servers_client.wait_for_server_status(server['id'], 'SHELVED')
+ self.servers_client.shelve_offload_server(server['id'])
+ self.servers_client.wait_for_server_status(server['id'],
+ 'SHELVED_OFFLOADED')
+ self.servers_client.unshelve_server(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ @testtools.skipUnless(CONF.compute_feature_enabled.shelve,
+ 'Shelve is not available.')
+ @test.services('compute', 'network', 'image')
+ def test_shelve_instance(self):
+ self.keypair = self.create_keypair()
+
+ self.security_group = self._create_security_group()
+ security_groups = [{'name': self.security_group['name']}]
+
+ create_kwargs = {
+ 'key_name': self.keypair['name'],
+ 'security_groups': security_groups
+ }
+ server = self.create_server(image=CONF.compute.image_ref,
+ create_kwargs=create_kwargs)
+
+ if CONF.compute.use_floatingip_for_ssh:
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], server['id'])
+ self._write_timestamp(floating_ip['ip'])
+ else:
+ self._write_timestamp(server)
+
+ # Prevent bug #1257594 from coming back
+ # Unshelve used to boot the instance with the original image, not
+ # with the instance snapshot
+ self._shelve_then_unshelve_server(server)
+ if CONF.compute.use_floatingip_for_ssh:
+ self._check_timestamp(floating_ip['ip'])
+ else:
+ self._check_timestamp(server)
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index dc32edc..5cb7c99 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -37,7 +37,7 @@
"""
def _boot_image(self, image_id):
- security_groups = [self.security_group]
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'key_name': self.keypair['name'],
'security_groups': security_groups
@@ -47,35 +47,16 @@
def _add_keypair(self):
self.keypair = self.create_keypair()
- def _ssh_to_server(self, server_or_ip):
- try:
- return self.get_remote_client(server_or_ip)
- except Exception:
- LOG.exception('Initializing SSH connection failed')
- self._log_console_output()
- raise
-
def _write_timestamp(self, server_or_ip):
- ssh_client = self._ssh_to_server(server_or_ip)
+ ssh_client = self.get_remote_client(server_or_ip)
ssh_client.exec_command('date > /tmp/timestamp; sync')
self.timestamp = ssh_client.exec_command('cat /tmp/timestamp')
def _check_timestamp(self, server_or_ip):
- ssh_client = self._ssh_to_server(server_or_ip)
+ ssh_client = self.get_remote_client(server_or_ip)
got_timestamp = ssh_client.exec_command('cat /tmp/timestamp')
self.assertEqual(self.timestamp, got_timestamp)
- def _create_floating_ip(self):
- _, floating_ip = self.floating_ips_client.create_floating_ip()
- self.addCleanup(self.delete_wrapper,
- self.floating_ips_client.delete_floating_ip,
- floating_ip['id'])
- return floating_ip
-
- def _set_floating_ip_to_server(self, server, floating_ip):
- self.floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], server['id'])
-
@testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
'Snapshotting is not available.')
@test.services('compute', 'network', 'image')
@@ -87,8 +68,7 @@
# boot a instance and create a timestamp file in it
server = self._boot_image(CONF.compute.image_ref)
if CONF.compute.use_floatingip_for_ssh:
- fip_for_server = self._create_floating_ip()
- self._set_floating_ip_to_server(server, fip_for_server)
+ fip_for_server = self.create_floating_ip(server)
self._write_timestamp(fip_for_server['ip'])
else:
self._write_timestamp(server)
@@ -101,9 +81,7 @@
# check the existence of the timestamp file in the second instance
if CONF.compute.use_floatingip_for_ssh:
- fip_for_snapshot = self._create_floating_ip()
- self._set_floating_ip_to_server(server_from_snapshot,
- fip_for_snapshot)
+ fip_for_snapshot = self.create_floating_ip(server_from_snapshot)
self._check_timestamp(fip_for_snapshot['ip'])
else:
self._check_timestamp(server_from_snapshot)
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index e30c824..cfc1d37 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -61,7 +61,7 @@
status)
def _boot_image(self, image_id):
- security_groups = [self.security_group]
+ security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'key_name': self.keypair['name'],
'security_groups': security_groups
@@ -71,17 +71,6 @@
def _add_keypair(self):
self.keypair = self.create_keypair()
- def _create_floating_ip(self):
- _, floating_ip = self.floating_ips_client.create_floating_ip()
- self.addCleanup(self.delete_wrapper,
- self.floating_ips_client.delete_floating_ip,
- floating_ip['id'])
- return floating_ip
-
- def _add_floating_ip(self, server, floating_ip):
- self.floating_ips_client.associate_floating_ip_to_server(
- floating_ip['ip'], server['id'])
-
def _ssh_to_server(self, server_or_ip):
return self.get_remote_client(server_or_ip)
@@ -163,8 +152,7 @@
# create and add floating IP to server1
if CONF.compute.use_floatingip_for_ssh:
- floating_ip_for_server = self._create_floating_ip()
- self._add_floating_ip(server, floating_ip_for_server)
+ floating_ip_for_server = self.create_floating_ip(server)
ip_for_server = floating_ip_for_server['ip']
else:
ip_for_server = server
@@ -189,9 +177,8 @@
# create and add floating IP to server_from_snapshot
if CONF.compute.use_floatingip_for_ssh:
- floating_ip_for_snapshot = self._create_floating_ip()
- self._add_floating_ip(server_from_snapshot,
- floating_ip_for_snapshot)
+ floating_ip_for_snapshot = self.create_floating_ip(
+ server_from_snapshot)
ip_for_snapshot = floating_ip_for_snapshot['ip']
else:
ip_for_snapshot = server_from_snapshot
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
index fcb9505..312fbc6 100644
--- a/tempest/scenario/test_swift_basic_ops.py
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -65,7 +65,10 @@
obj_name, _ = self.upload_object_to_container(container_name)
obj_url = '%s/%s/%s' % (self.object_client.base_url,
container_name, obj_name)
- http_client = http.ClosingHttp()
+ dscv = CONF.identity.disable_ssl_certificate_validation
+ ca_certs = CONF.identity.ca_certificates_file
+ http_client = http.ClosingHttp(
+ disable_ssl_certificate_validation=dscv, ca_certs=ca_certs)
resp, _ = http_client.request(obj_url, 'GET')
self.assertEqual(resp.status, 401)
self.change_container_acl(container_name, '.r:*')
diff --git a/tempest/scenario/test_swift_telemetry_middleware.py b/tempest/scenario/test_swift_telemetry_middleware.py
index e4b6cba..e8eb45c 100644
--- a/tempest/scenario/test_swift_telemetry_middleware.py
+++ b/tempest/scenario/test_swift_telemetry_middleware.py
@@ -51,6 +51,9 @@
skip_msg = ("%s skipped as ceilometer is not available" %
cls.__name__)
raise cls.skipException(skip_msg)
+ elif CONF.telemetry.too_slow_to_test:
+ skip_msg = "Ceilometer feature for fast work mysql is disabled"
+ raise cls.skipException(skip_msg)
super(TestSwiftTelemetry, cls).resource_setup()
cls.telemetry_client = cls.manager.telemetry_client
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 62876c4..c584a6e 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -110,14 +110,8 @@
network_name_for_ssh = CONF.compute.network_for_ssh
ip = server.networks[network_name_for_ssh][0]
- try:
- return self.get_remote_client(
- ip,
- private_key=keypair['private_key'])
- except Exception:
- LOG.exception('ssh to server failed')
- self._log_console_output(servers=[server])
- raise
+ return self.get_remote_client(ip, private_key=keypair['private_key'],
+ log_console_of_servers=[server])
def _get_content(self, ssh_client):
return ssh_client.exec_command('cat /tmp/text')
@@ -136,6 +130,7 @@
actual = self._get_content(ssh_client)
self.assertEqual(expected, actual)
+ @test.skip_because(bug='1373513')
@test.services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index 7af904b..f581e89 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -38,6 +38,7 @@
# FIXME(andreaf) replace credentials and auth_url with auth_provider
insecure_ssl = CONF.identity.disable_ssl_certificate_validation
+ ca_cert = CONF.identity.ca_certificates_file
self.connection_timeout = str(CONF.boto.http_socket_timeout)
self.num_retries = str(CONF.boto.num_retries)
@@ -46,7 +47,8 @@
"password": password,
"auth_url": auth_url,
"tenant_name": tenant_name,
- "insecure": insecure_ssl}
+ "insecure": insecure_ssl,
+ "cacert": ca_cert}
def _keystone_aws_get(self):
# FIXME(andreaf) Move EC2 credentials to AuthProvider
diff --git a/tempest/services/compute/json/interfaces_client.py b/tempest/services/compute/json/interfaces_client.py
index 83c253a..620ed68 100644
--- a/tempest/services/compute/json/interfaces_client.py
+++ b/tempest/services/compute/json/interfaces_client.py
@@ -79,9 +79,10 @@
timed_out = int(time.time()) - start >= self.build_timeout
if interface_status != status and timed_out:
- message = ('Interface %s failed to reach %s status within '
- 'the required time (%s s).' %
- (port_id, status, self.build_timeout))
+ message = ('Interface %s failed to reach %s status '
+ '(current %s) within the required time (%s s).' %
+ (port_id, status, interface_status,
+ self.build_timeout))
raise exceptions.TimeoutException(message)
return resp, body
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 309dc5b..afa6937 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -73,10 +73,9 @@
metadata: A dictionary of values to be used as metadata.
"""
post_body = {
- 'size': size,
- 'display_name': kwargs.get('display_name'),
- 'metadata': kwargs.get('metadata'),
+ 'size': size
}
+ post_body.update(kwargs)
post_body = json.dumps({'volume': post_body})
resp, body = self.post('os-volumes', post_body)
@@ -93,7 +92,6 @@
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""
resp, body = self.get_volume(volume_id)
- volume_name = body['displayName']
volume_status = body['status']
start = int(time.time())
@@ -105,9 +103,10 @@
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
if int(time.time()) - start >= self.build_timeout:
- message = ('Volume %s failed to reach %s status within '
- 'the required time (%s s).' %
- (volume_name, status, self.build_timeout))
+ message = ('Volume %s failed to reach %s status (current %s) '
+ 'within the required time (%s s).' %
+ (volume_id, status, volume_status,
+ self.build_timeout))
raise exceptions.TimeoutException(message)
def is_resource_deleted(self, id):
diff --git a/tempest/services/compute/v3/__init__.py b/tempest/services/compute/v3/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/compute/v3/__init__.py
+++ /dev/null
diff --git a/tempest/services/compute/v3/json/__init__.py b/tempest/services/compute/v3/json/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/compute/v3/json/__init__.py
+++ /dev/null
diff --git a/tempest/services/compute/v3/json/agents_client.py b/tempest/services/compute/v3/json/agents_client.py
deleted file mode 100644
index ffca142..0000000
--- a/tempest/services/compute/v3/json/agents_client.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from tempest.api_schema.response.compute import agents as common_schema
-from tempest.api_schema.response.compute.v3 import agents as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class AgentsV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(AgentsV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_agents(self, params=None):
- """List all agent builds."""
- url = 'os-agents'
- if params:
- url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(common_schema.list_agents, resp, body)
- return resp, body['agents']
-
- def create_agent(self, **kwargs):
- """Create an agent build."""
- post_body = json.dumps({'agent': kwargs})
- resp, body = self.post('os-agents', post_body)
- body = json.loads(body)
- self.validate_response(schema.create_agent, resp, body)
- return resp, body['agent']
-
- def delete_agent(self, agent_id):
- """Delete an existing agent build."""
- resp, body = self.delete("os-agents/%s" % str(agent_id))
- self.validate_response(schema.delete_agent, resp, body)
- return resp, body
-
- def update_agent(self, agent_id, **kwargs):
- """Update an agent build."""
- put_body = json.dumps({'agent': kwargs})
- resp, body = self.put('os-agents/%s' % str(agent_id), put_body)
- return resp, self._parse_resp(body)
diff --git a/tempest/services/compute/v3/json/aggregates_client.py b/tempest/services/compute/v3/json/aggregates_client.py
deleted file mode 100644
index e11ed45..0000000
--- a/tempest/services/compute/v3/json/aggregates_client.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute import aggregates as schema
-from tempest.api_schema.response.compute.v3 import aggregates as v3_schema
-from tempest.common import rest_client
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class AggregatesV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(AggregatesV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_aggregates(self):
- """Get aggregate list."""
- resp, body = self.get("os-aggregates")
- body = json.loads(body)
- self.validate_response(schema.list_aggregates, resp, body)
- return resp, body['aggregates']
-
- def get_aggregate(self, aggregate_id):
- """Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
- body = json.loads(body)
- self.validate_response(schema.get_aggregate, resp, body)
- return resp, body['aggregate']
-
- def create_aggregate(self, **kwargs):
- """Creates a new aggregate."""
- post_body = json.dumps({'aggregate': kwargs})
- resp, body = self.post('os-aggregates', post_body)
-
- body = json.loads(body)
- self.validate_response(v3_schema.create_aggregate, resp, body)
- return resp, body['aggregate']
-
- def update_aggregate(self, aggregate_id, name, availability_zone=None):
- """Update a aggregate."""
- put_body = {
- 'name': name,
- 'availability_zone': availability_zone
- }
- put_body = json.dumps({'aggregate': put_body})
- resp, body = self.put('os-aggregates/%s' % str(aggregate_id), put_body)
-
- body = json.loads(body)
- self.validate_response(schema.update_aggregate, resp, body)
- return resp, body['aggregate']
-
- def delete_aggregate(self, aggregate_id):
- """Deletes the given aggregate."""
- resp, body = self.delete("os-aggregates/%s" % str(aggregate_id))
- self.validate_response(v3_schema.delete_aggregate, resp, body)
- return resp, body
-
- def is_resource_deleted(self, id):
- try:
- self.get_aggregate(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'aggregate'
-
- def add_host(self, aggregate_id, host):
- """Adds a host to the given aggregate."""
- post_body = {
- 'host': host,
- }
- post_body = json.dumps({'add_host': post_body})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(v3_schema.aggregate_add_remove_host, resp, body)
- return resp, body['aggregate']
-
- def remove_host(self, aggregate_id, host):
- """Removes a host from the given aggregate."""
- post_body = {
- 'host': host,
- }
- post_body = json.dumps({'remove_host': post_body})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(v3_schema.aggregate_add_remove_host, resp, body)
- return resp, body['aggregate']
-
- def set_metadata(self, aggregate_id, meta):
- """Replaces the aggregate's existing metadata with new metadata."""
- post_body = {
- 'metadata': meta,
- }
- post_body = json.dumps({'set_metadata': post_body})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_set_metadata, resp, body)
- return resp, body['aggregate']
diff --git a/tempest/services/compute/v3/json/availability_zone_client.py b/tempest/services/compute/v3/json/availability_zone_client.py
deleted file mode 100644
index 0da78da..0000000
--- a/tempest/services/compute/v3/json/availability_zone_client.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute.v3 import availability_zone as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class AvailabilityZoneV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(AvailabilityZoneV3ClientJSON, self).__init__(
- auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def get_availability_zone_list(self):
- resp, body = self.get('os-availability-zone')
- body = json.loads(body)
- self.validate_response(schema.get_availability_zone_list, resp, body)
- return resp, body['availability_zone_info']
-
- def get_availability_zone_list_detail(self):
- resp, body = self.get('os-availability-zone/detail')
- body = json.loads(body)
- self.validate_response(schema.get_availability_zone_list_detail, resp,
- body)
- return resp, body['availability_zone_info']
diff --git a/tempest/services/compute/v3/json/certificates_client.py b/tempest/services/compute/v3/json/certificates_client.py
deleted file mode 100644
index 42e9d5a..0000000
--- a/tempest/services/compute/v3/json/certificates_client.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute import certificates as schema
-from tempest.api_schema.response.compute.v3 import certificates as v3schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class CertificatesV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(CertificatesV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def get_certificate(self, id):
- url = "os-certificates/%s" % (id)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.get_certificate, resp, body)
- return resp, body['certificate']
-
- def create_certificate(self):
- """create certificates."""
- url = "os-certificates"
- resp, body = self.post(url, None)
- body = json.loads(body)
- self.validate_response(v3schema.create_certificate, resp, body)
- return resp, body['certificate']
diff --git a/tempest/services/compute/v3/json/extensions_client.py b/tempest/services/compute/v3/json/extensions_client.py
deleted file mode 100644
index f172efd..0000000
--- a/tempest/services/compute/v3/json/extensions_client.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute.v3 import extensions as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class ExtensionsV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(ExtensionsV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_extensions(self):
- url = 'extensions'
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_extensions, resp, body)
- return resp, body['extensions']
-
- def is_enabled(self, extension):
- _, extensions = self.list_extensions()
- exts = extensions['extensions']
- return any([e for e in exts if e['name'] == extension])
-
- def get_extension(self, extension_alias):
- resp, body = self.get('extensions/%s' % extension_alias)
- body = json.loads(body)
- return resp, body['extension']
diff --git a/tempest/services/compute/v3/json/flavors_client.py b/tempest/services/compute/v3/json/flavors_client.py
deleted file mode 100644
index fdca6b3..0000000
--- a/tempest/services/compute/v3/json/flavors_client.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from tempest.api_schema.response.compute import flavors as common_schema
-from tempest.api_schema.response.compute import flavors_access as schema_access
-from tempest.api_schema.response.compute import flavors_extra_specs \
- as schema_extra_specs
-from tempest.api_schema.response.compute.v3 import flavors as v3schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class FlavorsV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(FlavorsV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_flavors(self, params=None):
- url = 'flavors'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(common_schema.list_flavors, resp, body)
- return resp, body['flavors']
-
- def list_flavors_with_detail(self, params=None):
- url = 'flavors/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(v3schema.list_flavors_details, resp, body)
- return resp, body['flavors']
-
- def get_flavor_details(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(flavor_id))
- body = json.loads(body)
- self.validate_response(v3schema.get_flavor_details, resp, body)
- return resp, body['flavor']
-
- def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
- """Creates a new flavor or instance type."""
- post_body = {
- 'name': name,
- 'ram': ram,
- 'vcpus': vcpus,
- 'disk': disk,
- 'id': flavor_id,
- }
- if kwargs.get('ephemeral'):
- post_body['ephemeral'] = kwargs.get('ephemeral')
- if kwargs.get('swap'):
- post_body['swap'] = kwargs.get('swap')
- if kwargs.get('rxtx'):
- post_body['os-flavor-rxtx:rxtx_factor'] = kwargs.get('rxtx')
- if kwargs.get('is_public'):
- post_body['flavor-access:is_public'] = kwargs.get('is_public')
- post_body = json.dumps({'flavor': post_body})
- resp, body = self.post('flavors', post_body)
-
- body = json.loads(body)
- self.validate_response(v3schema.create_flavor_details, resp, body)
- return resp, body['flavor']
-
- def delete_flavor(self, flavor_id):
- """Deletes the given flavor."""
- resp, body = self.delete("flavors/{0}".format(flavor_id))
- self.validate_response(v3schema.delete_flavor, resp, body)
- return resp, body
-
- def is_resource_deleted(self, id):
- # Did not use get_flavor_details(id) for verification as it gives
- # 200 ok even for deleted id. LP #981263
- # we can remove the loop here and use get by ID when bug gets sortedout
- resp, flavors = self.list_flavors_with_detail()
- for flavor in flavors:
- if flavor['id'] == id:
- return False
- return True
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'flavor'
-
- def set_flavor_extra_spec(self, flavor_id, specs):
- """Sets extra Specs to the mentioned flavor."""
- post_body = json.dumps({'extra_specs': specs})
- resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
- post_body)
- body = json.loads(body)
- self.validate_response(v3schema.set_flavor_extra_specs, resp, body)
- return resp, body['extra_specs']
-
- def get_flavor_extra_spec(self, flavor_id):
- """Gets extra Specs details of the mentioned flavor."""
- resp, body = self.get('flavors/%s/flavor-extra-specs' % flavor_id)
- body = json.loads(body)
- self.validate_response(schema_extra_specs.flavor_extra_specs,
- resp, body)
- return resp, body['extra_specs']
-
- def get_flavor_extra_spec_with_key(self, flavor_id, key):
- """Gets extra Specs key-value of the mentioned flavor and key."""
- resp, body = self.get('flavors/%s/flavor-extra-specs/%s' %
- (str(flavor_id), key))
- body = json.loads(body)
- self.validate_response(schema_extra_specs.flavor_extra_specs_key,
- resp, body)
- return resp, body
-
- def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
- """Update specified extra Specs of the mentioned flavor and key."""
- resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
- (flavor_id, key), json.dumps(kwargs))
- body = json.loads(body)
- self.validate_response(schema_extra_specs.flavor_extra_specs_key,
- resp, body)
- return resp, body
-
- def unset_flavor_extra_spec(self, flavor_id, key):
- """Unsets extra Specs from the mentioned flavor."""
- resp, body = self.delete('flavors/%s/flavor-extra-specs/%s' %
- (str(flavor_id), key))
- self.validate_response(v3schema.unset_flavor_extra_specs, resp, body)
- return resp, body
-
- def list_flavor_access(self, flavor_id):
- """Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/flavor-access' % flavor_id)
- body = json.loads(body)
- self.validate_response(schema_access.add_remove_list_flavor_access,
- resp, body)
- return resp, body['flavor_access']
-
- def add_flavor_access(self, flavor_id, tenant_id):
- """Add flavor access for the specified tenant."""
- post_body = {
- 'add_tenant_access': {
- 'tenant_id': tenant_id
- }
- }
- post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
- body = json.loads(body)
- self.validate_response(schema_access.add_remove_list_flavor_access,
- resp, body)
- return resp, body['flavor_access']
-
- def remove_flavor_access(self, flavor_id, tenant_id):
- """Remove flavor access from the specified tenant."""
- post_body = {
- 'remove_tenant_access': {
- 'tenant_id': tenant_id
- }
- }
- post_body = json.dumps(post_body)
- resp, body = self.post('flavors/%s/action' % flavor_id, post_body)
- body = json.loads(body)
- self.validate_response(schema_access.add_remove_list_flavor_access,
- resp, body)
- return resp, body['flavor_access']
diff --git a/tempest/services/compute/v3/json/hosts_client.py b/tempest/services/compute/v3/json/hosts_client.py
deleted file mode 100644
index 476afad..0000000
--- a/tempest/services/compute/v3/json/hosts_client.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from tempest.api_schema.response.compute import hosts as schema
-from tempest.api_schema.response.compute.v3 import hosts as v3_schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class HostsV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(HostsV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_hosts(self, params=None):
- """Lists all hosts."""
-
- url = 'os-hosts'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_hosts, resp, body)
- return resp, body['hosts']
-
- def show_host_detail(self, hostname):
- """Show detail information for the host."""
-
- resp, body = self.get("os-hosts/%s" % str(hostname))
- body = json.loads(body)
- self.validate_response(schema.show_host_detail, resp, body)
- return resp, body['host']
-
- def update_host(self, hostname, **kwargs):
- """Update a host."""
-
- request_body = {
- 'status': None,
- 'maintenance_mode': None,
- }
- request_body.update(**kwargs)
- request_body = json.dumps({'host': request_body})
-
- resp, body = self.put("os-hosts/%s" % str(hostname), request_body)
- body = json.loads(body)
- self.validate_response(v3_schema.update_host, resp, body)
- return resp, body
-
- def startup_host(self, hostname):
- """Startup a host."""
-
- resp, body = self.get("os-hosts/%s/startup" % str(hostname))
- body = json.loads(body)
- self.validate_response(v3_schema.startup_host, resp, body)
- return resp, body['host']
-
- def shutdown_host(self, hostname):
- """Shutdown a host."""
-
- resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
- body = json.loads(body)
- self.validate_response(v3_schema.shutdown_host, resp, body)
- return resp, body['host']
-
- def reboot_host(self, hostname):
- """reboot a host."""
-
- resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
- body = json.loads(body)
- self.validate_response(v3_schema.reboot_host, resp, body)
- return resp, body['host']
diff --git a/tempest/services/compute/v3/json/hypervisor_client.py b/tempest/services/compute/v3/json/hypervisor_client.py
deleted file mode 100644
index 507157a..0000000
--- a/tempest/services/compute/v3/json/hypervisor_client.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# Copyright 2013 IBM Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute import hypervisors as common_schema
-from tempest.api_schema.response.compute.v3 import hypervisors as v3schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class HypervisorV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(HypervisorV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def get_hypervisor_list(self):
- """List hypervisors information."""
- resp, body = self.get('os-hypervisors')
- body = json.loads(body)
- self.validate_response(common_schema.common_hypervisors_detail,
- resp, body)
- return resp, body['hypervisors']
-
- def get_hypervisor_list_details(self):
- """Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail')
- body = json.loads(body)
- self.validate_response(v3schema.list_hypervisors_detail, resp, body)
- return resp, body['hypervisors']
-
- def get_hypervisor_show_details(self, hyper_id):
- """Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hyper_id)
- body = json.loads(body)
- self.validate_response(v3schema.show_hypervisor, resp, body)
- return resp, body['hypervisor']
-
- def get_hypervisor_servers(self, hyper_name):
- """List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
- body = json.loads(body)
- self.validate_response(v3schema.hypervisors_servers, resp, body)
- return resp, body['hypervisor']
-
- def get_hypervisor_stats(self):
- """Get hypervisor statistics over all compute nodes."""
- resp, body = self.get('os-hypervisors/statistics')
- body = json.loads(body)
- self.validate_response(common_schema.hypervisor_statistics, resp, body)
- return resp, body['hypervisor_statistics']
-
- def get_hypervisor_uptime(self, hyper_id):
- """Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
- body = json.loads(body)
- self.validate_response(common_schema.hypervisor_uptime, resp, body)
- return resp, body['hypervisor']
-
- def search_hypervisor(self, hyper_name):
- """Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/search?query=%s' % hyper_name)
- body = json.loads(body)
- self.validate_response(common_schema.common_hypervisors_detail,
- resp, body)
- return resp, body['hypervisors']
diff --git a/tempest/services/compute/v3/json/interfaces_client.py b/tempest/services/compute/v3/json/interfaces_client.py
deleted file mode 100644
index e99c124..0000000
--- a/tempest/services/compute/v3/json/interfaces_client.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import time
-
-from tempest.api_schema.response.compute import interfaces as common_schema
-from tempest.api_schema.response.compute import servers as servers_schema
-from tempest.api_schema.response.compute.v3 import interfaces as schema
-from tempest.common import rest_client
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class InterfacesV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(InterfacesV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_interfaces(self, server):
- resp, body = self.get('servers/%s/os-attach-interfaces' % server)
- body = json.loads(body)
- self.validate_response(schema.list_interfaces, resp, body)
- return resp, body['interface_attachments']
-
- def create_interface(self, server, port_id=None, network_id=None,
- fixed_ip=None):
- post_body = dict()
- if port_id:
- post_body['port_id'] = port_id
- if network_id:
- post_body['net_id'] = network_id
- if fixed_ip:
- post_body['fixed_ips'] = [dict(ip_address=fixed_ip)]
- post_body = json.dumps({'interface_attachment': post_body})
- resp, body = self.post('servers/%s/os-attach-interfaces' % server,
- body=post_body)
- body = json.loads(body)
- return resp, body['interface_attachment']
-
- def show_interface(self, server, port_id):
- resp, body =\
- self.get('servers/%s/os-attach-interfaces/%s' % (server, port_id))
- body = json.loads(body)
- return resp, body['interface_attachment']
-
- def delete_interface(self, server, port_id):
- resp, body =\
- self.delete('servers/%s/os-attach-interfaces/%s' % (server,
- port_id))
- self.validate_response(common_schema.delete_interface, resp, body)
- return resp, body
-
- def wait_for_interface_status(self, server, port_id, status):
- """Waits for a interface to reach a given status."""
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
- start = int(time.time())
-
- while(interface_status != status):
- time.sleep(self.build_interval)
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
-
- timed_out = int(time.time()) - start >= self.build_timeout
-
- if interface_status != status and timed_out:
- message = ('Interface %s failed to reach %s status within '
- 'the required time (%s s).' %
- (port_id, status, self.build_timeout))
- raise exceptions.TimeoutException(message)
-
- return resp, body
-
- def add_fixed_ip(self, server_id, network_id):
- """Add a fixed IP to input server instance."""
- post_body = json.dumps({
- 'add_fixed_ip': {
- 'network_id': network_id
- }
- })
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body)
- self.validate_response(servers_schema.server_actions_common_schema,
- resp, body)
- return resp, body
-
- def remove_fixed_ip(self, server_id, ip_address):
- """Remove input fixed IP from input server instance."""
- post_body = json.dumps({
- 'remove_fixed_ip': {
- 'address': ip_address
- }
- })
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body)
- self.validate_response(servers_schema.server_actions_common_schema,
- resp, body)
- return resp, body
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
deleted file mode 100644
index a290acb..0000000
--- a/tempest/services/compute/v3/json/keypairs_client.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute import keypairs as common_schema
-from tempest.api_schema.response.compute.v3 import keypairs as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class KeyPairsV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(KeyPairsV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_keypairs(self):
- resp, body = self.get("keypairs")
- body = json.loads(body)
- # Each returned keypair is embedded within an unnecessary 'keypair'
- # element which is a deviation from other resources like floating-ips,
- # servers, etc. A bug?
- # For now we shall adhere to the spec, but the spec for keypairs
- # is yet to be found
- self.validate_response(common_schema.list_keypairs, resp, body)
- return resp, body['keypairs']
-
- def get_keypair(self, key_name):
- resp, body = self.get("keypairs/%s" % str(key_name))
- body = json.loads(body)
- self.validate_response(schema.get_keypair, resp, body)
- return resp, body['keypair']
-
- def create_keypair(self, name, pub_key=None):
- post_body = {'keypair': {'name': name}}
- if pub_key:
- post_body['keypair']['public_key'] = pub_key
- post_body = json.dumps(post_body)
- resp, body = self.post("keypairs", body=post_body)
- body = json.loads(body)
- self.validate_response(schema.create_keypair, resp, body)
- return resp, body['keypair']
-
- def delete_keypair(self, key_name):
- resp, body = self.delete("keypairs/%s" % str(key_name))
- self.validate_response(schema.delete_keypair, resp, body)
- return resp, body
diff --git a/tempest/services/compute/v3/json/migration_client.py b/tempest/services/compute/v3/json/migration_client.py
deleted file mode 100644
index bf1ae85..0000000
--- a/tempest/services/compute/v3/json/migration_client.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2014 NEC Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from tempest.api_schema.response.compute import migrations as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class MigrationsV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(MigrationsV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_migrations(self, params=None):
- """Lists all migrations."""
-
- url = 'os-migrations'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_migrations, resp, body)
- return resp, body['migrations']
diff --git a/tempest/services/compute/v3/json/quotas_client.py b/tempest/services/compute/v3/json/quotas_client.py
deleted file mode 100644
index f9aa9e9..0000000
--- a/tempest/services/compute/v3/json/quotas_client.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Copyright 2012 NTT Data
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute.v3 import quotas as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class QuotasV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(QuotasV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def get_quota_set(self, tenant_id, user_id=None):
- """List the quota set for a tenant."""
-
- url = 'os-quota-sets/%s' % str(tenant_id)
- if user_id:
- url += '?user_id=%s' % str(user_id)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.quota_set, resp, body)
- return resp, body['quota_set']
-
- def get_quota_set_detail(self, tenant_id):
- """Get the quota set detail for a tenant."""
-
- url = 'os-quota-sets/%s/detail' % str(tenant_id)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.quota_set_detail, resp, body)
- return resp, body['quota_set']
-
- def get_default_quota_set(self, tenant_id):
- """List the default quota set for a tenant."""
-
- url = 'os-quota-sets/%s/defaults' % str(tenant_id)
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.quota_set, resp, body)
- return resp, body['quota_set']
-
- def update_quota_set(self, tenant_id, user_id=None, force=None,
- metadata_items=None, ram=None, floating_ips=None,
- fixed_ips=None, key_pairs=None, instances=None,
- security_group_rules=None, cores=None,
- security_groups=None):
- """
- Updates the tenant's quota limits for one or more resources
- """
- post_body = {}
-
- if force is not None:
- post_body['force'] = force
-
- if metadata_items is not None:
- post_body['metadata_items'] = metadata_items
-
- if ram is not None:
- post_body['ram'] = ram
-
- if floating_ips is not None:
- post_body['floating_ips'] = floating_ips
-
- if fixed_ips is not None:
- post_body['fixed_ips'] = fixed_ips
-
- if key_pairs is not None:
- post_body['key_pairs'] = key_pairs
-
- if instances is not None:
- post_body['instances'] = instances
-
- if security_group_rules is not None:
- post_body['security_group_rules'] = security_group_rules
-
- if cores is not None:
- post_body['cores'] = cores
-
- if security_groups is not None:
- post_body['security_groups'] = security_groups
-
- post_body = json.dumps({'quota_set': post_body})
-
- if user_id:
- resp, body = self.put('os-quota-sets/%s?user_id=%s' %
- (str(tenant_id), str(user_id)), post_body)
- else:
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
- post_body)
-
- body = json.loads(body)
- self.validate_response(schema.quota_set, resp, body)
- return resp, body['quota_set']
-
- def delete_quota_set(self, tenant_id):
- """Delete the tenant's quota set."""
- resp, body = self.delete('os-quota-sets/%s' % str(tenant_id))
- self.validate_response(schema.delete_quota, resp, body)
- return resp, body
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
deleted file mode 100644
index 89e282d..0000000
--- a/tempest/services/compute/v3/json/servers_client.py
+++ /dev/null
@@ -1,531 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import time
-import urllib
-
-from tempest.api_schema.response.compute import servers as common_schema
-from tempest.api_schema.response.compute.v3 import servers as schema
-from tempest.common import rest_client
-from tempest.common import waiters
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class ServersV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(ServersV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def create_server(self, name, image_ref, flavor_ref, **kwargs):
- """
- Creates an instance of a server.
- name (Required): The name of the server.
- image_ref (Required): Reference to the image used to build the server.
- flavor_ref (Required): The flavor used to build the server.
- Following optional keyword arguments are accepted:
- admin_password: Sets the initial root password.
- key_name: Key name of keypair that was created earlier.
- meta: A dictionary of values to be used as metadata.
- security_groups: A list of security group dicts.
- networks: A list of network dicts with UUID and fixed_ip.
- user_data: User data for instance.
- availability_zone: Availability zone in which to launch instance.
- access_ip_v4: The IPv4 access address for the server.
- access_ip_v6: The IPv6 access address for the server.
- min_count: Count of minimum number of instances to launch.
- max_count: Count of maximum number of instances to launch.
- disk_config: Determines if user or admin controls disk configuration.
- return_reservation_id: Enable/Disable the return of reservation id
- block_device_mapping: Block device mapping for the server.
- """
- post_body = {
- 'name': name,
- 'image_ref': image_ref,
- 'flavor_ref': flavor_ref
- }
-
- for option in ['admin_password', 'key_name', 'networks',
- ('os-security-groups:security_groups',
- 'security_groups'),
- ('os-user-data:user_data', 'user_data'),
- ('os-availability-zone:availability_zone',
- 'availability_zone'),
- ('os-access-ips:access_ip_v4', 'access_ip_v4'),
- ('os-access-ips:access_ip_v6', 'access_ip_v6'),
- ('os-multiple-create:min_count', 'min_count'),
- ('os-multiple-create:max_count', 'max_count'),
- ('metadata', 'meta'),
- ('os-disk-config:disk_config', 'disk_config'),
- ('os-multiple-create:return_reservation_id',
- 'return_reservation_id'),
- ('os-block-device-mapping:block_device_mapping',
- 'block_device_mapping')]:
- if isinstance(option, tuple):
- post_param = option[0]
- key = option[1]
- else:
- post_param = option
- key = option
- value = kwargs.get(key)
- if value is not None:
- post_body[post_param] = value
- post_body = json.dumps({'server': post_body})
- resp, body = self.post('servers', post_body)
-
- body = json.loads(body)
- # NOTE(maurosr): this deals with the case of multiple server create
- # with return reservation id set True
- if 'servers_reservation' in body:
- return resp, body['servers_reservation']
- if CONF.compute_feature_enabled.enable_instance_password:
- create_schema = schema.create_server_with_admin_pass
- else:
- create_schema = schema.create_server
- self.validate_response(create_schema, resp, body)
- return resp, body['server']
-
- def update_server(self, server_id, name=None, meta=None, access_ip_v4=None,
- access_ip_v6=None, disk_config=None):
- """
- Updates the properties of an existing server.
- server_id: The id of an existing server.
- name: The name of the server.
- access_ip_v4: The IPv4 access address for the server.
- access_ip_v6: The IPv6 access address for the server.
- """
-
- post_body = {}
-
- if meta is not None:
- post_body['metadata'] = meta
-
- if name is not None:
- post_body['name'] = name
-
- if access_ip_v4 is not None:
- post_body['os-access-ips:access_ip_v4'] = access_ip_v4
-
- if access_ip_v6 is not None:
- post_body['os-access-ips:access_ip_v6'] = access_ip_v6
-
- if disk_config is not None:
- post_body['os-disk-config:disk_config'] = disk_config
-
- post_body = json.dumps({'server': post_body})
- resp, body = self.put("servers/%s" % str(server_id), post_body)
- body = json.loads(body)
- self.validate_response(schema.update_server, resp, body)
- return resp, body['server']
-
- def get_server(self, server_id):
- """Returns the details of an existing server."""
- resp, body = self.get("servers/%s" % str(server_id))
- body = json.loads(body)
- self.validate_response(schema.get_server, resp, body)
- return resp, body['server']
-
- def delete_server(self, server_id):
- """Deletes the given server."""
- resp, body = self.delete("servers/%s" % str(server_id))
- self.validate_response(common_schema.delete_server, resp, body)
- return resp, body
-
- def list_servers(self, params=None):
- """Lists all servers for a user."""
-
- url = 'servers'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(common_schema.list_servers, resp, body)
- return resp, body
-
- def list_servers_with_detail(self, params=None):
- """Lists all servers in detail for a user."""
-
- url = 'servers/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_servers_detail, resp, body)
- return resp, body
-
- def wait_for_server_status(self, server_id, status, extra_timeout=0,
- raise_on_error=True):
- """Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status,
- extra_timeout=extra_timeout,
- raise_on_error=raise_on_error)
-
- def wait_for_server_termination(self, server_id, ignore_error=False):
- """Waits for server to reach termination."""
- start_time = int(time.time())
- while True:
- try:
- resp, body = self.get_server(server_id)
- except exceptions.NotFound:
- return
-
- server_status = body['status']
- if server_status == 'ERROR' and not ignore_error:
- raise exceptions.BuildErrorException(server_id=server_id)
-
- if int(time.time()) - start_time >= self.build_timeout:
- raise exceptions.TimeoutException
-
- time.sleep(self.build_interval)
-
- def list_addresses(self, server_id):
- """Lists all addresses for a server."""
- resp, body = self.get("servers/%s/ips" % str(server_id))
- body = json.loads(body)
- self.validate_response(schema.list_addresses, resp, body)
- return resp, body['addresses']
-
- def list_addresses_by_network(self, server_id, network_id):
- """Lists all addresses of a specific network type for a server."""
- resp, body = self.get("servers/%s/ips/%s" %
- (str(server_id), network_id))
- body = json.loads(body)
- self.validate_response(schema.list_addresses_by_network, resp, body)
- return resp, body
-
- def action(self, server_id, action_name, response_key,
- schema=common_schema.server_actions_common_schema, **kwargs):
- post_body = json.dumps({action_name: kwargs})
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body)
- if response_key is not None:
- body = json.loads(body)
- # Check for Schema as 'None' because if we do not have any server
- # action schema implemented yet then they can pass 'None' to skip
- # the validation.Once all server action has their schema
- # implemented then, this check can be removed if every actions are
- # supposed to validate their response.
- # TODO(GMann): Remove the below 'if' check once all server actions
- # schema are implemented.
- if schema is not None:
- self.validate_response(schema, resp, body)
- body = body[response_key]
- else:
- self.validate_response(schema, resp, body)
- return resp, body
-
- def create_backup(self, server_id, backup_type, rotation, name):
- """Backup a server instance."""
- return self.action(server_id, "create_backup", None,
- backup_type=backup_type,
- rotation=rotation,
- name=name)
-
- def change_password(self, server_id, admin_password):
- """Changes the root password for the server."""
- return self.action(server_id, 'change_password',
- None, schema.server_actions_change_password,
- admin_password=admin_password)
-
- def get_password(self, server_id):
- resp, body = self.get("servers/%s/os-server-password" %
- str(server_id))
- body = json.loads(body)
- self.validate_response(common_schema.get_password, resp, body)
- return resp, body
-
- def delete_password(self, server_id):
- """
- Removes the encrypted server password from the metadata server
- Note that this does not actually change the instance server
- password.
- """
- resp, body = self.delete("servers/%s/os-server-password" %
- str(server_id))
- self.validate_response(common_schema.server_actions_delete_password,
- resp, body)
- return resp, body
-
- def reboot(self, server_id, reboot_type):
- """Reboots a server."""
- return self.action(server_id, 'reboot', None, type=reboot_type)
-
- def rebuild(self, server_id, image_ref, **kwargs):
- """Rebuilds a server with a new image."""
- kwargs['image_ref'] = image_ref
- if 'disk_config' in kwargs:
- kwargs['os-disk-config:disk_config'] = kwargs['disk_config']
- del kwargs['disk_config']
- if CONF.compute_feature_enabled.enable_instance_password:
- rebuild_schema = schema.rebuild_server_with_admin_pass
- else:
- rebuild_schema = schema.rebuild_server
- return self.action(server_id, 'rebuild', 'server',
- rebuild_schema, **kwargs)
-
- def resize(self, server_id, flavor_ref, **kwargs):
- """Changes the flavor of a server."""
- kwargs['flavor_ref'] = flavor_ref
- if 'disk_config' in kwargs:
- kwargs['os-disk-config:disk_config'] = kwargs['disk_config']
- del kwargs['disk_config']
- return self.action(server_id, 'resize', None, **kwargs)
-
- def confirm_resize(self, server_id, **kwargs):
- """Confirms the flavor change for a server."""
- return self.action(server_id, 'confirm_resize', None, **kwargs)
-
- def revert_resize(self, server_id, **kwargs):
- """Reverts a server back to its original flavor."""
- return self.action(server_id, 'revert_resize', None, **kwargs)
-
- def create_image(self, server_id, name, meta=None):
- """Creates an image of the original server."""
-
- post_body = {
- 'create_image': {
- 'name': name,
- }
- }
-
- if meta is not None:
- post_body['create_image']['metadata'] = meta
-
- post_body = json.dumps(post_body)
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body)
- return resp, body
-
- def list_server_metadata(self, server_id):
- resp, body = self.get("servers/%s/metadata" % str(server_id))
- body = json.loads(body)
- self.validate_response(common_schema.list_server_metadata, resp, body)
- return resp, body['metadata']
-
- def set_server_metadata(self, server_id, meta, no_metadata_field=False):
- if no_metadata_field:
- post_body = ""
- else:
- post_body = json.dumps({'metadata': meta})
- resp, body = self.put('servers/%s/metadata' % str(server_id),
- post_body)
- body = json.loads(body)
- self.validate_response(common_schema.set_server_metadata, resp, body)
- return resp, body['metadata']
-
- def update_server_metadata(self, server_id, meta):
- post_body = json.dumps({'metadata': meta})
- resp, body = self.post('servers/%s/metadata' % str(server_id),
- post_body)
- body = json.loads(body)
- self.validate_response(schema.update_server_metadata, resp, body)
- return resp, body['metadata']
-
- def get_server_metadata_item(self, server_id, key):
- resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key))
- body = json.loads(body)
- self.validate_response(schema.set_get_server_metadata_item,
- resp, body)
- return resp, body['metadata']
-
- def set_server_metadata_item(self, server_id, key, meta):
- post_body = json.dumps({'metadata': meta})
- resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- post_body)
- body = json.loads(body)
- self.validate_response(schema.set_get_server_metadata_item,
- resp, body)
- return resp, body['metadata']
-
- def delete_server_metadata_item(self, server_id, key):
- resp, body = self.delete("servers/%s/metadata/%s" %
- (str(server_id), key))
- self.validate_response(common_schema.delete_server_metadata_item,
- resp, body)
- return resp, body
-
- def stop(self, server_id, **kwargs):
- return self.action(server_id, 'stop', None, **kwargs)
-
- def start(self, server_id, **kwargs):
- return self.action(server_id, 'start', None, **kwargs)
-
- def attach_volume(self, server_id, volume_id, device='/dev/vdz'):
- """Attaches a volume to a server instance."""
- resp, body = self.action(server_id, 'attach', None,
- volume_id=volume_id, device=device)
- self.validate_response(schema.attach_detach_volume, resp, body)
- return resp, body
-
- def detach_volume(self, server_id, volume_id):
- """Detaches a volume from a server instance."""
- resp, body = self.action(server_id, 'detach', None,
- volume_id=volume_id)
- self.validate_response(schema.attach_detach_volume, resp, body)
- return resp, body
-
- def live_migrate_server(self, server_id, dest_host, use_block_migration):
- """This should be called with administrator privileges ."""
-
- migrate_params = {
- "disk_over_commit": False,
- "block_migration": use_block_migration,
- "host": dest_host
- }
-
- req_body = json.dumps({'migrate_live': migrate_params})
-
- resp, body = self.post("servers/%s/action" % str(server_id),
- req_body)
- self.validate_response(common_schema.server_actions_common_schema,
- resp, body)
- return resp, body
-
- def migrate_server(self, server_id, **kwargs):
- """Migrates a server to a new host."""
- return self.action(server_id, 'migrate', None, **kwargs)
-
- def lock_server(self, server_id, **kwargs):
- """Locks the given server."""
- return self.action(server_id, 'lock', None, **kwargs)
-
- def unlock_server(self, server_id, **kwargs):
- """UNlocks the given server."""
- return self.action(server_id, 'unlock', None, **kwargs)
-
- def suspend_server(self, server_id, **kwargs):
- """Suspends the provided server."""
- return self.action(server_id, 'suspend', None, **kwargs)
-
- def resume_server(self, server_id, **kwargs):
- """Un-suspends the provided server."""
- return self.action(server_id, 'resume', None, **kwargs)
-
- def pause_server(self, server_id, **kwargs):
- """Pauses the provided server."""
- return self.action(server_id, 'pause', None, **kwargs)
-
- def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provided server."""
- return self.action(server_id, 'unpause', None, **kwargs)
-
- def reset_state(self, server_id, state='error'):
- """Resets the state of a server to active/error."""
- return self.action(server_id, 'reset_state', None, state=state)
-
- def shelve_server(self, server_id, **kwargs):
- """Shelves the provided server."""
- return self.action(server_id, 'shelve', None, **kwargs)
-
- def unshelve_server(self, server_id, **kwargs):
- """Un-shelves the provided server."""
- return self.action(server_id, 'unshelve', None, **kwargs)
-
- def shelve_offload_server(self, server_id, **kwargs):
- """Shelve-offload the provided server."""
- return self.action(server_id, 'shelve_offload', None, **kwargs)
-
- def get_console_output(self, server_id, length):
- if length is None:
- # NOTE(mriedem): -1 means optional/unlimited in the nova v3 API.
- length = -1
- return self.action(server_id, 'get_console_output', 'output',
- common_schema.get_console_output, length=length)
-
- def rescue_server(self, server_id, **kwargs):
- """Rescue the provided server."""
- post_body = json.dumps({'rescue': kwargs})
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body)
- if CONF.compute_feature_enabled.enable_instance_password:
- rescue_schema = schema.rescue_server_with_admin_pass
- else:
- rescue_schema = schema.rescue_server
- body = json.loads(body)
- self.validate_response(rescue_schema, resp, body)
- return resp, body
-
- def unrescue_server(self, server_id):
- """Unrescue the provided server."""
- return self.action(server_id, 'unrescue', None)
-
- def get_server_diagnostics(self, server_id):
- """Get the usage data for a server."""
- resp, body = self.get("servers/%s/os-server-diagnostics" %
- str(server_id))
- return resp, json.loads(body)
-
- def list_server_actions(self, server_id):
- """List the provided server action."""
- resp, body = self.get("servers/%s/os-server-actions" %
- str(server_id))
- body = json.loads(body)
- self.validate_response(schema.list_server_actions, resp, body)
- return resp, body['server_actions']
-
- def get_server_action(self, server_id, request_id):
- """Returns the action details of the provided server."""
- resp, body = self.get("servers/%s/os-server-actions/%s" %
- (str(server_id), str(request_id)))
- body = json.loads(body)
- self.validate_response(schema.get_server_action, resp, body)
- return resp, body['server_action']
-
- def force_delete_server(self, server_id, **kwargs):
- """Force delete a server."""
- return self.action(server_id, 'force_delete', None, **kwargs)
-
- def restore_soft_deleted_server(self, server_id, **kwargs):
- """Restore a soft-deleted server."""
- return self.action(server_id, 'restore', None, **kwargs)
-
- def get_vnc_console(self, server_id, type):
- """Get URL of VNC console."""
- post_body = json.dumps({
- "get_vnc_console": {
- "type": type
- }
- })
- resp, body = self.post('servers/%s/action' % str(server_id),
- post_body)
- body = json.loads(body)
- self.validate_response(common_schema.get_vnc_console, resp, body)
- return resp, body['console']
-
- def reset_network(self, server_id, **kwargs):
- """Resets the Network of a server"""
- return self.action(server_id, 'reset_network', None, **kwargs)
-
- def inject_network_info(self, server_id, **kwargs):
- """Inject the Network Info into server"""
- return self.action(server_id, 'inject_network_info', None, **kwargs)
-
- def get_spice_console(self, server_id, console_type):
- """Get URL of Spice console."""
- return self.action(server_id, "get_spice_console"
- "console", None, type=console_type)
-
- def get_rdp_console(self, server_id, console_type):
- """Get URL of RDP console."""
- return self.action(server_id, "get_rdp_console"
- "console", None, type=console_type)
diff --git a/tempest/services/compute/v3/json/services_client.py b/tempest/services/compute/v3/json/services_client.py
deleted file mode 100644
index 0645287..0000000
--- a/tempest/services/compute/v3/json/services_client.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright 2013 NEC Corporation
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from tempest.api_schema.response.compute import services as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class ServicesV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(ServicesV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def list_services(self, params=None):
- url = 'os-services'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = json.loads(body)
- self.validate_response(schema.list_services, resp, body)
- return resp, body['services']
-
- def enable_service(self, host_name, binary):
- """
- Enable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = json.dumps({
- 'service': {
- 'binary': binary,
- 'host': host_name
- }
- })
- resp, body = self.put('os-services/enable', post_body)
- body = json.loads(body)
- self.validate_response(schema.enable_service, resp, body)
- return resp, body['service']
-
- def disable_service(self, host_name, binary):
- """
- Disable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = json.dumps({
- 'service': {
- 'binary': binary,
- 'host': host_name
- }
- })
- resp, body = self.put('os-services/disable', post_body)
- body = json.loads(body)
- return resp, body['service']
diff --git a/tempest/services/compute/v3/json/version_client.py b/tempest/services/compute/v3/json/version_client.py
deleted file mode 100644
index bc4f58c..0000000
--- a/tempest/services/compute/v3/json/version_client.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2014 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from tempest.api_schema.response.compute import version as schema
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class VersionV3ClientJSON(rest_client.RestClient):
-
- def __init__(self, auth_provider):
- super(VersionV3ClientJSON, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_v3_type
-
- def get_version(self):
- resp, body = self.get('')
- body = json.loads(body)
- self.validate_response(schema.version, resp, body)
- return resp, body['version']
diff --git a/tempest/services/compute/xml/__init__.py b/tempest/services/compute/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/compute/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/compute/xml/aggregates_client.py b/tempest/services/compute/xml/aggregates_client.py
deleted file mode 100644
index 47cde65..0000000
--- a/tempest/services/compute/xml/aggregates_client.py
+++ /dev/null
@@ -1,130 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class AggregatesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(AggregatesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _format_aggregate(self, g):
- agg = xml_utils.xml_to_json(g)
- aggregate = {}
- for key, value in agg.items():
- if key == 'hosts':
- aggregate['hosts'] = []
- for k, v in value.items():
- aggregate['hosts'].append(v)
- elif key == 'availability_zone':
- aggregate[key] = None if value == 'None' else value
- else:
- aggregate[key] = value
- return aggregate
-
- def _parse_array(self, node):
- return [self._format_aggregate(x) for x in node]
-
- def list_aggregates(self):
- """Get aggregate list."""
- resp, body = self.get("os-aggregates")
- aggregates = self._parse_array(etree.fromstring(body))
- return resp, aggregates
-
- def get_aggregate(self, aggregate_id):
- """Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def create_aggregate(self, name, availability_zone=None):
- """Creates a new aggregate."""
- if availability_zone is not None:
- post_body = xml_utils.Element("aggregate", name=name,
- availability_zone=availability_zone)
- else:
- post_body = xml_utils.Element("aggregate", name=name)
- resp, body = self.post('os-aggregates',
- str(xml_utils.Document(post_body)))
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def update_aggregate(self, aggregate_id, name, availability_zone=None):
- """Update a aggregate."""
- if availability_zone is not None:
- put_body = xml_utils.Element("aggregate", name=name,
- availability_zone=availability_zone)
- else:
- put_body = xml_utils.Element("aggregate", name=name)
- resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
- str(xml_utils.Document(put_body)))
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def delete_aggregate(self, aggregate_id):
- """Deletes the given aggregate."""
- return self.delete("os-aggregates/%s" % str(aggregate_id))
-
- def is_resource_deleted(self, id):
- try:
- self.get_aggregate(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'aggregate'
-
- def add_host(self, aggregate_id, host):
- """Adds a host to the given aggregate."""
- post_body = xml_utils.Element("add_host", host=host)
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(xml_utils.Document(post_body)))
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def remove_host(self, aggregate_id, host):
- """Removes a host from the given aggregate."""
- post_body = xml_utils.Element("remove_host", host=host)
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(xml_utils.Document(post_body)))
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
-
- def set_metadata(self, aggregate_id, meta):
- """Replaces the aggregate's existing metadata with new metadata."""
- post_body = xml_utils.Element("set_metadata")
- metadata = xml_utils.Element("metadata")
- post_body.append(metadata)
- for k, v in meta.items():
- meta = xml_utils.Element(k)
- meta.append(xml_utils.Text(v))
- metadata.append(meta)
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- str(xml_utils.Document(post_body)))
- aggregate = self._format_aggregate(etree.fromstring(body))
- return resp, aggregate
diff --git a/tempest/services/compute/xml/availability_zone_client.py b/tempest/services/compute/xml/availability_zone_client.py
deleted file mode 100644
index 38446b8..0000000
--- a/tempest/services/compute/xml/availability_zone_client.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class AvailabilityZoneClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(AvailabilityZoneClientXML, self).__init__(
- auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_array(self, node):
- return [xml_utils.xml_to_json(x) for x in node]
-
- def get_availability_zone_list(self):
- resp, body = self.get('os-availability-zone')
- availability_zone = self._parse_array(etree.fromstring(body))
- return resp, availability_zone
-
- def get_availability_zone_list_detail(self):
- resp, body = self.get('os-availability-zone/detail')
- availability_zone = self._parse_array(etree.fromstring(body))
- return resp, availability_zone
diff --git a/tempest/services/compute/xml/certificates_client.py b/tempest/services/compute/xml/certificates_client.py
deleted file mode 100644
index 24ffca8..0000000
--- a/tempest/services/compute/xml/certificates_client.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class CertificatesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(CertificatesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def get_certificate(self, id):
- url = "os-certificates/%s" % (id)
- resp, body = self.get(url)
- body = self._parse_resp(body)
- return resp, body
-
- def create_certificate(self):
- """create certificates."""
- url = "os-certificates"
- resp, body = self.post(url, None)
- body = self._parse_resp(body)
- return resp, body
diff --git a/tempest/services/compute/xml/extensions_client.py b/tempest/services/compute/xml/extensions_client.py
deleted file mode 100644
index d924dff..0000000
--- a/tempest/services/compute/xml/extensions_client.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class ExtensionsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(ExtensionsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_array(self, node):
- array = []
- for child in node:
- array.append(xml_utils.xml_to_json(child))
- return array
-
- def list_extensions(self):
- url = 'extensions'
- resp, body = self.get(url)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def is_enabled(self, extension):
- _, extensions = self.list_extensions()
- exts = extensions['extensions']
- return any([e for e in exts if e['name'] == extension])
-
- def get_extension(self, extension_alias):
- resp, body = self.get('extensions/%s' % extension_alias)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/xml/fixed_ips_client.py b/tempest/services/compute/xml/fixed_ips_client.py
deleted file mode 100644
index e14ced6..0000000
--- a/tempest/services/compute/xml/fixed_ips_client.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2013 IBM Corp
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class FixedIPsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(FixedIPsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def get_fixed_ip_details(self, fixed_ip):
- url = "os-fixed-ips/%s" % (fixed_ip)
- resp, body = self.get(url)
- body = self._parse_resp(body)
- return resp, body
-
- def reserve_fixed_ip(self, ip, body):
- """This reserves and unreserves fixed ips."""
- url = "os-fixed-ips/%s/action" % (ip)
- # NOTE(maurosr): First converts the dict body to a json string then
- # accept any action key value here to permit tests to cover cases with
- # invalid actions raising badrequest.
- key, value = body.popitem()
- xml_body = xml_utils.Element(key)
- xml_body.append(xml_utils.Text(value))
- resp, body = self.post(url, str(xml_utils.Document(xml_body)))
- return resp, body
diff --git a/tempest/services/compute/xml/flavors_client.py b/tempest/services/compute/xml/flavors_client.py
deleted file mode 100644
index 63d1a4d..0000000
--- a/tempest/services/compute/xml/flavors_client.py
+++ /dev/null
@@ -1,216 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-XMLNS_OS_FLV_EXT_DATA = \
- "http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
-XMLNS_OS_FLV_ACCESS = \
- "http://docs.openstack.org/compute/ext/flavor_access/api/v2"
-
-
-class FlavorsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(FlavorsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _format_flavor(self, f):
- flavor = {'links': []}
- for k, v in f.items():
- if k == 'id':
- flavor['id'] = v
- continue
-
- if k == 'link':
- flavor['links'].append(v)
- continue
-
- if k == '{%s}ephemeral' % XMLNS_OS_FLV_EXT_DATA:
- k = 'OS-FLV-EXT-DATA:ephemeral'
-
- if k == '{%s}is_public' % XMLNS_OS_FLV_ACCESS:
- k = 'os-flavor-access:is_public'
- v = True if v == 'True' else False
-
- if k == 'extra_specs':
- k = 'OS-FLV-WITH-EXT-SPECS:extra_specs'
- flavor[k] = dict(v)
- continue
-
- try:
- v = int(v)
- except ValueError:
- try:
- v = float(v)
- except ValueError:
- pass
-
- flavor[k] = v
-
- return flavor
-
- def _parse_array(self, node):
- return [self._format_flavor(xml_utils.xml_to_json(x)) for x in node]
-
- def _list_flavors(self, url, params):
- if params:
- url += "?%s" % urllib.urlencode(params)
-
- resp, body = self.get(url)
- flavors = self._parse_array(etree.fromstring(body))
- return resp, flavors
-
- def list_flavors(self, params=None):
- url = 'flavors'
- return self._list_flavors(url, params)
-
- def list_flavors_with_detail(self, params=None):
- url = 'flavors/detail'
- return self._list_flavors(url, params)
-
- def get_flavor_details(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(flavor_id))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- flavor = self._format_flavor(body)
- return resp, flavor
-
- def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
- """Creates a new flavor or instance type."""
- flavor = xml_utils.Element("flavor",
- xmlns=xml_utils.XMLNS_11,
- ram=ram,
- vcpus=vcpus,
- disk=disk,
- id=flavor_id,
- name=name)
- if kwargs.get('rxtx'):
- flavor.add_attr('rxtx_factor', kwargs.get('rxtx'))
- if kwargs.get('swap'):
- flavor.add_attr('swap', kwargs.get('swap'))
- if kwargs.get('ephemeral'):
- flavor.add_attr('OS-FLV-EXT-DATA:ephemeral',
- kwargs.get('ephemeral'))
- if kwargs.get('is_public'):
- flavor.add_attr('os-flavor-access:is_public',
- kwargs.get('is_public'))
- flavor.add_attr('xmlns:OS-FLV-EXT-DATA', XMLNS_OS_FLV_EXT_DATA)
- flavor.add_attr('xmlns:os-flavor-access', XMLNS_OS_FLV_ACCESS)
- resp, body = self.post('flavors', str(xml_utils.Document(flavor)))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- flavor = self._format_flavor(body)
- return resp, flavor
-
- def delete_flavor(self, flavor_id):
- """Deletes the given flavor."""
- return self.delete("flavors/%s" % str(flavor_id))
-
- def is_resource_deleted(self, id):
- # Did not use get_flavor_details(id) for verification as it gives
- # 200 ok even for deleted id. LP #981263
- # we can remove the loop here and use get by ID when bug gets sortedout
- resp, flavors = self.list_flavors_with_detail()
- for flavor in flavors:
- if flavor['id'] == id:
- return False
- return True
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'flavor'
-
- def set_flavor_extra_spec(self, flavor_id, specs):
- """Sets extra Specs to the mentioned flavor."""
- extra_specs = xml_utils.Element("extra_specs")
- for key in specs.keys():
- extra_specs.add_attr(key, specs[key])
- resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
- str(xml_utils.Document(extra_specs)))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def get_flavor_extra_spec(self, flavor_id):
- """Gets extra Specs of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def get_flavor_extra_spec_with_key(self, flavor_id, key):
- """Gets extra Specs key-value of the mentioned flavor and key."""
- resp, xml_body = self.get('flavors/%s/os-extra_specs/%s' %
- (str(flavor_id), key))
- body = {}
- element = etree.fromstring(xml_body)
- key = element.get('key')
- body[key] = xml_utils.xml_to_json(element)
- return resp, body
-
- def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
- """Update extra Specs details of the mentioned flavor and key."""
- doc = xml_utils.Document()
- for (k, v) in kwargs.items():
- element = xml_utils.Element(k)
- doc.append(element)
- value = xml_utils.Text(v)
- element.append(value)
-
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
- (flavor_id, key), str(doc))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, {key: body}
-
- def unset_flavor_extra_spec(self, flavor_id, key):
- """Unsets an extra spec based on the mentioned flavor and key."""
- return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
-
- def _parse_array_access(self, node):
- return [xml_utils.xml_to_json(x) for x in node]
-
- def list_flavor_access(self, flavor_id):
- """Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % str(flavor_id))
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def add_flavor_access(self, flavor_id, tenant_id):
- """Add flavor access for the specified tenant."""
- doc = xml_utils.Document()
- server = xml_utils.Element("addTenantAccess")
- doc.append(server)
- server.add_attr("tenant", tenant_id)
- resp, body = self.post('flavors/%s/action' % str(flavor_id), str(doc))
- body = self._parse_array_access(etree.fromstring(body))
- return resp, body
-
- def remove_flavor_access(self, flavor_id, tenant_id):
- """Remove flavor access from the specified tenant."""
- doc = xml_utils.Document()
- server = xml_utils.Element("removeTenantAccess")
- doc.append(server)
- server.add_attr("tenant", tenant_id)
- resp, body = self.post('flavors/%s/action' % str(flavor_id), str(doc))
- body = self._parse_array_access(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
deleted file mode 100644
index 84f06ab..0000000
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class FloatingIPsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(FloatingIPsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_utils.xml_to_json(child))
- return array
-
- def _parse_floating_ip(self, body):
- json = xml_utils.xml_to_json(body)
- return json
-
- def list_floating_ips(self, params=None):
- """Returns a list of all floating IPs filtered by any parameters."""
- url = 'os-floating-ips'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_floating_ip_details(self, floating_ip_id):
- """Get the details of a floating IP."""
- url = "os-floating-ips/%s" % str(floating_ip_id)
- resp, body = self.get(url)
- body = self._parse_floating_ip(etree.fromstring(body))
- if resp.status == 404:
- raise exceptions.NotFound(body)
- return resp, body
-
- def create_floating_ip(self, pool_name=None):
- """Allocate a floating IP to the project."""
- url = 'os-floating-ips'
- if pool_name:
- doc = xml_utils.Document()
- pool = xml_utils.Element("pool")
- pool.append(xml_utils.Text(pool_name))
- doc.append(pool)
- resp, body = self.post(url, str(doc))
- else:
- resp, body = self.post(url, None)
- body = self._parse_floating_ip(etree.fromstring(body))
- return resp, body
-
- def delete_floating_ip(self, floating_ip_id):
- """Deletes the provided floating IP from the project."""
- url = "os-floating-ips/%s" % str(floating_ip_id)
- resp, body = self.delete(url)
- return resp, body
-
- def associate_floating_ip_to_server(self, floating_ip, server_id):
- """Associate the provided floating IP to a specific server."""
- url = "servers/%s/action" % str(server_id)
- doc = xml_utils.Document()
- server = xml_utils.Element("addFloatingIp")
- doc.append(server)
- server.add_attr("address", floating_ip)
- resp, body = self.post(url, str(doc))
- return resp, body
-
- def disassociate_floating_ip_from_server(self, floating_ip, server_id):
- """Disassociate the provided floating IP from a specific server."""
- url = "servers/%s/action" % str(server_id)
- doc = xml_utils.Document()
- server = xml_utils.Element("removeFloatingIp")
- doc.append(server)
- server.add_attr("address", floating_ip)
- resp, body = self.post(url, str(doc))
- return resp, body
-
- def is_resource_deleted(self, id):
- try:
- self.get_floating_ip_details(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'floating_ip'
-
- def list_floating_ip_pools(self, params=None):
- """Returns a list of all floating IP Pools."""
- url = 'os-floating-ip-pools'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/xml/hosts_client.py b/tempest/services/compute/xml/hosts_client.py
deleted file mode 100644
index ddb92b6..0000000
--- a/tempest/services/compute/xml/hosts_client.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class HostsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(HostsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def list_hosts(self, params=None):
- """Lists all hosts."""
-
- url = 'os-hosts'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def show_host_detail(self, hostname):
- """Show detail information for the host."""
-
- resp, body = self.get("os-hosts/%s" % str(hostname))
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(node)]
- return resp, body
-
- def update_host(self, hostname, **kwargs):
- """Update a host."""
-
- request_body = xml_utils.Element("updates")
- if kwargs:
- for k, v in kwargs.iteritems():
- request_body.append(xml_utils.Element(k, v))
- resp, body = self.put("os-hosts/%s" % str(hostname),
- str(xml_utils.Document(request_body)))
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def startup_host(self, hostname):
- """Startup a host."""
-
- resp, body = self.get("os-hosts/%s/startup" % str(hostname))
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def shutdown_host(self, hostname):
- """Shutdown a host."""
-
- resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def reboot_host(self, hostname):
- """Reboot a host."""
-
- resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, body
diff --git a/tempest/services/compute/xml/hypervisor_client.py b/tempest/services/compute/xml/hypervisor_client.py
deleted file mode 100644
index 1452708..0000000
--- a/tempest/services/compute/xml/hypervisor_client.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class HypervisorClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(HypervisorClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_array(self, node):
- return [xml_utils.xml_to_json(x) for x in node]
-
- def get_hypervisor_list(self):
- """List hypervisors information."""
- resp, body = self.get('os-hypervisors')
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_list_details(self):
- """Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail')
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_show_details(self, hyper_id):
- """Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hyper_id)
- hypervisor = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, hypervisor
-
- def get_hypervisor_servers(self, hyper_name):
- """List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_stats(self):
- """Get hypervisor statistics over all compute nodes."""
- resp, body = self.get('os-hypervisors/statistics')
- stats = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, stats
-
- def get_hypervisor_uptime(self, hyper_id):
- """Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
- uptime = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, uptime
-
- def search_hypervisor(self, hyper_name):
- """Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/search' % hyper_name)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
diff --git a/tempest/services/compute/xml/images_client.py b/tempest/services/compute/xml/images_client.py
deleted file mode 100644
index ce37b07..0000000
--- a/tempest/services/compute/xml/images_client.py
+++ /dev/null
@@ -1,211 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import waiters
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class ImagesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(ImagesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
- self.build_interval = CONF.compute.build_interval
- self.build_timeout = CONF.compute.build_timeout
-
- def _parse_server(self, node):
- data = xml_utils.xml_to_json(node)
- return self._parse_links(node, data)
-
- def _parse_image(self, node):
- """Parses detailed XML image information into dictionary."""
- data = xml_utils.xml_to_json(node)
-
- self._parse_links(node, data)
-
- # parse all metadata
- if 'metadata' in data:
- tag = node.find('{%s}metadata' % xml_utils.XMLNS_11)
- data['metadata'] = dict((x.get('key'), x.text)
- for x in tag.getchildren())
-
- # parse server information
- if 'server' in data:
- tag = node.find('{%s}server' % xml_utils.XMLNS_11)
- data['server'] = self._parse_server(tag)
- return data
-
- def _parse_links(self, node, data):
- """Append multiple links under a list."""
- # look for links
- if 'link' in data:
- # remove single link element
- del data['link']
- data['links'] = [xml_utils.xml_to_json(x) for x in
- node.findall('{http://www.w3.org/2005/Atom}link')]
- return data
-
- def _parse_images(self, xml):
- data = {'images': []}
- images = xml.getchildren()
- for image in images:
- data['images'].append(self._parse_image(image))
- return data
-
- def _parse_key_value(self, node):
- """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
- data = {}
- for node in node.getchildren():
- data[node.get('key')] = node.text
- return data
-
- def _parse_metadata(self, node):
- """Parse the response body without children."""
- data = {}
- data[node.get('key')] = node.text
- return data
-
- def create_image(self, server_id, name, meta=None):
- """Creates an image of the original server."""
- post_body = xml_utils.Element('createImage', name=name)
-
- if meta:
- metadata = xml_utils.Element('metadata')
- post_body.append(metadata)
- for k, v in meta.items():
- data = xml_utils.Element('meta', key=k)
- data.append(xml_utils.Text(v))
- metadata.append(data)
- resp, body = self.post('servers/%s/action' % str(server_id),
- str(xml_utils.Document(post_body)))
- return resp, body
-
- def list_images(self, params=None):
- """Returns a list of all images filtered by any parameters."""
- url = 'images'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = self._parse_images(etree.fromstring(body))
- return resp, body['images']
-
- def list_images_with_detail(self, params=None):
- """Returns a detailed list of images filtered by any parameters."""
- url = 'images/detail'
- if params:
- param_list = urllib.urlencode(params)
-
- url = "images/detail?" + param_list
-
- resp, body = self.get(url)
- body = self._parse_images(etree.fromstring(body))
- return resp, body['images']
-
- def get_image(self, image_id):
- """Returns the details of a single image."""
- resp, body = self.get("images/%s" % str(image_id))
- self.expected_success(200, resp.status)
- body = self._parse_image(etree.fromstring(body))
- return resp, body
-
- def delete_image(self, image_id):
- """Deletes the provided image."""
- return self.delete("images/%s" % str(image_id))
-
- def wait_for_image_status(self, image_id, status):
- """Waits for an image to reach a given status."""
- waiters.wait_for_image_status(self, image_id, status)
-
- def _metadata_body(self, meta):
- post_body = xml_utils.Element('metadata')
- for k, v in meta.items():
- data = xml_utils.Element('meta', key=k)
- data.append(xml_utils.Text(v))
- post_body.append(data)
- return post_body
-
- def list_image_metadata(self, image_id):
- """Lists all metadata items for an image."""
- resp, body = self.get("images/%s/metadata" % str(image_id))
- body = self._parse_key_value(etree.fromstring(body))
- return resp, body
-
- def set_image_metadata(self, image_id, meta):
- """Sets the metadata for an image."""
- post_body = self._metadata_body(meta)
- resp, body = self.put('images/%s/metadata' % image_id,
- str(xml_utils.Document(post_body)))
- body = self._parse_key_value(etree.fromstring(body))
- return resp, body
-
- def update_image_metadata(self, image_id, meta):
- """Updates the metadata for an image."""
- post_body = self._metadata_body(meta)
- resp, body = self.post('images/%s/metadata' % str(image_id),
- str(xml_utils.Document(post_body)))
- body = self._parse_key_value(etree.fromstring(body))
- return resp, body
-
- def get_image_metadata_item(self, image_id, key):
- """Returns the value for a specific image metadata key."""
- resp, body = self.get("images/%s/metadata/%s.xml" %
- (str(image_id), key))
- body = self._parse_metadata(etree.fromstring(body))
- return resp, body
-
- def set_image_metadata_item(self, image_id, key, meta):
- """Sets the value for a specific image metadata key."""
- for k, v in meta.items():
- post_body = xml_utils.Element('meta', key=key)
- post_body.append(xml_utils.Text(v))
- resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
- str(xml_utils.Document(post_body)))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def update_image_metadata_item(self, image_id, key, meta):
- """Sets the value for a specific image metadata key."""
- post_body = xml_utils.Document('meta', xml_utils.Text(meta), key=key)
- resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
- post_body)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body['meta']
-
- def delete_image_metadata_item(self, image_id, key):
- """Deletes a single image metadata key/value pair."""
- return self.delete("images/%s/metadata/%s" % (str(image_id), key))
-
- def is_resource_deleted(self, id):
- try:
- self.get_image(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'image'
diff --git a/tempest/services/compute/xml/instance_usage_audit_log_client.py b/tempest/services/compute/xml/instance_usage_audit_log_client.py
deleted file mode 100644
index b139db1..0000000
--- a/tempest/services/compute/xml/instance_usage_audit_log_client.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2013 IBM Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class InstanceUsagesAuditLogClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(InstanceUsagesAuditLogClientXML, self).__init__(
- auth_provider)
- self.service = CONF.compute.catalog_type
-
- def list_instance_usage_audit_logs(self):
- url = 'os-instance_usage_audit_log'
- resp, body = self.get(url)
- instance_usage_audit_logs = xml_utils.xml_to_json(
- etree.fromstring(body))
- return resp, instance_usage_audit_logs
-
- def get_instance_usage_audit_log(self, time_before):
- url = 'os-instance_usage_audit_log/%s' % time_before
- resp, body = self.get(url)
- instance_usage_audit_log = xml_utils.xml_to_json(
- etree.fromstring(body))
- return resp, instance_usage_audit_log
diff --git a/tempest/services/compute/xml/interfaces_client.py b/tempest/services/compute/xml/interfaces_client.py
deleted file mode 100644
index e30a97c..0000000
--- a/tempest/services/compute/xml/interfaces_client.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import time
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class InterfacesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(InterfacesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _process_xml_interface(self, node):
- iface = xml_utils.xml_to_json(node)
- # NOTE(danms): if multiple addresses per interface is ever required,
- # xml_utils.xml_to_json will need to be fixed or replaced in this case
- iface['fixed_ips'] = [dict(iface['fixed_ips']['fixed_ip'].items())]
- return iface
-
- def list_interfaces(self, server):
- resp, body = self.get('servers/%s/os-interface' % server)
- node = etree.fromstring(body)
- interfaces = [self._process_xml_interface(x)
- for x in node.getchildren()]
- return resp, interfaces
-
- def create_interface(self, server, port_id=None, network_id=None,
- fixed_ip=None):
- doc = xml_utils.Document()
- iface = xml_utils.Element('interfaceAttachment')
- if port_id:
- _port_id = xml_utils.Element('port_id')
- _port_id.append(xml_utils.Text(port_id))
- iface.append(_port_id)
- if network_id:
- _network_id = xml_utils.Element('net_id')
- _network_id.append(xml_utils.Text(network_id))
- iface.append(_network_id)
- if fixed_ip:
- _fixed_ips = xml_utils.Element('fixed_ips')
- _fixed_ip = xml_utils.Element('fixed_ip')
- _ip_address = xml_utils.Element('ip_address')
- _ip_address.append(xml_utils.Text(fixed_ip))
- _fixed_ip.append(_ip_address)
- _fixed_ips.append(_fixed_ip)
- iface.append(_fixed_ips)
- doc.append(iface)
- resp, body = self.post('servers/%s/os-interface' % server,
- body=str(doc))
- body = self._process_xml_interface(etree.fromstring(body))
- return resp, body
-
- def show_interface(self, server, port_id):
- resp, body = self.get('servers/%s/os-interface/%s' % (server, port_id))
- body = self._process_xml_interface(etree.fromstring(body))
- return resp, body
-
- def delete_interface(self, server, port_id):
- resp, body = self.delete('servers/%s/os-interface/%s' % (server,
- port_id))
- return resp, body
-
- def wait_for_interface_status(self, server, port_id, status):
- """Waits for a interface to reach a given status."""
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
- start = int(time.time())
-
- while(interface_status != status):
- time.sleep(self.build_interval)
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
-
- timed_out = int(time.time()) - start >= self.build_timeout
-
- if interface_status != status and timed_out:
- message = ('Interface %s failed to reach %s status within '
- 'the required time (%s s).' %
- (port_id, status, self.build_timeout))
- raise exceptions.TimeoutException(message)
- return resp, body
-
- def add_fixed_ip(self, server_id, network_id):
- """Add a fixed IP to input server instance."""
- post_body = xml_utils.Element("addFixedIp",
- xmlns=xml_utils.XMLNS_11,
- networkId=network_id)
- resp, body = self.post('servers/%s/action' % str(server_id),
- str(xml_utils.Document(post_body)))
- return resp, body
-
- def remove_fixed_ip(self, server_id, ip_address):
- """Remove input fixed IP from input server instance."""
- post_body = xml_utils.Element("removeFixedIp",
- xmlns=xml_utils.XMLNS_11,
- address=ip_address)
- resp, body = self.post('servers/%s/action' % str(server_id),
- str(xml_utils.Document(post_body)))
- return resp, body
diff --git a/tempest/services/compute/xml/keypairs_client.py b/tempest/services/compute/xml/keypairs_client.py
deleted file mode 100644
index 8ff37ac..0000000
--- a/tempest/services/compute/xml/keypairs_client.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class KeyPairsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(KeyPairsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def list_keypairs(self):
- resp, body = self.get("os-keypairs")
- node = etree.fromstring(body)
- body = [{'keypair': xml_utils.xml_to_json(x)} for x in
- node.getchildren()]
- return resp, body
-
- def get_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def create_keypair(self, name, pub_key=None):
- doc = xml_utils.Document()
-
- keypair_element = xml_utils.Element("keypair")
-
- if pub_key:
- public_key_element = xml_utils.Element("public_key")
- public_key_text = xml_utils.Text(pub_key)
- public_key_element.append(public_key_text)
- keypair_element.append(public_key_element)
-
- name_element = xml_utils.Element("name")
- name_text = xml_utils.Text(name)
- name_element.append(name_text)
- keypair_element.append(name_element)
-
- doc.append(keypair_element)
-
- resp, body = self.post("os-keypairs", body=str(doc))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def delete_keypair(self, key_name):
- return self.delete("os-keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/xml/limits_client.py b/tempest/services/compute/xml/limits_client.py
deleted file mode 100644
index 2327626..0000000
--- a/tempest/services/compute/xml/limits_client.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import objectify
-
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
-
-NS = "{http://docs.openstack.org/common/api/v1.0}"
-
-
-class LimitsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(LimitsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def get_absolute_limits(self):
- resp, body = self.get("limits")
- body = objectify.fromstring(body)
- lim = NS + 'absolute'
- ret = {}
-
- for el in body[lim].iterchildren():
- attributes = el.attrib
- ret[attributes['name']] = attributes['value']
- return resp, ret
-
- def get_specific_absolute_limit(self, absolute_limit):
- resp, body = self.get("limits")
- body = objectify.fromstring(body)
- lim = NS + 'absolute'
- ret = {}
-
- for el in body[lim].iterchildren():
- attributes = el.attrib
- ret[attributes['name']] = attributes['value']
- if absolute_limit not in ret:
- return None
- else:
- return ret[absolute_limit]
diff --git a/tempest/services/compute/xml/quotas_client.py b/tempest/services/compute/xml/quotas_client.py
deleted file mode 100644
index 7f87248..0000000
--- a/tempest/services/compute/xml/quotas_client.py
+++ /dev/null
@@ -1,165 +0,0 @@
-# Copyright 2012 NTT Data
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-def format_quota(q):
- quota = {}
- for k, v in q.items():
- try:
- v = int(v)
- except ValueError:
- pass
-
- quota[k] = v
-
- return quota
-
-
-class QuotasClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(QuotasClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def get_quota_set(self, tenant_id, user_id=None):
- """List the quota set for a tenant."""
-
- url = 'os-quota-sets/%s' % str(tenant_id)
- if user_id:
- url += '?user_id=%s' % str(user_id)
- resp, body = self.get(url)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- body = format_quota(body)
- return resp, body
-
- def get_default_quota_set(self, tenant_id):
- """List the default quota set for a tenant."""
-
- url = 'os-quota-sets/%s/defaults' % str(tenant_id)
- resp, body = self.get(url)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- body = format_quota(body)
- return resp, body
-
- def update_quota_set(self, tenant_id, user_id=None,
- force=None, injected_file_content_bytes=None,
- metadata_items=None, ram=None, floating_ips=None,
- fixed_ips=None, key_pairs=None, instances=None,
- security_group_rules=None, injected_files=None,
- cores=None, injected_file_path_bytes=None,
- security_groups=None):
- """
- Updates the tenant's quota limits for one or more resources
- """
- post_body = xml_utils.Element("quota_set",
- xmlns=xml_utils.XMLNS_11)
-
- if force is not None:
- post_body.add_attr('force', force)
-
- if injected_file_content_bytes is not None:
- post_body.add_attr('injected_file_content_bytes',
- injected_file_content_bytes)
-
- if metadata_items is not None:
- post_body.add_attr('metadata_items', metadata_items)
-
- if ram is not None:
- post_body.add_attr('ram', ram)
-
- if floating_ips is not None:
- post_body.add_attr('floating_ips', floating_ips)
-
- if fixed_ips is not None:
- post_body.add_attr('fixed_ips', fixed_ips)
-
- if key_pairs is not None:
- post_body.add_attr('key_pairs', key_pairs)
-
- if instances is not None:
- post_body.add_attr('instances', instances)
-
- if security_group_rules is not None:
- post_body.add_attr('security_group_rules', security_group_rules)
-
- if injected_files is not None:
- post_body.add_attr('injected_files', injected_files)
-
- if cores is not None:
- post_body.add_attr('cores', cores)
-
- if injected_file_path_bytes is not None:
- post_body.add_attr('injected_file_path_bytes',
- injected_file_path_bytes)
-
- if security_groups is not None:
- post_body.add_attr('security_groups', security_groups)
-
- if user_id:
- resp, body = self.put('os-quota-sets/%s?user_id=%s' %
- (str(tenant_id), str(user_id)),
- str(xml_utils.Document(post_body)))
- else:
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
- str(xml_utils.Document(post_body)))
-
- body = xml_utils.xml_to_json(etree.fromstring(body))
- body = format_quota(body)
- return resp, body
-
- def delete_quota_set(self, tenant_id):
- """Delete the tenant's quota set."""
- return self.delete('os-quota-sets/%s' % str(tenant_id))
-
-
-class QuotaClassesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(QuotaClassesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def get_quota_class_set(self, quota_class_id):
- """List the quota class set for a quota class."""
-
- url = 'os-quota-class-sets/%s' % str(quota_class_id)
- resp, body = self.get(url)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- body = format_quota(body)
- return resp, body
-
- def update_quota_class_set(self, quota_class_id, **kwargs):
- """
- Updates the quota class's limits for one or more resources.
- """
- post_body = xml_utils.Element("quota_class_set",
- xmlns=xml_utils.XMLNS_11,
- **kwargs)
-
- resp, body = self.put('os-quota-class-sets/%s' % str(quota_class_id),
- str(xml_utils.Document(post_body)))
-
- body = xml_utils.xml_to_json(etree.fromstring(body))
- body = format_quota(body)
- return resp, body
diff --git a/tempest/services/compute/xml/security_groups_client.py b/tempest/services/compute/xml/security_groups_client.py
deleted file mode 100644
index e529623..0000000
--- a/tempest/services/compute/xml/security_groups_client.py
+++ /dev/null
@@ -1,166 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class SecurityGroupsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(SecurityGroupsClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_utils.xml_to_json(child))
- return array
-
- def _parse_body(self, body):
- json = xml_utils.xml_to_json(body)
- return json
-
- def list_security_groups(self, params=None):
- """List all security groups for a user."""
-
- url = 'os-security-groups'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_security_group(self, security_group_id):
- """Get the details of a Security Group."""
- url = "os-security-groups/%s" % str(security_group_id)
- resp, body = self.get(url)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def create_security_group(self, name, description):
- """
- Creates a new security group.
- name (Required): Name of security group.
- description (Required): Description of security group.
- """
- security_group = xml_utils.Element("security_group", name=name)
- des = xml_utils.Element("description")
- des.append(xml_utils.Text(content=description))
- security_group.append(des)
- resp, body = self.post('os-security-groups',
- str(xml_utils.Document(security_group)))
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_security_group(self, security_group_id, name=None,
- description=None):
- """
- Update a security group.
- security_group_id: a security_group to update
- name: new name of security group
- description: new description of security group
- """
- security_group = xml_utils.Element("security_group")
- if name:
- sg_name = xml_utils.Element("name")
- sg_name.append(xml_utils.Text(content=name))
- security_group.append(sg_name)
- if description:
- des = xml_utils.Element("description")
- des.append(xml_utils.Text(content=description))
- security_group.append(des)
- resp, body = self.put('os-security-groups/%s' %
- str(security_group_id),
- str(xml_utils.Document(security_group)))
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_security_group(self, security_group_id):
- """Deletes the provided Security Group."""
- return self.delete('os-security-groups/%s' % str(security_group_id))
-
- def create_security_group_rule(self, parent_group_id, ip_proto, from_port,
- to_port, **kwargs):
- """
- Creating a new security group rules.
- parent_group_id :ID of Security group
- ip_protocol : ip_proto (icmp, tcp, udp).
- from_port: Port at start of range.
- to_port : Port at end of range.
- Following optional keyword arguments are accepted:
- cidr : CIDR for address range.
- group_id : ID of the Source group
- """
- group_rule = xml_utils.Element("security_group_rule")
-
- elements = dict()
- elements['cidr'] = kwargs.get('cidr')
- elements['group_id'] = kwargs.get('group_id')
- elements['parent_group_id'] = parent_group_id
- elements['ip_protocol'] = ip_proto
- elements['from_port'] = from_port
- elements['to_port'] = to_port
-
- for k, v in elements.items():
- if v is not None:
- element = xml_utils.Element(k)
- element.append(xml_utils.Text(content=str(v)))
- group_rule.append(element)
-
- url = 'os-security-group-rules'
- resp, body = self.post(url, str(xml_utils.Document(group_rule)))
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_security_group_rule(self, group_rule_id):
- """Deletes the provided Security Group rule."""
- return self.delete('os-security-group-rules/%s' %
- str(group_rule_id))
-
- def list_security_group_rules(self, security_group_id):
- """List all rules for a security group."""
- url = "os-security-groups"
- resp, body = self.get(url)
- body = etree.fromstring(body)
- secgroups = body.getchildren()
- for secgroup in secgroups:
- if secgroup.get('id') == security_group_id:
- node = secgroup.find('{%s}rules' % xml_utils.XMLNS_11)
- rules = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, rules
- raise exceptions.NotFound('No such Security Group')
-
- def is_resource_deleted(self, id):
- try:
- self.get_security_group(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'security_group'
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
deleted file mode 100644
index 06f1b83..0000000
--- a/tempest/services/compute/xml/servers_client.py
+++ /dev/null
@@ -1,673 +0,0 @@
-# Copyright 2012 IBM Corp.
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import time
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import waiters
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-def _translate_ip_xml_json(ip):
- """
- Convert the address version to int.
- """
- ip = dict(ip)
- version = ip.get('version')
- if version:
- ip['version'] = int(version)
- # NOTE(maurosr): just a fast way to avoid the xml version with the
- # expanded xml namespace.
- type_ns_prefix = ('{http://docs.openstack.org/compute/ext/extended_ips/'
- 'api/v1.1}type')
- mac_ns_prefix = ('{http://docs.openstack.org/compute/ext/extended_ips_mac'
- '/api/v1.1}mac_addr')
-
- if type_ns_prefix in ip:
- ip['OS-EXT-IPS:type'] = ip.pop(type_ns_prefix)
-
- if mac_ns_prefix in ip:
- ip['OS-EXT-IPS-MAC:mac_addr'] = ip.pop(mac_ns_prefix)
- return ip
-
-
-def _translate_network_xml_to_json(network):
- return [_translate_ip_xml_json(ip.attrib)
- for ip in network.findall('{%s}ip' % xml_utils.XMLNS_11)]
-
-
-def _translate_addresses_xml_to_json(xml_addresses):
- return dict((network.attrib['id'], _translate_network_xml_to_json(network))
- for network in xml_addresses.findall('{%s}network' %
- xml_utils.XMLNS_11))
-
-
-def _translate_server_xml_to_json(xml_dom):
- """Convert server XML to server JSON.
-
- The addresses collection does not convert well by the dumb xml_to_json.
- This method does some pre and post-processing to deal with that.
-
- Translate XML addresses subtree to JSON.
-
- Having xml_doc similar to
- <api:server xmlns:api="http://docs.openstack.org/compute/api/v1.1">
- <api:addresses>
- <api:network id="foo_novanetwork">
- <api:ip version="4" addr="192.168.0.4"/>
- </api:network>
- <api:network id="bar_novanetwork">
- <api:ip version="4" addr="10.1.0.4"/>
- <api:ip version="6" addr="2001:0:0:1:2:3:4:5"/>
- </api:network>
- </api:addresses>
- </api:server>
-
- the _translate_server_xml_to_json(etree.fromstring(xml_doc)) should produce
- something like
-
- {'addresses': {'bar_novanetwork': [{'addr': '10.1.0.4', 'version': 4},
- {'addr': '2001:0:0:1:2:3:4:5',
- 'version': 6}],
- 'foo_novanetwork': [{'addr': '192.168.0.4', 'version': 4}]}}
- """
- nsmap = {'api': xml_utils.XMLNS_11}
- addresses = xml_dom.xpath('/api:server/api:addresses', namespaces=nsmap)
- if addresses:
- if len(addresses) > 1:
- raise ValueError('Expected only single `addresses` element.')
- json_addresses = _translate_addresses_xml_to_json(addresses[0])
- json = xml_utils.xml_to_json(xml_dom)
- json['addresses'] = json_addresses
- else:
- json = xml_utils.xml_to_json(xml_dom)
- diskConfig = ('{http://docs.openstack.org'
- '/compute/ext/disk_config/api/v1.1}diskConfig')
- terminated_at = ('{http://docs.openstack.org/'
- 'compute/ext/server_usage/api/v1.1}terminated_at')
- launched_at = ('{http://docs.openstack.org'
- '/compute/ext/server_usage/api/v1.1}launched_at')
- power_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v1.1}power_state')
- availability_zone = ('{http://docs.openstack.org'
- '/compute/ext/extended_availability_zone/api/v2}'
- 'availability_zone')
- vm_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v1.1}vm_state')
- task_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v1.1}task_state')
- if 'tenantId' in json:
- json['tenant_id'] = json.pop('tenantId')
- if 'userId' in json:
- json['user_id'] = json.pop('userId')
- if diskConfig in json:
- json['OS-DCF:diskConfig'] = json.pop(diskConfig)
- if terminated_at in json:
- json['OS-SRV-USG:terminated_at'] = json.pop(terminated_at)
- if launched_at in json:
- json['OS-SRV-USG:launched_at'] = json.pop(launched_at)
- if power_state in json:
- json['OS-EXT-STS:power_state'] = json.pop(power_state)
- if availability_zone in json:
- json['OS-EXT-AZ:availability_zone'] = json.pop(availability_zone)
- if vm_state in json:
- json['OS-EXT-STS:vm_state'] = json.pop(vm_state)
- if task_state in json:
- json['OS-EXT-STS:task_state'] = json.pop(task_state)
- return json
-
-
-class ServersClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(ServersClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_key_value(self, node):
- """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
- data = {}
- for node in node.getchildren():
- data[node.get('key')] = node.text
- return data
-
- def _parse_links(self, node, json):
- del json['link']
- json['links'] = []
- for linknode in node.findall('{http://www.w3.org/2005/Atom}link'):
- json['links'].append(xml_utils.xml_to_json(linknode))
-
- def _parse_server(self, body):
- json = _translate_server_xml_to_json(body)
-
- if 'metadata' in json and json['metadata']:
- # NOTE(danms): if there was metadata, we need to re-parse
- # that as a special type
- metadata_tag = body.find('{%s}metadata' % xml_utils.XMLNS_11)
- json["metadata"] = self._parse_key_value(metadata_tag)
- if 'link' in json:
- self._parse_links(body, json)
- for sub in ['image', 'flavor']:
- if sub in json and 'link' in json[sub]:
- self._parse_links(body, json[sub])
- return json
-
- def _parse_xml_virtual_interfaces(self, xml_dom):
- """
- Return server's virtual interfaces XML as JSON.
- """
- data = {"virtual_interfaces": []}
- for iface in xml_dom.getchildren():
- data["virtual_interfaces"].append(
- {"id": iface.get("id"),
- "mac_address": iface.get("mac_address")})
- return data
-
- def get_server(self, server_id):
- """Returns the details of an existing server."""
- resp, body = self.get("servers/%s" % str(server_id))
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def migrate_server(self, server_id, **kwargs):
- """Migrates the given server ."""
- return self.action(server_id, 'migrate', None, **kwargs)
-
- def lock_server(self, server_id, **kwargs):
- """Locks the given server."""
- return self.action(server_id, 'lock', None, **kwargs)
-
- def unlock_server(self, server_id, **kwargs):
- """Unlocks the given server."""
- return self.action(server_id, 'unlock', None, **kwargs)
-
- def suspend_server(self, server_id, **kwargs):
- """Suspends the provided server."""
- return self.action(server_id, 'suspend', None, **kwargs)
-
- def resume_server(self, server_id, **kwargs):
- """Un-suspends the provided server."""
- return self.action(server_id, 'resume', None, **kwargs)
-
- def pause_server(self, server_id, **kwargs):
- """Pauses the provided server."""
- return self.action(server_id, 'pause', None, **kwargs)
-
- def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provided server."""
- return self.action(server_id, 'unpause', None, **kwargs)
-
- def shelve_server(self, server_id, **kwargs):
- """Shelves the provided server."""
- return self.action(server_id, 'shelve', None, **kwargs)
-
- def unshelve_server(self, server_id, **kwargs):
- """Un-shelves the provided server."""
- return self.action(server_id, 'unshelve', None, **kwargs)
-
- def shelve_offload_server(self, server_id, **kwargs):
- """Shelve-offload the provided server."""
- return self.action(server_id, 'shelveOffload', None, **kwargs)
-
- def reset_state(self, server_id, state='error'):
- """Resets the state of a server to active/error."""
- return self.action(server_id, 'os-resetState', None, state=state)
-
- def delete_server(self, server_id):
- """Deletes the given server."""
- return self.delete("servers/%s" % str(server_id))
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_utils.xml_to_json(child))
- return array
-
- def _parse_server_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(self._parse_server(child))
- return array
-
- def list_servers(self, params=None):
- url = 'servers'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- servers = self._parse_server_array(etree.fromstring(body))
- return resp, {"servers": servers}
-
- def list_servers_with_detail(self, params=None):
- url = 'servers/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- servers = self._parse_server_array(etree.fromstring(body))
- return resp, {"servers": servers}
-
- def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
- accessIPv6=None, disk_config=None):
- doc = xml_utils.Document()
- server = xml_utils.Element("server")
- doc.append(server)
-
- if name is not None:
- server.add_attr("name", name)
- if accessIPv4 is not None:
- server.add_attr("accessIPv4", accessIPv4)
- if accessIPv6 is not None:
- server.add_attr("accessIPv6", accessIPv6)
- if disk_config is not None:
- server.add_attr('xmlns:OS-DCF', "http://docs.openstack.org/"
- "compute/ext/disk_config/api/v1.1")
- server.add_attr("OS-DCF:diskConfig", disk_config)
- if meta is not None:
- metadata = xml_utils.Element("metadata")
- server.append(metadata)
- for k, v in meta:
- meta = xml_utils.Element("meta", key=k)
- meta.append(xml_utils.Text(v))
- metadata.append(meta)
-
- resp, body = self.put('servers/%s' % str(server_id), str(doc))
- return resp, xml_utils.xml_to_json(etree.fromstring(body))
-
- def create_server(self, name, image_ref, flavor_ref, **kwargs):
- """
- Creates an instance of a server.
- name (Required): The name of the server.
- image_ref (Required): Reference to the image used to build the server.
- flavor_ref (Required): The flavor used to build the server.
- Following optional keyword arguments are accepted:
- adminPass: Sets the initial root password.
- key_name: Key name of keypair that was created earlier.
- meta: A dictionary of values to be used as metadata.
- personality: A list of dictionaries for files to be injected into
- the server.
- security_groups: A list of security group dicts.
- networks: A list of network dicts with UUID and fixed_ip.
- user_data: User data for instance.
- availability_zone: Availability zone in which to launch instance.
- accessIPv4: The IPv4 access address for the server.
- accessIPv6: The IPv6 access address for the server.
- min_count: Count of minimum number of instances to launch.
- max_count: Count of maximum number of instances to launch.
- disk_config: Determines if user or admin controls disk configuration.
- block_device_mapping: Block device mapping for the server.
- """
- server = xml_utils.Element("server",
- xmlns=xml_utils.XMLNS_11,
- imageRef=image_ref,
- flavorRef=flavor_ref,
- name=name)
-
- for attr in ["adminPass", "accessIPv4", "accessIPv6", "key_name",
- "user_data", "availability_zone", "min_count",
- "max_count", "return_reservation_id",
- "block_device_mapping"]:
- if attr in kwargs:
- server.add_attr(attr, kwargs[attr])
-
- if 'disk_config' in kwargs:
- server.add_attr('xmlns:OS-DCF', "http://docs.openstack.org/"
- "compute/ext/disk_config/api/v1.1")
- server.add_attr('OS-DCF:diskConfig', kwargs['disk_config'])
-
- if 'security_groups' in kwargs:
- secgroups = xml_utils.Element("security_groups")
- server.append(secgroups)
- for secgroup in kwargs['security_groups']:
- s = xml_utils.Element("security_group", name=secgroup['name'])
- secgroups.append(s)
-
- if 'networks' in kwargs:
- networks = xml_utils.Element("networks")
- server.append(networks)
- for network in kwargs['networks']:
- if 'fixed_ip' in network:
- s = xml_utils.Element("network", uuid=network['uuid'],
- fixed_ip=network['fixed_ip'])
- else:
- s = xml_utils.Element("network", uuid=network['uuid'])
- networks.append(s)
-
- if 'meta' in kwargs:
- metadata = xml_utils.Element("metadata")
- server.append(metadata)
- for k, v in kwargs['meta'].items():
- meta = xml_utils.Element("meta", key=k)
- meta.append(xml_utils.Text(v))
- metadata.append(meta)
-
- if 'personality' in kwargs:
- personality = xml_utils.Element('personality')
- server.append(personality)
- for k in kwargs['personality']:
- temp = xml_utils.Element('file', path=k['path'])
- temp.append(xml_utils.Text(k['contents']))
- personality.append(temp)
-
- if 'sched_hints' in kwargs:
- sched_hints = kwargs.get('sched_hints')
- hints = xml_utils.Element("os:scheduler_hints")
- hints.add_attr('xmlns:os', xml_utils.XMLNS_11)
- for attr in sched_hints:
- p1 = xml_utils.Element(attr)
- p1.append(sched_hints[attr])
- hints.append(p1)
- server.append(hints)
- resp, body = self.post('servers', str(xml_utils.Document(server)))
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def wait_for_server_status(self, server_id, status, extra_timeout=0,
- raise_on_error=True):
- """Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status,
- extra_timeout=extra_timeout,
- raise_on_error=raise_on_error)
-
- def wait_for_server_termination(self, server_id, ignore_error=False):
- """Waits for server to reach termination."""
- start_time = int(time.time())
- while True:
- try:
- resp, body = self.get_server(server_id)
- except exceptions.NotFound:
- return
-
- server_status = body['status']
- if server_status == 'ERROR' and not ignore_error:
- raise exceptions.BuildErrorException(server_id=server_id)
-
- if int(time.time()) - start_time >= self.build_timeout:
- raise exceptions.TimeoutException
-
- time.sleep(self.build_interval)
-
- def _parse_network(self, node):
- addrs = []
- for child in node.getchildren():
- addrs.append({'version': int(child.get('version')),
- 'addr': child.get('addr')})
- return {node.get('id'): addrs}
-
- def list_addresses(self, server_id):
- """Lists all addresses for a server."""
- resp, body = self.get("servers/%s/ips" % str(server_id))
-
- networks = {}
- xml_list = etree.fromstring(body)
- for child in xml_list.getchildren():
- network = self._parse_network(child)
- networks.update(**network)
-
- return resp, networks
-
- def list_addresses_by_network(self, server_id, network_id):
- """Lists all addresses of a specific network type for a server."""
- resp, body = self.get("servers/%s/ips/%s" % (str(server_id),
- network_id))
- network = self._parse_network(etree.fromstring(body))
-
- return resp, network
-
- def action(self, server_id, action_name, response_key, **kwargs):
- if 'xmlns' not in kwargs:
- kwargs['xmlns'] = xml_utils.XMLNS_11
- doc = xml_utils.Document((xml_utils.Element(action_name, **kwargs)))
- resp, body = self.post("servers/%s/action" % server_id, str(doc))
- if response_key is not None:
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def create_backup(self, server_id, backup_type, rotation, name):
- """Backup a server instance."""
- return self.action(server_id, "createBackup", None,
- backup_type=backup_type,
- rotation=rotation,
- name=name)
-
- def change_password(self, server_id, password):
- return self.action(server_id, "changePassword", None,
- adminPass=password)
-
- def get_password(self, server_id):
- resp, body = self.get("servers/%s/os-server-password" % str(server_id))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def delete_password(self, server_id):
- """
- Removes the encrypted server password from the metadata server
- Note that this does not actually change the instance server
- password.
- """
- return self.delete("servers/%s/os-server-password" % str(server_id))
-
- def reboot(self, server_id, reboot_type):
- return self.action(server_id, "reboot", None, type=reboot_type)
-
- def rebuild(self, server_id, image_ref, **kwargs):
- kwargs['imageRef'] = image_ref
- if 'disk_config' in kwargs:
- kwargs['OS-DCF:diskConfig'] = kwargs['disk_config']
- del kwargs['disk_config']
- kwargs['xmlns:OS-DCF'] = "http://docs.openstack.org/"\
- "compute/ext/disk_config/api/v1.1"
- kwargs['xmlns:atom'] = "http://www.w3.org/2005/Atom"
- if 'xmlns' not in kwargs:
- kwargs['xmlns'] = xml_utils.XMLNS_11
-
- attrs = kwargs.copy()
- if 'metadata' in attrs:
- del attrs['metadata']
- rebuild = xml_utils.Element("rebuild", **attrs)
-
- if 'metadata' in kwargs:
- metadata = xml_utils.Element("metadata")
- rebuild.append(metadata)
- for k, v in kwargs['metadata'].items():
- meta = xml_utils.Element("meta", key=k)
- meta.append(xml_utils.Text(v))
- metadata.append(meta)
-
- resp, body = self.post('servers/%s/action' % server_id,
- str(xml_utils.Document(rebuild)))
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def resize(self, server_id, flavor_ref, **kwargs):
- if 'disk_config' in kwargs:
- kwargs['OS-DCF:diskConfig'] = kwargs['disk_config']
- del kwargs['disk_config']
- kwargs['xmlns:OS-DCF'] = "http://docs.openstack.org/"\
- "compute/ext/disk_config/api/v1.1"
- kwargs['xmlns:atom'] = "http://www.w3.org/2005/Atom"
- kwargs['flavorRef'] = flavor_ref
- return self.action(server_id, 'resize', None, **kwargs)
-
- def confirm_resize(self, server_id, **kwargs):
- return self.action(server_id, 'confirmResize', None, **kwargs)
-
- def revert_resize(self, server_id, **kwargs):
- return self.action(server_id, 'revertResize', None, **kwargs)
-
- def stop(self, server_id, **kwargs):
- return self.action(server_id, 'os-stop', None, **kwargs)
-
- def start(self, server_id, **kwargs):
- return self.action(server_id, 'os-start', None, **kwargs)
-
- def create_image(self, server_id, name):
- return self.action(server_id, 'createImage', None, name=name)
-
- def add_security_group(self, server_id, name):
- return self.action(server_id, 'addSecurityGroup', None, name=name)
-
- def remove_security_group(self, server_id, name):
- return self.action(server_id, 'removeSecurityGroup', None, name=name)
-
- def live_migrate_server(self, server_id, dest_host, use_block_migration):
- """This should be called with administrator privileges ."""
-
- req_body = xml_utils.Element("os-migrateLive",
- xmlns=xml_utils.XMLNS_11,
- disk_over_commit=False,
- block_migration=use_block_migration,
- host=dest_host)
-
- resp, body = self.post("servers/%s/action" % str(server_id),
- str(xml_utils.Document(req_body)))
- return resp, body
-
- def list_server_metadata(self, server_id):
- resp, body = self.get("servers/%s/metadata" % str(server_id))
- body = self._parse_key_value(etree.fromstring(body))
- return resp, body
-
- def set_server_metadata(self, server_id, meta, no_metadata_field=False):
- doc = xml_utils.Document()
- if not no_metadata_field:
- metadata = xml_utils.Element("metadata")
- doc.append(metadata)
- for k, v in meta.items():
- meta_element = xml_utils.Element("meta", key=k)
- meta_element.append(xml_utils.Text(v))
- metadata.append(meta_element)
- resp, body = self.put('servers/%s/metadata' % str(server_id), str(doc))
- return resp, xml_utils.xml_to_json(etree.fromstring(body))
-
- def update_server_metadata(self, server_id, meta):
- doc = xml_utils.Document()
- metadata = xml_utils.Element("metadata")
- doc.append(metadata)
- for k, v in meta.items():
- meta_element = xml_utils.Element("meta", key=k)
- meta_element.append(xml_utils.Text(v))
- metadata.append(meta_element)
- resp, body = self.post("/servers/%s/metadata" % str(server_id),
- str(doc))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def get_server_metadata_item(self, server_id, key):
- resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key))
- return resp, dict([(etree.fromstring(body).attrib['key'],
- xml_utils.xml_to_json(etree.fromstring(body)))])
-
- def set_server_metadata_item(self, server_id, key, meta):
- doc = xml_utils.Document()
- for k, v in meta.items():
- meta_element = xml_utils.Element("meta", key=k)
- meta_element.append(xml_utils.Text(v))
- doc.append(meta_element)
- resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- str(doc))
- return resp, xml_utils.xml_to_json(etree.fromstring(body))
-
- def delete_server_metadata_item(self, server_id, key):
- resp, body = self.delete("servers/%s/metadata/%s" %
- (str(server_id), key))
- return resp, body
-
- def get_console_output(self, server_id, length):
- kwargs = {'length': length} if length else {}
- return self.action(server_id, 'os-getConsoleOutput', 'output',
- **kwargs)
-
- def list_virtual_interfaces(self, server_id):
- """
- List the virtual interfaces used in an instance.
- """
- resp, body = self.get('/'.join(['servers', server_id,
- 'os-virtual-interfaces']))
- virt_int = self._parse_xml_virtual_interfaces(etree.fromstring(body))
- return resp, virt_int
-
- def rescue_server(self, server_id, **kwargs):
- """Rescue the provided server."""
- return self.action(server_id, 'rescue', None, **kwargs)
-
- def unrescue_server(self, server_id):
- """Unrescue the provided server."""
- return self.action(server_id, 'unrescue', None)
-
- def attach_volume(self, server_id, volume_id, device='/dev/vdz'):
- post_body = xml_utils.Element("volumeAttachment", volumeId=volume_id,
- device=device)
- resp, body = self.post('servers/%s/os-volume_attachments' % server_id,
- str(xml_utils.Document(post_body)))
- return resp, body
-
- def detach_volume(self, server_id, volume_id):
- headers = {'Content-Type': 'application/xml',
- 'Accept': 'application/xml'}
- resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
- (server_id, volume_id), headers)
- return resp, body
-
- def get_server_diagnostics(self, server_id):
- """Get the usage data for a server."""
- resp, body = self.get("servers/%s/diagnostics" % server_id)
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def list_instance_actions(self, server_id):
- """List the provided server action."""
- resp, body = self.get("servers/%s/os-instance-actions" % server_id)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_instance_action(self, server_id, request_id):
- """Returns the action details of the provided server."""
- resp, body = self.get("servers/%s/os-instance-actions/%s" %
- (server_id, request_id))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def force_delete_server(self, server_id, **kwargs):
- """Force delete a server."""
- return self.action(server_id, 'forceDelete', None, **kwargs)
-
- def restore_soft_deleted_server(self, server_id, **kwargs):
- """Restore a soft-deleted server."""
- return self.action(server_id, 'restore', None, **kwargs)
-
- def reset_network(self, server_id, **kwargs):
- """Resets the Network of a server"""
- return self.action(server_id, 'resetNetwork', None, **kwargs)
-
- def inject_network_info(self, server_id, **kwargs):
- """Inject the Network Info into server"""
- return self.action(server_id, 'injectNetworkInfo', None, **kwargs)
-
- def get_vnc_console(self, server_id, console_type):
- """Get URL of VNC console."""
- return self.action(server_id, "os-getVNCConsole",
- "console", type=console_type)
diff --git a/tempest/services/compute/xml/services_client.py b/tempest/services/compute/xml/services_client.py
deleted file mode 100644
index e1e78d0..0000000
--- a/tempest/services/compute/xml/services_client.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 2013 NEC Corporation
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class ServicesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(ServicesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def list_services(self, params=None):
- url = 'os-services'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- return resp, body
-
- def enable_service(self, host_name, binary):
- """
- Enable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = xml_utils.Element("service")
- post_body.add_attr('binary', binary)
- post_body.add_attr('host', host_name)
-
- resp, body = self.put('os-services/enable', str(
- xml_utils.Document(post_body)))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def disable_service(self, host_name, binary):
- """
- Disable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = xml_utils.Element("service")
- post_body.add_attr('binary', binary)
- post_body.add_attr('host', host_name)
-
- resp, body = self.put('os-services/disable', str(
- xml_utils.Document(post_body)))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/xml/tenant_usages_client.py b/tempest/services/compute/xml/tenant_usages_client.py
deleted file mode 100644
index 0b19f63..0000000
--- a/tempest/services/compute/xml/tenant_usages_client.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright 2013 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class TenantUsagesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(TenantUsagesClientXML, self).__init__(auth_provider)
- self.service = CONF.compute.catalog_type
-
- def _parse_array(self, node):
- json = xml_utils.xml_to_json(node)
- return json
-
- def list_tenant_usages(self, params=None):
- url = 'os-simple-tenant-usage'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- tenant_usage = self._parse_array(etree.fromstring(body))
- return resp, tenant_usage['tenant_usage']
-
- def get_tenant_usage(self, tenant_id, params=None):
- url = 'os-simple-tenant-usage/%s' % tenant_id
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- tenant_usage = self._parse_array(etree.fromstring(body))
- return resp, tenant_usage
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
deleted file mode 100644
index da1764a..0000000
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import time
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class VolumesExtensionsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(VolumesExtensionsClientXML, self).__init__(
- auth_provider)
- self.service = CONF.compute.catalog_type
- self.build_interval = CONF.compute.build_interval
- self.build_timeout = CONF.compute.build_timeout
-
- def _parse_volume(self, body):
- vol = dict((attr, body.get(attr)) for attr in body.keys())
-
- for child in body.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- ns, tag = tag.split("}", 1)
- if tag == 'metadata':
- vol['metadata'] = dict((meta.get('key'),
- meta.text) for meta in list(child))
- else:
- vol[tag] = xml_utils.xml_to_json(child)
- return vol
-
- def list_volumes(self, params=None):
- """List all the volumes created."""
- url = 'os-volumes'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volumes = []
- if body is not None:
- volumes += [self._parse_volume(vol) for vol in list(body)]
- return resp, volumes
-
- def list_volumes_with_detail(self, params=None):
- """List all the details of volumes."""
- url = 'os-volumes/detail'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volumes = []
- if body is not None:
- volumes += [self._parse_volume(vol) for vol in list(body)]
- return resp, volumes
-
- def get_volume(self, volume_id):
- """Returns the details of a single volume."""
- url = "os-volumes/%s" % str(volume_id)
- resp, body = self.get(url)
- body = etree.fromstring(body)
- return resp, self._parse_volume(body)
-
- def create_volume(self, size, display_name=None, metadata=None):
- """Creates a new Volume.
-
- :param size: Size of volume in GB. (Required)
- :param display_name: Optional Volume Name.
- :param metadata: An optional dictionary of values for metadata.
- """
- volume = xml_utils.Element("volume",
- xmlns=xml_utils.XMLNS_11,
- size=size)
- if display_name:
- volume.add_attr('display_name', display_name)
-
- if metadata:
- _metadata = xml_utils.Element('metadata')
- volume.append(_metadata)
- for key, value in metadata.items():
- meta = xml_utils.Element('meta')
- meta.add_attr('key', key)
- meta.append(xml_utils.Text(value))
- _metadata.append(meta)
-
- resp, body = self.post('os-volumes', str(xml_utils.Document(volume)))
- body = xml_utils.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def delete_volume(self, volume_id):
- """Deletes the Specified Volume."""
- return self.delete("os-volumes/%s" % str(volume_id))
-
- def wait_for_volume_status(self, volume_id, status):
- """Waits for a Volume to reach a given status."""
- resp, body = self.get_volume(volume_id)
- volume_name = body['displayName']
- volume_status = body['status']
- start = int(time.time())
-
- while volume_status != status:
- time.sleep(self.build_interval)
- resp, body = self.get_volume(volume_id)
- volume_status = body['status']
- if volume_status == 'error':
- raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
-
- if int(time.time()) - start >= self.build_timeout:
- message = 'Volume %s failed to reach %s status within '\
- 'the required time (%s s).' % (volume_name, status,
- self.build_timeout)
- raise exceptions.TimeoutException(message)
-
- def is_resource_deleted(self, id):
- try:
- self.get_volume(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'volume'
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index e76c1bd..281464c 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -26,10 +26,6 @@
self.service = CONF.identity.catalog_type
self.endpoint_url = 'adminURL'
- # Needed for xml service client
- self.list_tags = ["roles", "tenants", "users", "services",
- "extensions"]
-
def has_admin_extensions(self):
"""
Returns True if the KSADM Admin Extensions are supported
@@ -335,9 +331,6 @@
body=None):
"""A simple HTTP request interface."""
if headers is None:
- # Always accept 'json', for TokenClientXML too.
- # Because XML response is not easily
- # converted to the corresponding JSON one
headers = self.get_headers(accept_type="json")
elif extra_headers:
try:
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 5ad416c..6ac4901 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -36,8 +36,10 @@
"""Creates a user."""
en = kwargs.get('enabled', True)
description = kwargs.get('description', None)
+ default_project_id = kwargs.get('default_project_id')
post_body = {
'project_id': project_id,
+ 'default_project_id': default_project_id,
'description': description,
'domain_id': domain_id,
'email': email,
@@ -57,6 +59,11 @@
email = kwargs.get('email', body['email'])
en = kwargs.get('enabled', body['enabled'])
project_id = kwargs.get('project_id', body['project_id'])
+ if 'default_project_id' in body.keys():
+ default_project_id = kwargs.get('default_project_id',
+ body['default_project_id'])
+ else:
+ default_project_id = kwargs.get('default_project_id')
description = kwargs.get('description', body['description'])
domain_id = kwargs.get('domain_id', body['domain_id'])
post_body = {
@@ -64,6 +71,7 @@
'email': email,
'enabled': en,
'project_id': project_id,
+ 'default_project_id': default_project_id,
'id': user_id,
'domain_id': domain_id,
'description': description
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index e093260..579243c 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -39,14 +39,14 @@
resp, body = self.post('policies', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
- return resp, body['policy']
+ return rest_client.ResponseBody(resp, body['policy'])
def list_policies(self):
"""Lists the policies."""
resp, body = self.get('policies')
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['policies']
+ return rest_client.ResponseBodyList(resp, body['policies'])
def get_policy(self, policy_id):
"""Lists out the given policy."""
@@ -54,7 +54,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['policy']
+ return rest_client.ResponseBody(resp, body['policy'])
def update_policy(self, policy_id, **kwargs):
"""Updates a policy."""
@@ -67,11 +67,11 @@
resp, body = self.patch(url, post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['policy']
+ return rest_client.ResponseBody(resp, body['policy'])
def delete_policy(self, policy_id):
"""Deletes the policy."""
url = "policies/%s" % policy_id
resp, body = self.delete(url)
self.expected_success(204, resp.status)
- return resp, body
+ return rest_client.ResponseBody(resp, body)
diff --git a/tempest/services/identity/v3/xml/__init__.py b/tempest/services/identity/v3/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/identity/v3/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/identity/v3/xml/credentials_client.py b/tempest/services/identity/v3/xml/credentials_client.py
deleted file mode 100644
index 37513d0..0000000
--- a/tempest/services/identity/v3/xml/credentials_client.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v3"
-
-
-class CredentialsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(CredentialsClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.endpoint_url = 'adminURL'
- self.api_version = "v3"
-
- def _parse_body(self, body):
- data = common.xml_to_json(body)
- return data
-
- def _parse_creds(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "credential":
- array.append(common.xml_to_json(child))
- return array
-
- def create_credential(self, access_key, secret_key, user_id, project_id):
- """Creates a credential."""
- cred_type = 'ec2'
- access = ""access": "%s"" % access_key
- secret = ""secret": "%s"" % secret_key
- blob = common.Element('blob',
- xmlns=XMLNS)
- blob.append(common.Text("{%s , %s}"
- % (access, secret)))
- credential = common.Element('credential', project_id=project_id,
- type=cred_type, user_id=user_id)
- credential.append(blob)
- resp, body = self.post('credentials', str(common.Document(credential)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- body['blob'] = json.loads(body['blob'])
- return resp, body
-
- def update_credential(self, credential_id, **kwargs):
- """Updates a credential."""
- _, body = self.get_credential(credential_id)
- cred_type = kwargs.get('type', body['type'])
- access_key = kwargs.get('access_key', body['blob']['access'])
- secret_key = kwargs.get('secret_key', body['blob']['secret'])
- project_id = kwargs.get('project_id', body['project_id'])
- user_id = kwargs.get('user_id', body['user_id'])
- access = ""access": "%s"" % access_key
- secret = ""secret": "%s"" % secret_key
- blob = common.Element('blob',
- xmlns=XMLNS)
- blob.append(common.Text("{%s , %s}"
- % (access, secret)))
- credential = common.Element('credential', project_id=project_id,
- type=cred_type, user_id=user_id)
- credential.append(blob)
- resp, body = self.patch('credentials/%s' % credential_id,
- str(common.Document(credential)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- body['blob'] = json.loads(body['blob'])
- return resp, body
-
- def get_credential(self, credential_id):
- """To GET Details of a credential."""
- resp, body = self.get('credentials/%s' % credential_id)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- body['blob'] = json.loads(body['blob'])
- return resp, body
-
- def list_credentials(self):
- """Lists out all the available credentials."""
- resp, body = self.get('credentials')
- self.expected_success(200, resp.status)
- body = self._parse_creds(etree.fromstring(body))
- return resp, body
-
- def delete_credential(self, credential_id):
- """Deletes a credential."""
- resp, body = self.delete('credentials/%s' % credential_id)
- self.expected_success(204, resp.status)
- return resp, body
diff --git a/tempest/services/identity/v3/xml/endpoints_client.py b/tempest/services/identity/v3/xml/endpoints_client.py
deleted file mode 100644
index 892fb58..0000000
--- a/tempest/services/identity/v3/xml/endpoints_client.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import http
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v3"
-
-
-class EndPointClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(EndPointClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.endpoint_url = 'adminURL'
- self.api_version = "v3"
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "endpoint":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_body(self, body):
- json = common.xml_to_json(body)
- return json
-
- def request(self, method, url, extra_headers=False, headers=None,
- body=None, wait=None):
- """Overriding the existing HTTP request in super class RestClient."""
- if extra_headers:
- try:
- headers.update(self.get_headers())
- except (ValueError, TypeError):
- headers = self.get_headers()
- dscv = CONF.identity.disable_ssl_certificate_validation
- self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv)
- return super(EndPointClientXML, self).request(method, url,
- extra_headers,
- headers=headers,
- body=body)
-
- def list_endpoints(self):
- """Get the list of endpoints."""
- resp, body = self.get("endpoints")
- self.expected_success(200, resp.status)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def create_endpoint(self, service_id, interface, url, **kwargs):
- """Create endpoint.
-
- Normally this function wouldn't allow setting values that are not
- allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
-
- """
- region = kwargs.get('region', None)
- if 'force_enabled' in kwargs:
- enabled = kwargs['force_enabled']
- else:
- enabled = kwargs.get('enabled', None)
- if enabled is not None:
- enabled = str(enabled).lower()
- create_endpoint = common.Element("endpoint",
- xmlns=XMLNS,
- service_id=service_id,
- interface=interface,
- url=url, region=region,
- enabled=enabled)
- resp, body = self.post('endpoints',
- str(common.Document(create_endpoint)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_endpoint(self, endpoint_id, service_id=None, interface=None,
- url=None, region=None, enabled=None, **kwargs):
- """Updates an endpoint with given parameters.
-
- Normally this function wouldn't allow setting values that are not
- allowed for 'enabled'. Use `force_enabled` to set a non-boolean.
-
- """
- doc = common.Document()
- endpoint = common.Element("endpoint")
- doc.append(endpoint)
-
- if service_id:
- endpoint.add_attr("service_id", service_id)
- if interface:
- endpoint.add_attr("interface", interface)
- if url:
- endpoint.add_attr("url", url)
- if region:
- endpoint.add_attr("region", region)
-
- if 'force_enabled' in kwargs:
- endpoint.add_attr("enabled", kwargs['force_enabled'])
- elif enabled is not None:
- endpoint.add_attr("enabled", str(enabled).lower())
-
- resp, body = self.patch('endpoints/%s' % str(endpoint_id), str(doc))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_endpoint(self, endpoint_id):
- """Delete endpoint."""
- resp_header, resp_body = self.delete('endpoints/%s' % endpoint_id)
- self.expected_success(204, resp_header.status)
- return resp_header, resp_body
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
deleted file mode 100644
index fdc0a0a..0000000
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ /dev/null
@@ -1,632 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v3"
-
-
-class IdentityV3ClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(IdentityV3ClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.endpoint_url = 'adminURL'
- self.api_version = "v3"
-
- def _parse_projects(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "project":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_domains(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "domain":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_groups(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "group":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_group_users(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "user":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_roles(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "role":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_users(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "user":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_body(self, body):
- _json = common.xml_to_json(body)
- return _json
-
- def create_user(self, user_name, password=None, project_id=None,
- email=None, domain_id='default', **kwargs):
- """Creates a user."""
- en = kwargs.get('enabled', 'true')
- description = kwargs.get('description', None)
- post_body = common.Element("user",
- xmlns=XMLNS,
- name=user_name,
- password=password,
- description=description,
- email=email,
- enabled=str(en).lower(),
- project_id=project_id,
- domain_id=domain_id)
- resp, body = self.post('users', str(common.Document(post_body)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_user(self, user_id, name, **kwargs):
- """Updates a user."""
- _, body = self.get_user(user_id)
- email = kwargs.get('email', body['email'])
- en = kwargs.get('enabled', body['enabled'])
- project_id = kwargs.get('project_id', body['project_id'])
- description = kwargs.get('description', body['description'])
- domain_id = kwargs.get('domain_id', body['domain_id'])
- update_user = common.Element("user",
- xmlns=XMLNS,
- name=name,
- email=email,
- project_id=project_id,
- domain_id=domain_id,
- description=description,
- enabled=str(en).lower())
- resp, body = self.patch('users/%s' % user_id,
- str(common.Document(update_user)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_user_password(self, user_id, password, original_password):
- """Updates a user password."""
- update_user = common.Element("user",
- xmlns=XMLNS,
- password=password,
- original_password=original_password)
- resp, _ = self.post('users/%s/password' % user_id,
- str(common.Document(update_user)))
- self.expected_success(204, resp.status)
- return resp
-
- def list_user_projects(self, user_id):
- """Lists the projects on which a user has roles assigned."""
- resp, body = self.get('users/%s/projects' % user_id)
- self.expected_success(200, resp.status)
- body = self._parse_projects(etree.fromstring(body))
- return resp, body
-
- def get_users(self, params=None):
- """Get the list of users."""
- url = 'users'
- if params:
- url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_users(etree.fromstring(body))
- return resp, body
-
- def get_user(self, user_id):
- """GET a user."""
- resp, body = self.get("users/%s" % user_id)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_user(self, user_id):
- """Deletes a User."""
- resp, body = self.delete("users/%s" % user_id)
- self.expected_success(204, resp.status)
- return resp, body
-
- def create_project(self, name, **kwargs):
- """Creates a project."""
- description = kwargs.get('description', None)
- en = kwargs.get('enabled', 'true')
- domain_id = kwargs.get('domain_id', 'default')
- post_body = common.Element("project",
- xmlns=XMLNS,
- description=description,
- domain_id=domain_id,
- enabled=str(en).lower(),
- name=name)
- resp, body = self.post('projects',
- str(common.Document(post_body)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_projects(self, params=None):
- """Get the list of projects."""
- url = 'projects'
- if params:
- url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_projects(etree.fromstring(body))
- return resp, body
-
- def update_project(self, project_id, **kwargs):
- """Updates a Project."""
- resp, body = self.get_project(project_id)
- name = kwargs.get('name', body['name'])
- desc = kwargs.get('description', body['description'])
- en = kwargs.get('enabled', body['enabled'])
- domain_id = kwargs.get('domain_id', body['domain_id'])
- post_body = common.Element("project",
- xmlns=XMLNS,
- name=name,
- description=desc,
- enabled=str(en).lower(),
- domain_id=domain_id)
- resp, body = self.patch('projects/%s' % project_id,
- str(common.Document(post_body)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_project(self, project_id):
- """GET a Project."""
- resp, body = self.get("projects/%s" % project_id)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_project(self, project_id):
- """Delete a project."""
- resp, body = self.delete('projects/%s' % str(project_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def create_role(self, name):
- """Create a Role."""
- post_body = common.Element("role",
- xmlns=XMLNS,
- name=name)
- resp, body = self.post('roles', str(common.Document(post_body)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_role(self, role_id):
- """GET a Role."""
- resp, body = self.get('roles/%s' % str(role_id))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_roles(self):
- """Get the list of Roles."""
- resp, body = self.get("roles")
- self.expected_success(200, resp.status)
- body = self._parse_roles(etree.fromstring(body))
- return resp, body
-
- def update_role(self, name, role_id):
- """Updates a Role."""
- post_body = common.Element("role",
- xmlns=XMLNS,
- name=name)
- resp, body = self.patch('roles/%s' % str(role_id),
- str(common.Document(post_body)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_role(self, role_id):
- """Delete a role."""
- resp, body = self.delete('roles/%s' % str(role_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def assign_user_role(self, project_id, user_id, role_id):
- """Add roles to a user on a tenant."""
- resp, body = self.put('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), '')
- self.expected_success(204, resp.status)
- return resp, body
-
- def create_domain(self, name, **kwargs):
- """Creates a domain."""
- description = kwargs.get('description', None)
- en = kwargs.get('enabled', True)
- post_body = common.Element("domain",
- xmlns=XMLNS,
- name=name,
- description=description,
- enabled=str(en).lower())
- resp, body = self.post('domains', str(common.Document(post_body)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_domains(self):
- """Get the list of domains."""
- resp, body = self.get("domains")
- self.expected_success(200, resp.status)
- body = self._parse_domains(etree.fromstring(body))
- return resp, body
-
- def delete_domain(self, domain_id):
- """Delete a domain."""
- resp, body = self.delete('domains/%s' % domain_id)
- self.expected_success(204, resp.status)
- return resp, body
-
- def update_domain(self, domain_id, **kwargs):
- """Updates a domain."""
- _, body = self.get_domain(domain_id)
- description = kwargs.get('description', body['description'])
- en = kwargs.get('enabled', body['enabled'])
- name = kwargs.get('name', body['name'])
- post_body = common.Element("domain",
- xmlns=XMLNS,
- name=name,
- description=description,
- enabled=str(en).lower())
- resp, body = self.patch('domains/%s' % domain_id,
- str(common.Document(post_body)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_domain(self, domain_id):
- """Get Domain details."""
- resp, body = self.get('domains/%s' % domain_id)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_token(self, resp_token):
- """GET a Token Details."""
- headers = {'Content-Type': 'application/xml',
- 'Accept': 'application/xml',
- 'X-Subject-Token': resp_token}
- resp, body = self.get("auth/tokens", headers=headers)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_token(self, resp_token):
- """Delete a Given Token."""
- headers = {'X-Subject-Token': resp_token}
- resp, body = self.delete("auth/tokens", headers=headers)
- self.expected_success(204, resp.status)
- return resp, body
-
- def create_group(self, name, **kwargs):
- """Creates a group."""
- description = kwargs.get('description', None)
- domain_id = kwargs.get('domain_id', 'default')
- project_id = kwargs.get('project_id', None)
- post_body = common.Element("group",
- xmlns=XMLNS,
- name=name,
- description=description,
- domain_id=domain_id,
- project_id=project_id)
- resp, body = self.post('groups', str(common.Document(post_body)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_group(self, group_id):
- """Get group details."""
- resp, body = self.get('groups/%s' % group_id)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_group(self, group_id, **kwargs):
- """Updates a group."""
- _, body = self.get_group(group_id)
- name = kwargs.get('name', body['name'])
- description = kwargs.get('description', body['description'])
- post_body = common.Element("group",
- xmlns=XMLNS,
- name=name,
- description=description)
- resp, body = self.patch('groups/%s' % group_id,
- str(common.Document(post_body)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_group(self, group_id):
- """Delete a group."""
- resp, body = self.delete('groups/%s' % group_id)
- self.expected_success(204, resp.status)
- return resp, body
-
- def add_group_user(self, group_id, user_id):
- """Add user into group."""
- resp, body = self.put('groups/%s/users/%s' % (group_id, user_id), '')
- self.expected_success(204, resp.status)
- return resp, body
-
- def list_group_users(self, group_id):
- """List users in group."""
- resp, body = self.get('groups/%s/users' % group_id)
- self.expected_success(200, resp.status)
- body = self._parse_group_users(etree.fromstring(body))
- return resp, body
-
- def list_user_groups(self, user_id):
- """Lists the groups which a user belongs to."""
- resp, body = self.get('users/%s/groups' % user_id)
- self.expected_success(200, resp.status)
- body = self._parse_groups(etree.fromstring(body))
- return resp, body
-
- def delete_group_user(self, group_id, user_id):
- """Delete user in group."""
- resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def assign_user_role_on_project(self, project_id, user_id, role_id):
- """Add roles to a user on a project."""
- resp, body = self.put('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id), '')
- self.expected_success(204, resp.status)
- return resp, body
-
- def assign_user_role_on_domain(self, domain_id, user_id, role_id):
- """Add roles to a user on a domain."""
- resp, body = self.put('domains/%s/users/%s/roles/%s' %
- (domain_id, user_id, role_id), '')
- self.expected_success(204, resp.status)
- return resp, body
-
- def list_user_roles_on_project(self, project_id, user_id):
- """list roles of a user on a project."""
- resp, body = self.get('projects/%s/users/%s/roles' %
- (project_id, user_id))
- self.expected_success(200, resp.status)
- body = self._parse_roles(etree.fromstring(body))
- return resp, body
-
- def list_user_roles_on_domain(self, domain_id, user_id):
- """list roles of a user on a domain."""
- resp, body = self.get('domains/%s/users/%s/roles' %
- (domain_id, user_id))
- self.expected_success(200, resp.status)
- body = self._parse_roles(etree.fromstring(body))
- return resp, body
-
- def revoke_role_from_user_on_project(self, project_id, user_id, role_id):
- """Delete role of a user on a project."""
- resp, body = self.delete('projects/%s/users/%s/roles/%s' %
- (project_id, user_id, role_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def revoke_role_from_user_on_domain(self, domain_id, user_id, role_id):
- """Delete role of a user on a domain."""
- resp, body = self.delete('domains/%s/users/%s/roles/%s' %
- (domain_id, user_id, role_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def assign_group_role_on_project(self, project_id, group_id, role_id):
- """Add roles to a user on a project."""
- resp, body = self.put('projects/%s/groups/%s/roles/%s' %
- (project_id, group_id, role_id), '')
- self.expected_success(204, resp.status)
- return resp, body
-
- def assign_group_role_on_domain(self, domain_id, group_id, role_id):
- """Add roles to a user on a domain."""
- resp, body = self.put('domains/%s/groups/%s/roles/%s' %
- (domain_id, group_id, role_id), '')
- self.expected_success(204, resp.status)
- return resp, body
-
- def list_group_roles_on_project(self, project_id, group_id):
- """list roles of a user on a project."""
- resp, body = self.get('projects/%s/groups/%s/roles' %
- (project_id, group_id))
- self.expected_success(200, resp.status)
- body = self._parse_roles(etree.fromstring(body))
- return resp, body
-
- def list_group_roles_on_domain(self, domain_id, group_id):
- """list roles of a user on a domain."""
- resp, body = self.get('domains/%s/groups/%s/roles' %
- (domain_id, group_id))
- self.expected_success(200, resp.status)
- body = self._parse_roles(etree.fromstring(body))
- return resp, body
-
- def revoke_role_from_group_on_project(self, project_id, group_id, role_id):
- """Delete role of a user on a project."""
- resp, body = self.delete('projects/%s/groups/%s/roles/%s' %
- (project_id, group_id, role_id))
- self.expected_success(204, resp.status)
- return resp, body
-
- def revoke_role_from_group_on_domain(self, domain_id, group_id, role_id):
- """Delete role of a user on a domain."""
- resp, body = self.delete('domains/%s/groups/%s/roles/%s' %
- (domain_id, group_id, role_id))
- self.expected_success(204, resp.status)
- return resp, body
-
-
-class V3TokenClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self):
- super(V3TokenClientXML, self).__init__(None)
- auth_url = CONF.identity.uri_v3
- if not auth_url:
- raise exceptions.InvalidConfiguration('you must specify a v3 uri '
- 'if using the v3 identity '
- 'api')
- if 'auth/tokens' not in auth_url:
- auth_url = auth_url.rstrip('/') + '/auth/tokens'
-
- self.auth_url = auth_url
-
- def auth(self, user=None, password=None, tenant=None, user_type='id',
- domain=None, token=None):
- """
- :param user: user id or name, as specified in user_type
- :param domain: the user and tenant domain
- :param token: a token to re-scope.
-
- Accepts different combinations of credentials. Restrictions:
- - tenant and domain are only name (no id)
- - user domain and tenant domain are assumed identical
- - domain scope is not supported here
- Sample sample valid combinations:
- - token
- - token, tenant, domain
- - user_id, password
- - username, password, domain
- - username, password, tenant, domain
- Validation is left to the server side.
- """
-
- methods = common.Element('methods')
- identity = common.Element('identity')
-
- if token:
- method = common.Element('method')
- method.append(common.Text('token'))
- methods.append(method)
-
- token = common.Element('token', id=token)
- identity.append(token)
-
- if user and password:
- if user_type == 'id':
- _user = common.Element('user', id=user, password=password)
- else:
- _user = common.Element('user', name=user, password=password)
- if domain is not None:
- _domain = common.Element('domain', name=domain)
- _user.append(_domain)
-
- password = common.Element('password')
- password.append(_user)
- method = common.Element('method')
- method.append(common.Text('password'))
- methods.append(method)
- identity.append(password)
-
- identity.append(methods)
-
- auth = common.Element('auth')
- auth.append(identity)
-
- if tenant is not None:
- project = common.Element('project', name=tenant)
- _domain = common.Element('domain', name=domain)
- project.append(_domain)
- scope = common.Element('scope')
- scope.append(project)
- auth.append(scope)
-
- resp, body = self.post(self.auth_url, body=str(common.Document(auth)))
- self.expected_success(201, resp.status)
- return resp, body
-
- def request(self, method, url, extra_headers=False, headers=None,
- body=None):
- """A simple HTTP request interface."""
- if headers is None:
- # Always accept 'json', for xml token client too.
- # Because XML response is not easily
- # converted to the corresponding JSON one
- headers = self.get_headers(accept_type="json")
- elif extra_headers:
- try:
- headers.update(self.get_headers(accept_type="json"))
- except (ValueError, TypeError):
- headers = self.get_headers(accept_type="json")
- resp, resp_body = self.http_obj.request(url, method,
- headers=headers, body=body)
- self._log_request(method, url, resp)
-
- if resp.status in [401, 403]:
- resp_body = json.loads(resp_body)
- raise exceptions.Unauthorized(resp_body['error']['message'])
- elif resp.status not in [200, 201, 204]:
- raise exceptions.IdentityError(
- 'Unexpected status code {0}'.format(resp.status))
-
- return resp, json.loads(resp_body)
-
- def get_token(self, user, password, tenant, domain='Default',
- auth_data=False):
- """
- :param user: username
- Returns (token id, token data) for supplied credentials
- """
- resp, body = self.auth(user, password, tenant, user_type='name',
- domain=domain)
-
- token = resp.get('x-subject-token')
- if auth_data:
- return token, body['token']
- else:
- return token
diff --git a/tempest/services/identity/v3/xml/policy_client.py b/tempest/services/identity/v3/xml/policy_client.py
deleted file mode 100644
index 41bbfe5..0000000
--- a/tempest/services/identity/v3/xml/policy_client.py
+++ /dev/null
@@ -1,104 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import http
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v3"
-
-
-class PolicyClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(PolicyClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.endpoint_url = 'adminURL'
- self.api_version = "v3"
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "policy":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_body(self, body):
- json = common.xml_to_json(body)
- return json
-
- def request(self, method, url, extra_headers=False, headers=None,
- body=None, wait=None):
- """Overriding the existing HTTP request in super class RestClient."""
- if extra_headers:
- try:
- headers.update(self.get_headers())
- except (ValueError, TypeError):
- headers = self.get_headers()
- dscv = CONF.identity.disable_ssl_certificate_validation
- self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv)
- return super(PolicyClientXML, self).request(method, url,
- extra_headers,
- headers=headers,
- body=body)
-
- def create_policy(self, blob, type):
- """Creates a Policy."""
- create_policy = common.Element("policy", xmlns=XMLNS,
- blob=blob, type=type)
- resp, body = self.post('policies', str(common.Document(create_policy)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_policies(self):
- """Lists the policies."""
- resp, body = self.get('policies')
- self.expected_success(200, resp.status)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_policy(self, policy_id):
- """Lists out the given policy."""
- url = 'policies/%s' % policy_id
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_policy(self, policy_id, **kwargs):
- """Updates a policy."""
- type = kwargs.get('type')
- update_policy = common.Element("policy", xmlns=XMLNS, type=type)
- url = 'policies/%s' % policy_id
- resp, body = self.patch(url, str(common.Document(update_policy)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_policy(self, policy_id):
- """Deletes the policy."""
- url = "policies/%s" % policy_id
- resp, body = self.delete(url)
- self.expected_success(204, resp.status)
- return resp, body
diff --git a/tempest/services/identity/v3/xml/region_client.py b/tempest/services/identity/v3/xml/region_client.py
deleted file mode 100644
index 7669678..0000000
--- a/tempest/services/identity/v3/xml/region_client.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# Copyright 2014 Hewlett-Packard Development Company, L.P
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import http
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v3"
-
-
-class RegionClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(RegionClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.region_url = 'adminURL'
- self.api_version = "v3"
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "region":
- array.append(common.xml_to_json(child))
- return array
-
- def _parse_body(self, body):
- json = common.xml_to_json(body)
- return json
-
- def request(self, method, url, extra_headers=False, headers=None,
- body=None, wait=None):
- """Overriding the existing HTTP request in super class RestClient."""
- if extra_headers:
- try:
- headers.update(self.get_headers())
- except (ValueError, TypeError):
- headers = self.get_headers()
- dscv = CONF.identity.disable_ssl_certificate_validation
- self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv)
- return super(RegionClientXML, self).request(method, url,
- extra_headers,
- headers=headers,
- body=body)
-
- def create_region(self, description, **kwargs):
- """Create region."""
- create_region = common.Element("region",
- xmlns=XMLNS,
- description=description)
- if 'parent_region_id' in kwargs:
- create_region.append(common.Element(
- 'parent_region_id', kwargs.get('parent_region_id')))
- if 'unique_region_id' in kwargs:
- resp, body = self.put(
- 'regions/%s' % kwargs.get('unique_region_id'),
- str(common.Document(create_region)))
- else:
- resp, body = self.post('regions',
- str(common.Document(create_region)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def update_region(self, region_id, **kwargs):
- """Updates an region with given parameters.
- """
- description = kwargs.get('description', None)
- update_region = common.Element("region",
- xmlns=XMLNS,
- description=description)
- if 'parent_region_id' in kwargs:
- update_region.append(common.Element('parent_region_id',
- kwargs.get('parent_region_id')))
-
- resp, body = self.patch('regions/%s' % str(region_id),
- str(common.Document(update_region)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_region(self, region_id):
- """Get Region."""
- url = 'regions/%s' % region_id
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def list_regions(self, params=None):
- """Get the list of regions."""
- url = 'regions'
- if params:
- url += '?%s' % urllib.urlencode(params)
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def delete_region(self, region_id):
- """Delete region."""
- resp, body = self.delete('regions/%s' % region_id)
- self.expected_success(204, resp.status)
- return resp, body
diff --git a/tempest/services/identity/v3/xml/service_client.py b/tempest/services/identity/v3/xml/service_client.py
deleted file mode 100644
index 14adfac..0000000
--- a/tempest/services/identity/v3/xml/service_client.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v3"
-
-
-class ServiceClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(ServiceClientXML, self).__init__(auth_provider)
- self.service = CONF.identity.catalog_type
- self.endpoint_url = 'adminURL'
- self.api_version = "v3"
-
- def _parse_body(self, body):
- data = common.xml_to_json(body)
- return data
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[1] == "service":
- array.append(common.xml_to_json(child))
- return array
-
- def update_service(self, service_id, **kwargs):
- """Updates a service_id."""
- resp, body = self.get_service(service_id)
- name = kwargs.get('name', body['name'])
- description = kwargs.get('description', body['description'])
- type = kwargs.get('type', body['type'])
- update_service = common.Element("service",
- xmlns=XMLNS,
- id=service_id,
- name=name,
- description=description,
- type=type)
- resp, body = self.patch('services/%s' % service_id,
- str(common.Document(update_service)))
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def get_service(self, service_id):
- """Get Service."""
- url = 'services/%s' % service_id
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def create_service(self, serv_type, name=None, description=None):
- post_body = common.Element("service",
- xmlns=XMLNS,
- name=name,
- description=description,
- type=serv_type)
- resp, body = self.post("services", str(common.Document(post_body)))
- self.expected_success(201, resp.status)
- body = self._parse_body(etree.fromstring(body))
- return resp, body
-
- def delete_service(self, serv_id):
- url = "services/" + serv_id
- resp, body = self.delete(url)
- self.expected_success(204, resp.status)
- return resp, body
-
- def list_services(self):
- resp, body = self.get('services')
- self.expected_success(200, resp.status)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/identity/xml/__init__.py b/tempest/services/identity/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/identity/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/identity/xml/identity_client.py b/tempest/services/identity/xml/identity_client.py
deleted file mode 100644
index eaf9390..0000000
--- a/tempest/services/identity/xml/identity_client.py
+++ /dev/null
@@ -1,172 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from tempest.common import xml_utils as xml
-from tempest import config
-from tempest.services.identity.json import identity_client
-
-CONF = config.CONF
-
-XMLNS = "http://docs.openstack.org/identity/api/v2.0"
-
-
-class IdentityClientXML(identity_client.IdentityClientJSON):
- TYPE = "xml"
-
- def create_role(self, name):
- """Create a role."""
- create_role = xml.Element("role", xmlns=XMLNS, name=name)
- resp, body = self.post('OS-KSADM/roles',
- str(xml.Document(create_role)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def get_role(self, role_id):
- """Get a role by its id."""
- resp, body = self.get('OS-KSADM/roles/%s' % role_id)
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def create_tenant(self, name, **kwargs):
- """
- Create a tenant
- name (required): New tenant name
- description: Description of new tenant (default is none)
- enabled <true|false>: Initial tenant status (default is true)
- """
- en = kwargs.get('enabled', 'true')
- create_tenant = xml.Element("tenant",
- xmlns=XMLNS,
- name=name,
- description=kwargs.get('description', ''),
- enabled=str(en).lower())
- resp, body = self.post('tenants', str(xml.Document(create_tenant)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def list_tenants(self):
- """Returns tenants."""
- resp, body = self.get('tenants')
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def update_tenant(self, tenant_id, **kwargs):
- """Updates a tenant."""
- _, body = self.get_tenant(tenant_id)
- name = kwargs.get('name', body['name'])
- desc = kwargs.get('description', body['description'])
- en = kwargs.get('enabled', body['enabled'])
- update_tenant = xml.Element("tenant",
- xmlns=XMLNS,
- id=tenant_id,
- name=name,
- description=desc,
- enabled=str(en).lower())
-
- resp, body = self.post('tenants/%s' % tenant_id,
- str(xml.Document(update_tenant)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def create_user(self, name, password, tenant_id, email, **kwargs):
- """Create a user."""
- create_user = xml.Element("user",
- xmlns=XMLNS,
- name=name,
- password=password,
- email=email)
- if tenant_id:
- create_user.add_attr('tenantId', tenant_id)
- if 'enabled' in kwargs:
- create_user.add_attr('enabled', str(kwargs['enabled']).lower())
-
- resp, body = self.post('users', str(xml.Document(create_user)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def update_user(self, user_id, **kwargs):
- """Updates a user."""
- if 'enabled' in kwargs:
- kwargs['enabled'] = str(kwargs['enabled']).lower()
- update_user = xml.Element("user", xmlns=XMLNS, **kwargs)
-
- resp, body = self.put('users/%s' % user_id,
- str(xml.Document(update_user)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def enable_disable_user(self, user_id, enabled):
- """Enables or disables a user."""
- enable_user = xml.Element("user", enabled=str(enabled).lower())
- resp, body = self.put('users/%s/enabled' % user_id,
- str(xml.Document(enable_user)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def create_service(self, name, service_type, **kwargs):
- """Create a service."""
- OS_KSADM = "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"
- create_service = xml.Element("service",
- xmlns=OS_KSADM,
- name=name,
- type=service_type,
- description=kwargs.get('description'))
- resp, body = self.post('OS-KSADM/services',
- str(xml.Document(create_service)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def update_user_password(self, user_id, new_pass):
- """Update User Password."""
- put_body = xml.Element("user",
- id=user_id,
- password=new_pass)
- resp, body = self.put('users/%s/OS-KSADM/password' % user_id,
- str(xml.Document(put_body)))
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
- def list_extensions(self):
- """List all the extensions."""
- resp, body = self.get('/extensions')
- self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
-
-
-class TokenClientXML(identity_client.TokenClientJSON):
- TYPE = "xml"
-
- def auth(self, user, password, tenant=None):
- passwordCreds = xml.Element('passwordCredentials',
- username=user,
- password=password)
- auth_kwargs = {}
- if tenant:
- auth_kwargs['tenantName'] = tenant
- auth = xml.Element('auth', **auth_kwargs)
- auth.append(passwordCreds)
- resp, body = self.post(self.auth_url, body=str(xml.Document(auth)))
- self.expected_success(200, resp.status)
- return resp, body['access']
-
- def auth_token(self, token_id, tenant=None):
- tokenCreds = xml.Element('token', id=token_id)
- auth_kwargs = {}
- if tenant:
- auth_kwargs['tenantName'] = tenant
- auth = xml.Element('auth', **auth_kwargs)
- auth.append(tokenCreds)
- resp, body = self.post(self.auth_url, body=str(xml.Document(auth)))
- self.expected_success(200, resp.status)
- return resp, body['access']
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index d0d32e5..d60c9d9 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -106,9 +106,10 @@
def _get_http(self):
dscv = CONF.identity.disable_ssl_certificate_validation
+ ca_certs = CONF.identity.ca_certificates_file
return glance_http.HTTPClient(auth_provider=self.auth_provider,
filters=self.filters,
- insecure=dscv)
+ insecure=dscv, ca_certs=ca_certs)
def _create_with_data(self, headers, data):
resp, body_iter = self.http.raw_request('POST', '/v1/images',
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 4865073..7421508 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -35,9 +35,10 @@
def _get_http(self):
dscv = CONF.identity.disable_ssl_certificate_validation
+ ca_certs = CONF.identity.ca_certificates_file
return glance_http.HTTPClient(auth_provider=self.auth_provider,
filters=self.filters,
- insecure=dscv)
+ insecure=dscv, ca_certs=ca_certs)
def _validate_schema(self, body, type='image'):
if type in ['image', 'images']:
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 46475f0..809c98b 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -40,8 +40,13 @@
def deserialize_list(self, body):
res = json.loads(body)
# expecting response in form
- # {'resources': [ res1, res2] }
- return res[res.keys()[0]]
+ # {'resources': [ res1, res2] } => when pagination disabled
+ # {'resources': [..], 'resources_links': {}} => if pagination enabled
+ pagination_suffix = "_links"
+ for k in res.keys():
+ if k[-len(pagination_suffix):] == pagination_suffix:
+ continue
+ return res[k]
def serialize(self, data):
return json.dumps(data)
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index 5ad5f37..2c767d9 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -259,6 +259,7 @@
# At this point, the wait has timed out
message = 'Resource %s' % (str(resource))
message += ' failed to reach status %s' % status
+ message += ' (current: %s)' % resource['status']
message += ' within the required time %s' % timeout
caller = misc.find_test_caller()
if caller:
diff --git a/tempest/services/network/xml/__init__.py b/tempest/services/network/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/network/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
deleted file mode 100644
index 4a8dddc..0000000
--- a/tempest/services/network/xml/network_client.py
+++ /dev/null
@@ -1,320 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import xml.etree.ElementTree as ET
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest.services.network import network_client_base as client_base
-
-
-class NetworkClientXML(client_base.NetworkClientBase):
- TYPE = "xml"
-
- # list of plurals used for xml serialization
- PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
- 'fixed_ips', 'extensions', 'extra_dhcp_opts', 'pools',
- 'health_monitors', 'vips', 'members', 'allowed_address_pairs',
- 'firewall_rules', 'security_groups']
-
- def get_rest_client(self, auth_provider):
- rc = rest_client.RestClient(auth_provider)
- rc.TYPE = self.TYPE
- return rc
-
- def deserialize_list(self, body):
- return common.parse_array(etree.fromstring(body), self.PLURALS)
-
- def deserialize_single(self, body):
- return _root_tag_fetcher_and_xml_to_json_parse(body)
-
- def serialize(self, body):
- # TODO(enikanorov): implement better json to xml conversion
- # expecting the dict with single key
- root = body.keys()[0]
- post_body = common.Element(root)
- post_body.add_attr('xmlns:xsi',
- 'http://www.w3.org/2001/XMLSchema-instance')
- elements = set()
- for name, attr in body[root].items():
- elt = self._get_element(name, attr)
- post_body.append(elt)
- if ":" in name:
- elements.add(name.split(":")[0])
- if elements:
- self._add_namespaces(post_body, elements)
- return str(common.Document(post_body))
-
- def serialize_list(self, body, root_name=None, item_name=None):
- # expecting dict in form
- # body = {'resources': [res_dict1, res_dict2, ...]
- post_body = common.Element(root_name)
- post_body.add_attr('xmlns:xsi',
- 'http://www.w3.org/2001/XMLSchema-instance')
- for item in body[body.keys()[0]]:
- elt = common.Element(item_name)
- for name, attr in item.items():
- elt_content = self._get_element(name, attr)
- elt.append(elt_content)
- post_body.append(elt)
- return str(common.Document(post_body))
-
- def _get_element(self, name, value):
- if value is None:
- xml_elem = common.Element(name)
- xml_elem.add_attr("xsi:nil", "true")
- return xml_elem
- elif isinstance(value, dict):
- dict_element = common.Element(name)
- for key, value in value.iteritems():
- elem = self._get_element(key, value)
- dict_element.append(elem)
- return dict_element
- elif isinstance(value, list):
- list_element = common.Element(name)
- for element in value:
- elem = self._get_element(name[:-1], element)
- list_element.append(elem)
- return list_element
- else:
- return common.Element(name, value)
-
- def _add_namespaces(self, root, elements):
- for element in elements:
- root.add_attr('xmlns:%s' % element,
- common.NEUTRON_NAMESPACES[element])
-
- def associate_health_monitor_with_pool(self, health_monitor_id,
- pool_id):
- uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
- pool_id)
- post_body = common.Element("health_monitor")
- p1 = common.Element("id", health_monitor_id,)
- post_body.append(p1)
- resp, body = self.post(uri, str(common.Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- self.rest_client.expected_success(201, resp.status)
- return resp, body
-
- def disassociate_health_monitor_with_pool(self, health_monitor_id,
- pool_id):
- uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
- health_monitor_id)
- resp, body = self.delete(uri)
- self.rest_client.expected_success(204, resp.status)
- return resp, body
-
- def show_extension_details(self, ext_alias):
- uri = '%s/extensions/%s' % (self.uri_prefix, str(ext_alias))
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def create_router(self, name, **kwargs):
- uri = '%s/routers' % (self.uri_prefix)
- router = common.Element("router")
- router.append(common.Element("name", name))
- common.deep_dict_to_xml(router, kwargs)
- resp, body = self.post(uri, str(common.Document(router)))
- self.rest_client.expected_success(201, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_router(self, router_id, **kwargs):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- router = common.Element("router")
- for element, content in kwargs.iteritems():
- router.append(common.Element(element, content))
- resp, body = self.put(uri, str(common.Document(router)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def add_router_interface_with_subnet_id(self, router_id, subnet_id):
- uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
- router_id)
- subnet = common.Element("subnet_id", subnet_id)
- resp, body = self.put(uri, str(common.Document(subnet)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def add_router_interface_with_port_id(self, router_id, port_id):
- uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
- router_id)
- port = common.Element("port_id", port_id)
- resp, body = self.put(uri, str(common.Document(port)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
- uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
- router_id)
- subnet = common.Element("subnet_id", subnet_id)
- resp, body = self.put(uri, str(common.Document(subnet)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def remove_router_interface_with_port_id(self, router_id, port_id):
- uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
- router_id)
- port = common.Element("port_id", port_id)
- resp, body = self.put(uri, str(common.Document(port)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def list_router_interfaces(self, uuid):
- uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- ports = common.parse_array(etree.fromstring(body), self.PLURALS)
- ports = {"ports": ports}
- return resp, ports
-
- def update_agent(self, agent_id, agent_info):
- uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
- agent = common.Element('agent')
- for (key, value) in agent_info.items():
- p = common.Element(key, value)
- agent.append(p)
- resp, body = self.put(uri, str(common.Document(agent)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def list_pools_hosted_by_one_lbaas_agent(self, agent_id):
- uri = '%s/agents/%s/loadbalancer-pools' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- pools = common.parse_array(etree.fromstring(body))
- body = {'pools': pools}
- return resp, body
-
- def show_lbaas_agent_hosting_pool(self, pool_id):
- uri = ('%s/lb/pools/%s/loadbalancer-agent' %
- (self.uri_prefix, pool_id))
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def list_routers_on_l3_agent(self, agent_id):
- uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- routers = common.parse_array(etree.fromstring(body))
- body = {'routers': routers}
- return resp, body
-
- def list_l3_agents_hosting_router(self, router_id):
- uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- agents = common.parse_array(etree.fromstring(body))
- body = {'agents': agents}
- return resp, body
-
- def add_router_to_l3_agent(self, agent_id, router_id):
- uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
- router = (common.Element("router_id", router_id))
- resp, body = self.post(uri, str(common.Document(router)))
- self.rest_client.expected_success(201, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def remove_router_from_l3_agent(self, agent_id, router_id):
- uri = '%s/agents/%s/l3-routers/%s' % (
- self.uri_prefix, agent_id, router_id)
- resp, body = self.delete(uri)
- self.rest_client.expected_success(204, resp.status)
- return resp, body
-
- def list_dhcp_agent_hosting_network(self, network_id):
- uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- agents = common.parse_array(etree.fromstring(body))
- body = {'agents': agents}
- return resp, body
-
- def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
- uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- networks = common.parse_array(etree.fromstring(body))
- body = {'networks': networks}
- return resp, body
-
- def remove_network_from_dhcp_agent(self, agent_id, network_id):
- uri = '%s/agents/%s/dhcp-networks/%s' % (self.uri_prefix, agent_id,
- network_id)
- resp, body = self.delete(uri)
- self.rest_client.expected_success(204, resp.status)
- return resp, body
-
- def list_lb_pool_stats(self, pool_id):
- uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
- resp, body = self.get(uri)
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def add_dhcp_agent_to_network(self, agent_id, network_id):
- uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
- network = common.Element("network_id", network_id)
- resp, body = self.post(uri, str(common.Document(network)))
- self.rest_client.expected_success(201, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def insert_firewall_rule_in_policy(self, firewall_policy_id,
- firewall_rule_id, insert_after="",
- insert_before=""):
- uri = '%s/fw/firewall_policies/%s/insert_rule' % (self.uri_prefix,
- firewall_policy_id)
- rule = common.Element("firewall_rule_id", firewall_rule_id)
- resp, body = self.put(uri, str(common.Document(rule)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def remove_firewall_rule_from_policy(self, firewall_policy_id,
- firewall_rule_id):
- uri = '%s/fw/firewall_policies/%s/remove_rule' % (self.uri_prefix,
- firewall_policy_id)
- rule = common.Element("firewall_rule_id", firewall_rule_id)
- resp, body = self.put(uri, str(common.Document(rule)))
- self.rest_client.expected_success(200, resp.status)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
-
-def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
- body = ET.fromstring(xml_returned_body)
- root_tag = body.tag
- if root_tag.startswith("{"):
- ns, root_tag = root_tag.split("}", 1)
- body = common.xml_to_json(etree.fromstring(xml_returned_body),
- NetworkClientXML.PLURALS)
- nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
- for key, val in body.iteritems():
- if isinstance(val, dict):
- if (nil in val and val[nil] == 'true'):
- body[key] = None
- body = {root_tag: body}
- return body
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index 4417e3b..a2044ef 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -181,7 +181,11 @@
def request(self, method, url, extra_headers=False, headers=None,
body=None):
"""A simple HTTP request interface."""
- self.http_obj = http.ClosingHttp()
+ dscv = CONF.identity.disable_ssl_certificate_validation
+ ca_certs = CONF.identity.ca_certificates_file
+ self.http_obj = http.ClosingHttp(
+ disable_ssl_certificate_validation=dscv,
+ ca_certs=ca_certs)
if headers is None:
headers = {}
elif extra_headers:
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 2231407..7a69fa8 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -197,8 +197,10 @@
body=None):
"""A simple HTTP request interface."""
dscv = CONF.identity.disable_ssl_certificate_validation
+ ca_certs = CONF.identity.ca_certificates_file
self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv)
+ disable_ssl_certificate_validation=dscv,
+ ca_certs=ca_certs)
if headers is None:
headers = {}
elif extra_headers:
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 15306a0..9b4700a 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -185,9 +185,12 @@
resource_status_reason=body['resource_status_reason'])
if int(time.time()) - start >= self.build_timeout:
- message = ('Resource %s failed to reach %s status within '
- 'the required time (%s s).' %
- (resource_name, status, self.build_timeout))
+ message = ('Resource %s failed to reach %s status '
+ '(current %s) within the required time (%s s).' %
+ (resource_name,
+ status,
+ resource_status,
+ self.build_timeout))
raise exceptions.TimeoutException(message)
time.sleep(self.build_interval)
@@ -214,9 +217,10 @@
stack_status_reason=body['stack_status_reason'])
if int(time.time()) - start >= self.build_timeout:
- message = ('Stack %s failed to reach %s status within '
- 'the required time (%s s).' %
- (stack_name, status, self.build_timeout))
+ message = ('Stack %s failed to reach %s status (current: %s) '
+ 'within the required time (%s s).' %
+ (stack_name, status, stack_status,
+ self.build_timeout))
raise exceptions.TimeoutException(message)
time.sleep(self.build_interval)
diff --git a/tempest/services/telemetry/xml/__init__.py b/tempest/services/telemetry/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/telemetry/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/telemetry/xml/telemetry_client.py b/tempest/services/telemetry/xml/telemetry_client.py
deleted file mode 100644
index 3bee8bf..0000000
--- a/tempest/services/telemetry/xml/telemetry_client.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2014 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-import tempest.services.telemetry.telemetry_client_base as client
-
-
-class TelemetryClientXML(client.TelemetryClientBase):
- TYPE = "xml"
-
- def get_rest_client(self, auth_provider):
- rc = rest_client.RestClient(auth_provider)
- rc.TYPE = self.TYPE
- return rc
-
- def _parse_array(self, body):
- array = []
- for child in body.getchildren():
- array.append(common.xml_to_json(child))
- return array
-
- def serialize(self, body):
- return str(common.Document(body))
-
- def deserialize(self, body):
- return self._parse_array(etree.fromstring(body))
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
index 90790e3..5b49040 100644
--- a/tempest/services/volume/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -23,7 +23,7 @@
CONF = config.CONF
-class VolumeQuotasClientJSON(rest_client.RestClient):
+class BaseVolumeQuotasClientJSON(rest_client.RestClient):
"""
Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
"""
@@ -31,7 +31,7 @@
TYPE = "json"
def __init__(self, auth_provider):
- super(VolumeQuotasClientJSON, self).__init__(auth_provider)
+ super(BaseVolumeQuotasClientJSON, self).__init__(auth_provider)
self.service = CONF.volume.catalog_type
self.build_interval = CONF.volume.build_interval
@@ -85,3 +85,9 @@
"""Delete the tenant's quota set."""
resp, body = self.delete('os-quota-sets/%s' % tenant_id)
self.expected_success(200, resp.status)
+
+
+class VolumeQuotasClientJSON(BaseVolumeQuotasClientJSON):
+ """
+ Client class to send CRUD Volume Type API V1 requests to a Cinder endpoint
+ """
diff --git a/tempest/services/volume/json/admin/volume_services_client.py b/tempest/services/volume/json/admin/volume_services_client.py
index c9b8bcc..88c6db0 100644
--- a/tempest/services/volume/json/admin/volume_services_client.py
+++ b/tempest/services/volume/json/admin/volume_services_client.py
@@ -22,10 +22,10 @@
CONF = config.CONF
-class VolumesServicesClientJSON(rest_client.RestClient):
+class BaseVolumesServicesClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
- super(VolumesServicesClientJSON, self).__init__(auth_provider)
+ super(BaseVolumesServicesClientJSON, self).__init__(auth_provider)
self.service = CONF.volume.catalog_type
def list_services(self, params=None):
@@ -37,3 +37,7 @@
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body['services']
+
+
+class VolumesServicesClientJSON(BaseVolumesServicesClientJSON):
+ """Volume V1 volume services client"""
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index 63fc646..51a017e 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -23,13 +23,13 @@
CONF = config.CONF
-class BackupsClientJSON(rest_client.RestClient):
+class BaseBackupsClientJSON(rest_client.RestClient):
"""
Client class to send CRUD Volume backup API requests to a Cinder endpoint
"""
def __init__(self, auth_provider):
- super(BackupsClientJSON, self).__init__(auth_provider)
+ super(BaseBackupsClientJSON, self).__init__(auth_provider)
self.service = CONF.volume.catalog_type
self.build_interval = CONF.volume.build_interval
self.build_timeout = CONF.volume.build_timeout
@@ -95,7 +95,12 @@
raise exceptions.VolumeBackupException(backup_id=backup_id)
if int(time.time()) - start >= self.build_timeout:
- message = ('Volume backup %s failed to reach %s status within '
- 'the required time (%s s).' %
- (backup_id, status, self.build_timeout))
+ message = ('Volume backup %s failed to reach %s status '
+ '(current %s) within the required time (%s s).' %
+ (backup_id, status, backup_status,
+ self.build_timeout))
raise exceptions.TimeoutException(message)
+
+
+class BackupsClientJSON(BaseBackupsClientJSON):
+ """Volume V1 Backups client"""
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index cf2837b..1e49e5a 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -174,10 +174,12 @@
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
if int(time.time()) - start >= self.build_timeout:
- message = 'Volume %s failed to reach %s status within '\
- 'the required time (%s s).' % (volume_id,
- status,
- self.build_timeout)
+ message = ('Volume %s failed to reach %s status (current: %s) '
+ 'within the required time '
+ '(%s s).' % (volume_id,
+ status,
+ volume_status,
+ self.build_timeout))
raise exceptions.TimeoutException(message)
def is_resource_deleted(self, id):
diff --git a/tempest/services/volume/v2/xml/extensions_client.py b/tempest/services/volume/v2/json/admin/volume_quotas_client.py
similarity index 66%
rename from tempest/services/volume/v2/xml/extensions_client.py
rename to tempest/services/volume/v2/json/admin/volume_quotas_client.py
index 13f333c..64f4f33 100644
--- a/tempest/services/volume/v2/xml/extensions_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_quotas_client.py
@@ -1,4 +1,4 @@
-# Copyright 2014 IBM Corp.
+# Copyright 2014 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -13,12 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.services.volume.xml import extensions_client
+from tempest.services.volume.json.admin import volume_quotas_client
-class ExtensionsV2ClientXML(extensions_client.BaseExtensionsClientXML):
+class VolumeQuotasV2Client(volume_quotas_client.BaseVolumeQuotasClientJSON):
+ """
+ Client class to send CRUD Volume V2 API requests to a Cinder endpoint
+ """
def __init__(self, auth_provider):
- super(ExtensionsV2ClientXML, self).__init__(auth_provider)
+ super(VolumeQuotasV2Client, self).__init__(auth_provider)
self.api_version = "v2"
diff --git a/tempest/services/volume/v2/xml/extensions_client.py b/tempest/services/volume/v2/json/admin/volume_services_client.py
similarity index 65%
copy from tempest/services/volume/v2/xml/extensions_client.py
copy to tempest/services/volume/v2/json/admin/volume_services_client.py
index 13f333c..dc3c8ea 100644
--- a/tempest/services/volume/v2/xml/extensions_client.py
+++ b/tempest/services/volume/v2/json/admin/volume_services_client.py
@@ -1,4 +1,4 @@
-# Copyright 2014 IBM Corp.
+# Copyright 2014 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -13,12 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.services.volume.xml import extensions_client
+from tempest.services.volume.json.admin import volume_services_client as vs_cli
-class ExtensionsV2ClientXML(extensions_client.BaseExtensionsClientXML):
+class VolumesServicesV2ClientJSON(vs_cli.BaseVolumesServicesClientJSON):
+ """
+ Client class to send CRUD Volume V2 API requests to a Cinder endpoint
+ """
def __init__(self, auth_provider):
- super(ExtensionsV2ClientXML, self).__init__(auth_provider)
-
+ super(VolumesServicesV2ClientJSON, self).__init__(auth_provider)
self.api_version = "v2"
diff --git a/tempest/services/volume/xml/backups_client.py b/tempest/services/volume/v2/json/backups_client.py
similarity index 72%
rename from tempest/services/volume/xml/backups_client.py
rename to tempest/services/volume/v2/json/backups_client.py
index a691a25..9698075 100644
--- a/tempest/services/volume/xml/backups_client.py
+++ b/tempest/services/volume/v2/json/backups_client.py
@@ -16,11 +16,11 @@
from tempest.services.volume.json import backups_client
-class BackupsClientXML(backups_client.BackupsClientJSON):
+class BackupsClientV2JSON(backups_client.BaseBackupsClientJSON):
"""
- Client class to send CRUD Volume Backup API requests to a Cinder endpoint
+ Client class to send CRUD Volume V2 API requests to a Cinder endpoint
"""
- TYPE = "xml"
- # TODO(gfidente): XML client isn't yet implemented because of bug 1270589
- pass
+ def __init__(self, auth_provider):
+ super(BackupsClientV2JSON, self).__init__(auth_provider)
+ self.api_version = "v2"
diff --git a/tempest/services/volume/v2/xml/__init__.py b/tempest/services/volume/v2/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/volume/v2/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/volume/v2/xml/availability_zone_client.py b/tempest/services/volume/v2/xml/availability_zone_client.py
deleted file mode 100644
index 68ca39b..0000000
--- a/tempest/services/volume/v2/xml/availability_zone_client.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2014 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.services.volume.xml import availability_zone_client
-
-
-class VolumeV2AvailabilityZoneClientXML(
- availability_zone_client.BaseVolumeAvailabilityZoneClientXML):
-
- def __init__(self, auth_provider):
- super(VolumeV2AvailabilityZoneClientXML, self).__init__(
- auth_provider)
-
- self.api_version = "v2"
diff --git a/tempest/services/volume/v2/xml/snapshots_client.py b/tempest/services/volume/v2/xml/snapshots_client.py
deleted file mode 100644
index b29d86c..0000000
--- a/tempest/services/volume/v2/xml/snapshots_client.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.services.volume.xml import snapshots_client
-
-
-class SnapshotsV2ClientXML(snapshots_client.BaseSnapshotsClientXML):
- """Client class to send CRUD Volume V2 API requests."""
-
- def __init__(self, auth_provider):
- super(SnapshotsV2ClientXML, self).__init__(auth_provider)
-
- self.api_version = "v2"
- self.create_resp = 202
diff --git a/tempest/services/volume/v2/xml/volumes_client.py b/tempest/services/volume/v2/xml/volumes_client.py
deleted file mode 100644
index b3133af..0000000
--- a/tempest/services/volume/v2/xml/volumes_client.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import xml_utils as common
-from tempest.services.volume.xml import volumes_client
-
-
-class VolumesV2ClientXML(volumes_client.BaseVolumesClientXML):
- """
- Client class to send CRUD Volume API V2 requests to a Cinder endpoint
- """
-
- def __init__(self, auth_provider):
- super(VolumesV2ClientXML, self).__init__(auth_provider)
-
- self.api_version = "v2"
- self.create_resp = 202
-
- def _parse_volume(self, body):
- vol = dict((attr, body.get(attr)) for attr in body.keys())
-
- for child in body.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- ns, tag = tag.split("}", 1)
- if tag == 'metadata':
- vol['metadata'] = dict((meta.get('key'),
- meta.text) for meta in
- child.getchildren())
- else:
- vol[tag] = common.xml_to_json(child)
- self._translate_attributes_to_json(vol)
- return vol
-
- def list_volumes_with_detail(self, params=None):
- """List all the details of volumes."""
- url = 'volumes/detail'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volumes = []
- if body is not None:
- volumes += [self._parse_volume(vol) for vol in list(body)]
- for v in volumes:
- v = self._check_if_bootable(v)
- self.expected_success(200, resp.status)
- return resp, volumes
-
- def get_volume(self, volume_id):
- """Returns the details of a single volume."""
- url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url)
- body = self._parse_volume(etree.fromstring(body))
- body = self._check_if_bootable(body)
- self.expected_success(200, resp.status)
- return resp, body
diff --git a/tempest/services/volume/xml/__init__.py b/tempest/services/volume/xml/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/volume/xml/__init__.py
+++ /dev/null
diff --git a/tempest/services/volume/xml/admin/__init__.py b/tempest/services/volume/xml/admin/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/volume/xml/admin/__init__.py
+++ /dev/null
diff --git a/tempest/services/volume/xml/admin/volume_hosts_client.py b/tempest/services/volume/xml/admin/volume_hosts_client.py
deleted file mode 100644
index 583b2c5..0000000
--- a/tempest/services/volume/xml/admin/volume_hosts_client.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright 2013 OpenStack Foundation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-
-class BaseVolumeHostsClientXML(rest_client.RestClient):
- """
- Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
- """
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(BaseVolumeHostsClientXML, self).__init__(auth_provider)
- self.service = CONF.volume.catalog_type
- self.build_interval = CONF.compute.build_interval
- self.build_timeout = CONF.compute.build_timeout
-
- def _parse_array(self, node):
- """
- This method is to parse the "list" response body
- Eg:
-
- <?xml version='1.0' encoding='UTF-8'?>
- <hosts>
- <host service-status="available" service="cinder-scheduler"/>
- <host service-status="available" service="cinder-volume"/>
- </hosts>
-
- This method will append the details of specified tag,
- here it is "host"
- Return value would be list of hosts as below
-
- [{'service-status': 'available', 'service': 'cinder-scheduler'},
- {'service-status': 'available', 'service': 'cinder-volume'}]
- """
- array = []
- for child in node.getchildren():
- tag_list = child.tag.split('}', 1)
- if tag_list[0] == "host":
- array.append(common.xml_to_json(child))
- return array
-
- def list_hosts(self, params=None):
- """List all the hosts."""
- url = 'os-hosts'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- self.expected_success(200, resp.status)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
-
-class VolumeHostsClientXML(BaseVolumeHostsClientXML):
- """
- Client class to send CRUD Volume Host API V1 requests to a Cinder endpoint
- """
diff --git a/tempest/services/volume/xml/admin/volume_quotas_client.py b/tempest/services/volume/xml/admin/volume_quotas_client.py
deleted file mode 100644
index acf9102..0000000
--- a/tempest/services/volume/xml/admin/volume_quotas_client.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
-#
-# Author: Sylvain Baubeau <sylvain.baubeau@enovance.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import ast
-
-from lxml import etree
-
-from tempest.common import xml_utils as xml
-from tempest import config
-from tempest.services.volume.json.admin import volume_quotas_client
-
-CONF = config.CONF
-
-
-class VolumeQuotasClientXML(volume_quotas_client.VolumeQuotasClientJSON):
- """
- Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
- """
-
- TYPE = "xml"
-
- def _format_quota(self, q):
- quota = {}
- for k, v in q.items():
- try:
- v = ast.literal_eval(v)
- except (ValueError, SyntaxError):
- pass
-
- quota[k] = v
-
- return quota
-
- def get_quota_usage(self, tenant_id):
- """List the quota set for a tenant."""
-
- resp, body = self.get_quota_set(tenant_id, params={'usage': True})
- self.expected_success(200, resp.status)
- return resp, self._format_quota(body)
-
- def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
- snapshots=None):
- post_body = {}
- element = xml.Element("quota_set")
-
- if gigabytes is not None:
- post_body['gigabytes'] = gigabytes
-
- if volumes is not None:
- post_body['volumes'] = volumes
-
- if snapshots is not None:
- post_body['snapshots'] = snapshots
-
- xml.deep_dict_to_xml(element, post_body)
- resp, body = self.put('os-quota-sets/%s' % tenant_id,
- str(xml.Document(element)))
- body = xml.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, self._format_quota(body)
-
- def delete_quota_set(self, tenant_id):
- """Delete the tenant's quota set."""
- resp, body = self.delete('os-quota-sets/%s' % tenant_id)
- self.expected_success(200, resp.status)
diff --git a/tempest/services/volume/xml/admin/volume_services_client.py b/tempest/services/volume/xml/admin/volume_services_client.py
deleted file mode 100644
index 2ecb590..0000000
--- a/tempest/services/volume/xml/admin/volume_services_client.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2014 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class VolumesServicesClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(VolumesServicesClientXML, self).__init__(auth_provider)
- self.service = CONF.volume.catalog_type
-
- def list_services(self, params=None):
- url = 'os-services'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- node = etree.fromstring(body)
- body = [xml_utils.xml_to_json(x) for x in node.getchildren()]
- self.expected_success(200, resp.status)
- return resp, body
diff --git a/tempest/services/volume/xml/admin/volume_types_client.py b/tempest/services/volume/xml/admin/volume_types_client.py
deleted file mode 100644
index 03d39a8..0000000
--- a/tempest/services/volume/xml/admin/volume_types_client.py
+++ /dev/null
@@ -1,218 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-
-class BaseVolumeTypesClientXML(rest_client.RestClient):
- """
- Client class to send CRUD Volume Types API requests to a Cinder endpoint
- """
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(BaseVolumeTypesClientXML, self).__init__(auth_provider)
- self.service = CONF.volume.catalog_type
- self.build_interval = CONF.compute.build_interval
- self.build_timeout = CONF.compute.build_timeout
-
- def _parse_volume_type(self, body):
- vol_type = dict((attr, body.get(attr)) for attr in body.keys())
-
- for child in body.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- ns, tag = tag.split("}", 1)
- if tag == 'extra_specs':
- vol_type['extra_specs'] = dict((meta.get('key'),
- meta.text)
- for meta in list(child))
- else:
- vol_type[tag] = common.xml_to_json(child)
- return vol_type
-
- def _parse_volume_type_extra_specs(self, body):
- extra_spec = dict((attr, body.get(attr)) for attr in body.keys())
-
- for child in body.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- ns, tag = tag.split("}", 1)
- else:
- extra_spec[tag] = common.xml_to_json(child)
- return extra_spec
-
- def list_volume_types(self, params=None):
- """List all the volume_types created."""
- url = 'types'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volume_types = []
- if body is not None:
- volume_types += [self._parse_volume_type(vol)
- for vol in list(body)]
- self.expected_success(200, resp.status)
- return resp, volume_types
-
- def get_volume_type(self, type_id):
- """Returns the details of a single volume_type."""
- url = "types/%s" % str(type_id)
- resp, body = self.get(url)
- body = etree.fromstring(body)
- self.expected_success(200, resp.status)
- return resp, self._parse_volume_type(body)
-
- def create_volume_type(self, name, **kwargs):
- """
- Creates a new Volume_type.
- name(Required): Name of volume_type.
- Following optional keyword arguments are accepted:
- extra_specs: A dictionary of values to be used as extra_specs.
- """
- vol_type = common.Element("volume_type", xmlns=common.XMLNS_11)
- if name:
- vol_type.add_attr('name', name)
-
- extra_specs = kwargs.get('extra_specs')
- if extra_specs:
- _extra_specs = common.Element('extra_specs')
- vol_type.append(_extra_specs)
- for key, value in extra_specs.items():
- spec = common.Element('extra_spec')
- spec.add_attr('key', key)
- spec.append(common.Text(value))
- _extra_specs.append(spec)
-
- resp, body = self.post('types', str(common.Document(vol_type)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def delete_volume_type(self, type_id):
- """Deletes the Specified Volume_type."""
- resp, body = self.delete("types/%s" % str(type_id))
- self.expected_success(202, resp.status)
-
- def list_volume_types_extra_specs(self, vol_type_id, params=None):
- """List all the volume_types extra specs created."""
- url = 'types/%s/extra_specs' % str(vol_type_id)
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- extra_specs = []
- if body is not None:
- extra_specs += [self._parse_volume_type_extra_specs(spec)
- for spec in list(body)]
- self.expected_success(200, resp.status)
- return resp, extra_specs
-
- def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
- """Returns the details of a single volume_type extra spec."""
- url = "types/%s/extra_specs/%s" % (str(vol_type_id),
- str(extra_spec_name))
- resp, body = self.get(url)
- body = etree.fromstring(body)
- self.expected_success(200, resp.status)
- return resp, self._parse_volume_type_extra_specs(body)
-
- def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
- """
- Creates a new Volume_type extra spec.
- vol_type_id: Id of volume_type.
- extra_specs: A dictionary of values to be used as extra_specs.
- """
- url = "types/%s/extra_specs" % str(vol_type_id)
- extra_specs = common.Element("extra_specs", xmlns=common.XMLNS_11)
- if extra_spec:
- if isinstance(extra_spec, list):
- extra_specs.append(extra_spec)
- else:
- for key, value in extra_spec.items():
- spec = common.Element('extra_spec')
- spec.add_attr('key', key)
- spec.append(common.Text(value))
- extra_specs.append(spec)
- else:
- extra_specs = None
-
- resp, body = self.post(url, str(common.Document(extra_specs)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
- """Deletes the Specified Volume_type extra spec."""
- resp, body = self.delete("types/%s/extra_specs/%s" % (
- (str(vol_id)), str(extra_spec_name)))
- self.expected_success(202, resp.status)
- return resp, body
-
- def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
- extra_spec):
- """
- Update a volume_type extra spec.
- vol_type_id: Id of volume_type.
- extra_spec_name: Name of the extra spec to be updated.
- extra_spec: A dictionary of with key as extra_spec_name and the
- updated value.
- """
- url = "types/%s/extra_specs/%s" % (str(vol_type_id),
- str(extra_spec_name))
- extra_specs = common.Element("extra_specs", xmlns=common.XMLNS_11)
-
- if extra_spec is not None:
- for key, value in extra_spec.items():
- spec = common.Element('extra_spec')
- spec.add_attr('key', key)
- spec.append(common.Text(value))
- extra_specs.append(spec)
-
- resp, body = self.put(url, str(common.Document(extra_specs)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def is_resource_deleted(self, id):
- try:
- self.get_volume_type(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'volume-type'
-
-
-class VolumeTypesClientXML(BaseVolumeTypesClientXML):
- """
- Client class to send CRUD Volume Type API V1 requests to a Cinder endpoint
- """
diff --git a/tempest/services/volume/xml/availability_zone_client.py b/tempest/services/volume/xml/availability_zone_client.py
deleted file mode 100644
index b956d3f..0000000
--- a/tempest/services/volume/xml/availability_zone_client.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2014 NEC Corporation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils
-from tempest import config
-
-CONF = config.CONF
-
-
-class BaseVolumeAvailabilityZoneClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(BaseVolumeAvailabilityZoneClientXML, self).__init__(
- auth_provider)
- self.service = CONF.volume.catalog_type
-
- def _parse_array(self, node):
- return [xml_utils.xml_to_json(x) for x in node]
-
- def get_availability_zone_list(self):
- resp, body = self.get('os-availability-zone')
- availability_zone = self._parse_array(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, availability_zone
-
-
-class VolumeAvailabilityZoneClientXML(BaseVolumeAvailabilityZoneClientXML):
- """
- Volume V1 availability zone client.
- """
diff --git a/tempest/services/volume/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
deleted file mode 100644
index f2b2e02..0000000
--- a/tempest/services/volume/xml/extensions_client.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-
-CONF = config.CONF
-
-
-class BaseExtensionsClientXML(rest_client.RestClient):
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(BaseExtensionsClientXML, self).__init__(auth_provider)
- self.service = CONF.volume.catalog_type
-
- def _parse_array(self, node):
- array = []
- for child in node:
- array.append(common.xml_to_json(child))
- return array
-
- def list_extensions(self):
- url = 'extensions'
- resp, body = self.get(url)
- body = self._parse_array(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
-
-class ExtensionsClientXML(BaseExtensionsClientXML):
- """
- Volume V1 extensions client.
- """
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
deleted file mode 100644
index fb591b1..0000000
--- a/tempest/services/volume/xml/snapshots_client.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import time
-import urllib
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class BaseSnapshotsClientXML(rest_client.RestClient):
- """Base Client class to send CRUD Volume API requests."""
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(BaseSnapshotsClientXML, self).__init__(auth_provider)
-
- self.service = CONF.volume.catalog_type
- self.build_interval = CONF.volume.build_interval
- self.build_timeout = CONF.volume.build_timeout
- self.create_resp = 200
-
- def list_snapshots(self, params=None):
- """List all snapshot."""
- url = 'snapshots'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- snapshots = []
- for snap in body:
- snapshots.append(common.xml_to_json(snap))
- self.expected_success(200, resp.status)
- return resp, snapshots
-
- def list_snapshots_with_detail(self, params=None):
- """List all the details of snapshot."""
- url = 'snapshots/detail'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- snapshots = []
- for snap in body:
- snapshots.append(common.xml_to_json(snap))
- self.expected_success(200, resp.status)
- return resp, snapshots
-
- def get_snapshot(self, snapshot_id):
- """Returns the details of a single snapshot."""
- url = "snapshots/%s" % str(snapshot_id)
- resp, body = self.get(url)
- body = etree.fromstring(body)
- self.expected_success(200, resp.status)
- return resp, common.xml_to_json(body)
-
- def create_snapshot(self, volume_id, **kwargs):
- """Creates a new snapshot.
- volume_id(Required): id of the volume.
- force: Create a snapshot even if the volume attached (Default=False)
- display_name: Optional snapshot Name.
- display_description: User friendly snapshot description.
- """
- # NOTE(afazekas): it should use the volume namespace
- snapshot = common.Element("snapshot", xmlns=common.XMLNS_11,
- volume_id=volume_id)
- for key, value in kwargs.items():
- snapshot.add_attr(key, value)
- resp, body = self.post('snapshots',
- str(common.Document(snapshot)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(self.create_resp, resp.status)
- return resp, body
-
- def update_snapshot(self, snapshot_id, **kwargs):
- """Updates a snapshot."""
- put_body = common.Element("snapshot", xmlns=common.XMLNS_11, **kwargs)
-
- resp, body = self.put('snapshots/%s' % snapshot_id,
- str(common.Document(put_body)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- # NOTE(afazekas): just for the wait function
- def _get_snapshot_status(self, snapshot_id):
- resp, body = self.get_snapshot(snapshot_id)
- status = body['status']
- # NOTE(afazekas): snapshot can reach an "error"
- # state in a "normal" lifecycle
- if (status == 'error'):
- raise exceptions.SnapshotBuildErrorException(
- snapshot_id=snapshot_id)
-
- return status
-
- # NOTE(afazkas): Wait reinvented again. It is not in the correct layer
- def wait_for_snapshot_status(self, snapshot_id, status):
- """Waits for a Snapshot to reach a given status."""
- start_time = time.time()
- old_value = value = self._get_snapshot_status(snapshot_id)
- while True:
- dtime = time.time() - start_time
- time.sleep(self.build_interval)
- if value != old_value:
- LOG.info('Value transition from "%s" to "%s"'
- 'in %d second(s).', old_value,
- value, dtime)
- if (value == status):
- return value
-
- if dtime > self.build_timeout:
- message = ('Time Limit Exceeded! (%ds)'
- 'while waiting for %s, '
- 'but we got %s.' %
- (self.build_timeout, status, value))
- raise exceptions.TimeoutException(message)
- time.sleep(self.build_interval)
- old_value = value
- value = self._get_snapshot_status(snapshot_id)
-
- def delete_snapshot(self, snapshot_id):
- """Delete Snapshot."""
- resp, body = self.delete("snapshots/%s" % str(snapshot_id))
- self.expected_success(202, resp.status)
-
- def is_resource_deleted(self, id):
- try:
- self.get_snapshot(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'volume-snapshot'
-
- def reset_snapshot_status(self, snapshot_id, status):
- """Reset the specified snapshot's status."""
- post_body = common.Element("os-reset_status", status=status)
- url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def update_snapshot_status(self, snapshot_id, status, progress):
- """Update the specified snapshot's status."""
- post_body = common.Element("os-update_snapshot_status",
- status=status,
- progress=progress
- )
- url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def _metadata_body(self, meta):
- post_body = common.Element('metadata')
- for k, v in meta.items():
- data = common.Element('meta', key=k)
- data.append(common.Text(v))
- post_body.append(data)
- return post_body
-
- def _parse_key_value(self, node):
- """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
- data = {}
- for node in node.getchildren():
- data[node.get('key')] = node.text
- return data
-
- def create_snapshot_metadata(self, snapshot_id, metadata):
- """Create metadata for the snapshot."""
- post_body = self._metadata_body(metadata)
- resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
- str(common.Document(post_body)))
- body = self._parse_key_value(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def get_snapshot_metadata(self, snapshot_id):
- """Get metadata of the snapshot."""
- url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.get(url)
- body = self._parse_key_value(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def update_snapshot_metadata(self, snapshot_id, metadata):
- """Update metadata for the snapshot."""
- put_body = self._metadata_body(metadata)
- url = "snapshots/%s/metadata" % str(snapshot_id)
- resp, body = self.put(url, str(common.Document(put_body)))
- body = self._parse_key_value(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
- """Update metadata item for the snapshot."""
- for k, v in meta_item.items():
- put_body = common.Element('meta', key=k)
- put_body.append(common.Text(v))
- url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
- resp, body = self.put(url, str(common.Document(put_body)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def delete_snapshot_metadata_item(self, snapshot_id, id):
- """Delete metadata item for the snapshot."""
- url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
- resp, body = self.delete(url)
- self.expected_success(200, resp.status)
- return resp, body
-
- def force_delete_snapshot(self, snapshot_id):
- """Force Delete Snapshot."""
- post_body = common.Element("os-force_delete")
- url = 'snapshots/%s/action' % str(snapshot_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
-
-class SnapshotsClientXML(BaseSnapshotsClientXML):
- """Client class to send CRUD Volume V1 API requests."""
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
deleted file mode 100644
index 0fe7e0d..0000000
--- a/tempest/services/volume/xml/volumes_client.py
+++ /dev/null
@@ -1,472 +0,0 @@
-# Copyright 2012 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import time
-import urllib
-from xml.sax import saxutils
-
-from lxml import etree
-
-from tempest.common import rest_client
-from tempest.common import xml_utils as common
-from tempest import config
-from tempest import exceptions
-
-CONF = config.CONF
-
-VOLUME_NS_BASE = 'http://docs.openstack.org/volume/ext/'
-VOLUME_HOST_NS = VOLUME_NS_BASE + 'volume_host_attribute/api/v1'
-VOLUME_MIG_STATUS_NS = VOLUME_NS_BASE + 'volume_mig_status_attribute/api/v1'
-VOLUMES_TENANT_NS = VOLUME_NS_BASE + 'volume_tenant_attribute/api/v1'
-
-
-class BaseVolumesClientXML(rest_client.RestClient):
- """
- Base client class to send CRUD Volume API requests to a Cinder endpoint
- """
- TYPE = "xml"
-
- def __init__(self, auth_provider):
- super(BaseVolumesClientXML, self).__init__(auth_provider)
- self.service = CONF.volume.catalog_type
- self.build_interval = CONF.compute.build_interval
- self.build_timeout = CONF.compute.build_timeout
- self.create_resp = 200
-
- def _translate_attributes_to_json(self, volume):
- volume_host_attr = '{' + VOLUME_HOST_NS + '}host'
- volume_mig_stat_attr = '{' + VOLUME_MIG_STATUS_NS + '}migstat'
- volume_mig_name_attr = '{' + VOLUME_MIG_STATUS_NS + '}name_id'
- volume_tenant_id_attr = '{' + VOLUMES_TENANT_NS + '}tenant_id'
- if volume_host_attr in volume:
- volume['os-vol-host-attr:host'] = volume.pop(volume_host_attr)
- if volume_mig_stat_attr in volume:
- volume['os-vol-mig-status-attr:migstat'] = volume.pop(
- volume_mig_stat_attr)
- if volume_mig_name_attr in volume:
- volume['os-vol-mig-status-attr:name_id'] = volume.pop(
- volume_mig_name_attr)
- if volume_tenant_id_attr in volume:
- volume['os-vol-tenant-attr:tenant_id'] = volume.pop(
- volume_tenant_id_attr)
-
- def _parse_volume(self, body):
- vol = dict((attr, body.get(attr)) for attr in body.keys())
-
- for child in body.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- ns, tag = tag.split("}", 1)
- if tag == 'metadata':
- vol['metadata'] = dict((meta.get('key'),
- meta.text) for meta in
- child.getchildren())
- else:
- vol[tag] = common.xml_to_json(child)
- self._translate_attributes_to_json(vol)
- self._check_if_bootable(vol)
- return vol
-
- def get_attachment_from_volume(self, volume):
- """Return the element 'attachment' from input volumes."""
- return volume['attachments']['attachment']
-
- def _check_if_bootable(self, volume):
- """
- Check if the volume is bootable, also change the value
- of 'bootable' from string to boolean.
- """
-
- # NOTE(jdg): Version 1 of Cinder API uses lc strings
- # We should consider being explicit in this check to
- # avoid introducing bugs like: LP #1227837
-
- if volume['bootable'].lower() == 'true':
- volume['bootable'] = True
- elif volume['bootable'].lower() == 'false':
- volume['bootable'] = False
- else:
- raise ValueError(
- 'bootable flag is supposed to be either True or False,'
- 'it is %s' % volume['bootable'])
- return volume
-
- def list_volumes(self, params=None):
- """List all the volumes created."""
- url = 'volumes'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volumes = []
- if body is not None:
- volumes += [self._parse_volume(vol) for vol in list(body)]
- self.expected_success(200, resp.status)
- return resp, volumes
-
- def list_volumes_with_detail(self, params=None):
- """List all the details of volumes."""
- url = 'volumes/detail'
-
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volumes = []
- if body is not None:
- volumes += [self._parse_volume(vol) for vol in list(body)]
- self.expected_success(200, resp.status)
- return resp, volumes
-
- def get_volume(self, volume_id):
- """Returns the details of a single volume."""
- url = "volumes/%s" % str(volume_id)
- resp, body = self.get(url)
- body = self._parse_volume(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def create_volume(self, size=None, **kwargs):
- """Creates a new Volume.
-
- :param size: Size of volume in GB.
- :param display_name: Optional Volume Name(only for V1).
- :param name: Optional Volume Name(only for V2).
- :param display_name: Optional Volume Name.
- :param metadata: An optional dictionary of values for metadata.
- :param volume_type: Optional Name of volume_type for the volume
- :param snapshot_id: When specified the volume is created from
- this snapshot
- :param imageRef: When specified the volume is created from this
- image
- """
- # for bug #1293885:
- # If no size specified, read volume size from CONF
- if size is None:
- size = CONF.volume.volume_size
- # NOTE(afazekas): it should use a volume namespace
- volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)
-
- if 'metadata' in kwargs:
- _metadata = common.Element('metadata')
- volume.append(_metadata)
- for key, value in kwargs['metadata'].items():
- meta = common.Element('meta')
- meta.add_attr('key', key)
- meta.append(common.Text(value))
- _metadata.append(meta)
- attr_to_add = kwargs.copy()
- del attr_to_add['metadata']
- else:
- attr_to_add = kwargs
-
- for key, value in attr_to_add.items():
- volume.add_attr(key, value)
-
- resp, body = self.post('volumes', str(common.Document(volume)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(self.create_resp, resp.status)
- return resp, body
-
- def update_volume(self, volume_id, **kwargs):
- """Updates the Specified Volume."""
- put_body = common.Element("volume", xmlns=common.XMLNS_11, **kwargs)
-
- resp, body = self.put('volumes/%s' % volume_id,
- str(common.Document(put_body)))
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def delete_volume(self, volume_id):
- """Deletes the Specified Volume."""
- resp, body = self.delete("volumes/%s" % str(volume_id))
- self.expected_success(202, resp.status)
- return resp, body
-
- def wait_for_volume_status(self, volume_id, status):
- """Waits for a Volume to reach a given status."""
- resp, body = self.get_volume(volume_id)
- volume_status = body['status']
- start = int(time.time())
-
- while volume_status != status:
- time.sleep(self.build_interval)
- resp, body = self.get_volume(volume_id)
- volume_status = body['status']
- if volume_status == 'error':
- raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
-
- if int(time.time()) - start >= self.build_timeout:
- message = 'Volume %s failed to reach %s status within '\
- 'the required time (%s s).' % (volume_id,
- status,
- self.build_timeout)
- raise exceptions.TimeoutException(message)
-
- def is_resource_deleted(self, id):
- try:
- self.get_volume(id)
- except exceptions.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'volume'
-
- def attach_volume(self, volume_id, instance_uuid, mountpoint):
- """Attaches a volume to a given instance on a given mountpoint."""
- post_body = common.Element("os-attach",
- instance_uuid=instance_uuid,
- mountpoint=mountpoint
- )
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def detach_volume(self, volume_id):
- """Detaches a volume from an instance."""
- post_body = common.Element("os-detach")
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def upload_volume(self, volume_id, image_name, disk_format):
- """Uploads a volume in Glance."""
- post_body = common.Element("os-volume_upload_image",
- image_name=image_name,
- disk_format=disk_format)
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- volume = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, volume
-
- def extend_volume(self, volume_id, extend_size):
- """Extend a volume."""
- post_body = common.Element("os-extend",
- new_size=extend_size)
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def reset_volume_status(self, volume_id, status):
- """Reset the Specified Volume's Status."""
- post_body = common.Element("os-reset_status",
- status=status
- )
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def volume_begin_detaching(self, volume_id):
- """Volume Begin Detaching."""
- post_body = common.Element("os-begin_detaching")
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def volume_roll_detaching(self, volume_id):
- """Volume Roll Detaching."""
- post_body = common.Element("os-roll_detaching")
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def reserve_volume(self, volume_id):
- """Reserves a volume."""
- post_body = common.Element("os-reserve")
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def unreserve_volume(self, volume_id):
- """Restore a reserved volume ."""
- post_body = common.Element("os-unreserve")
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def create_volume_transfer(self, vol_id, display_name=None):
- """Create a volume transfer."""
- post_body = common.Element("transfer",
- volume_id=vol_id)
- if display_name:
- post_body.add_attr('name', display_name)
- resp, body = self.post('os-volume-transfer',
- str(common.Document(post_body)))
- volume = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, volume
-
- def get_volume_transfer(self, transfer_id):
- """Returns the details of a volume transfer."""
- url = "os-volume-transfer/%s" % str(transfer_id)
- resp, body = self.get(url)
- volume = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, volume
-
- def list_volume_transfers(self, params=None):
- """List all the volume transfers created."""
- url = 'os-volume-transfer'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url)
- body = etree.fromstring(body)
- volumes = []
- if body is not None:
- volumes += [self._parse_volume_transfer(vol) for vol in list(body)]
- self.expected_success(200, resp.status)
- return resp, volumes
-
- def _parse_volume_transfer(self, body):
- vol = dict((attr, body.get(attr)) for attr in body.keys())
- for child in body.getchildren():
- tag = child.tag
- if tag.startswith("{"):
- tag = tag.split("}", 1)
- vol[tag] = common.xml_to_json(child)
- return vol
-
- def delete_volume_transfer(self, transfer_id):
- """Delete a volume transfer."""
- resp, body = self.delete("os-volume-transfer/%s" % str(transfer_id))
- self.expected_success(202, resp.status)
- return resp, body
-
- def accept_volume_transfer(self, transfer_id, transfer_auth_key):
- """Accept a volume transfer."""
- post_body = common.Element("accept", auth_key=transfer_auth_key)
- url = 'os-volume-transfer/%s/accept' % transfer_id
- resp, body = self.post(url, str(common.Document(post_body)))
- volume = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, volume
-
- def update_volume_readonly(self, volume_id, readonly):
- """Update the Specified Volume readonly."""
- post_body = common.Element("os-update_readonly_flag",
- readonly=readonly)
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def force_delete_volume(self, volume_id):
- """Force Delete Volume."""
- post_body = common.Element("os-force_delete")
- url = 'volumes/%s/action' % str(volume_id)
- resp, body = self.post(url, str(common.Document(post_body)))
- if body:
- body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(202, resp.status)
- return resp, body
-
- def _metadata_body(self, meta):
- post_body = common.Element('metadata')
- for k, v in meta.items():
- data = common.Element('meta', key=k)
- # Escape value to allow for special XML chars
- data.append(common.Text(saxutils.escape(v)))
- post_body.append(data)
- return post_body
-
- def _parse_key_value(self, node):
- """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
- data = {}
- for node in node.getchildren():
- data[node.get('key')] = node.text
- return data
-
- def create_volume_metadata(self, volume_id, metadata):
- """Create metadata for the volume."""
- post_body = self._metadata_body(metadata)
- resp, body = self.post('volumes/%s/metadata' % volume_id,
- str(common.Document(post_body)))
- body = self._parse_key_value(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def get_volume_metadata(self, volume_id):
- """Get metadata of the volume."""
- url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.get(url)
- body = self._parse_key_value(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def update_volume_metadata(self, volume_id, metadata):
- """Update metadata for the volume."""
- put_body = self._metadata_body(metadata)
- url = "volumes/%s/metadata" % str(volume_id)
- resp, body = self.put(url, str(common.Document(put_body)))
- body = self._parse_key_value(etree.fromstring(body))
- self.expected_success(200, resp.status)
- return resp, body
-
- def update_volume_metadata_item(self, volume_id, id, meta_item):
- """Update metadata item for the volume."""
- for k, v in meta_item.items():
- put_body = common.Element('meta', key=k)
- put_body.append(common.Text(v))
- url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- resp, body = self.put(url, str(common.Document(put_body)))
- self.expected_success(200, resp.status)
- body = common.xml_to_json(etree.fromstring(body))
- return resp, body
-
- def delete_volume_metadata_item(self, volume_id, id):
- """Delete metadata item for the volume."""
- url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
- resp, body = self.delete(url)
- self.expected_success(200, resp.status)
- return resp, body
-
-
-class VolumesClientXML(BaseVolumesClientXML):
- """
- Client class to send CRUD Volume API V1 requests to a Cinder endpoint
- """
diff --git a/tempest/test.py b/tempest/test.py
index 14cf3bb..6deb42b 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -224,6 +224,23 @@
class BaseTestCase(testtools.testcase.WithAttributes,
testtools.TestCase):
+ """The test base class defines Tempest framework for class level fixtures.
+ `setUpClass` and `tearDownClass` are defined here and cannot be overwritten
+ by subclasses (enforced via hacking rule T105).
+
+ Set-up is split in a series of steps (setup stages), which can be
+ overwritten by test classes. Set-up stages are:
+ - skip_checks
+ - setup_credentials
+ - setup_clients
+ - resource_setup
+
+ Tear-down is also split in a series of steps (teardown stages), which are
+ stacked for execution only if the corresponding setup stage had been
+ reached during the setup phase. Tear-down stages are:
+ - clear_isolated_creds (defined in the base test class)
+ - resource_cleanup
+ """
setUpClassCalled = False
_service = None
@@ -242,31 +259,28 @@
if hasattr(super(BaseTestCase, cls), 'setUpClass'):
super(BaseTestCase, cls).setUpClass()
cls.setUpClassCalled = True
- # No test resource is allocated until here
+ # Stack of (name, callable) to be invoked in reverse order at teardown
+ cls.teardowns = []
+ # All the configuration checks that may generate a skip
+ cls.skip_checks()
try:
- # TODO(andreaf) Split-up resource_setup in stages:
- # skip checks, pre-hook, credentials, clients, resources, post-hook
+ # Allocation of all required credentials and client managers
+ cls.teardowns.append(('credentials', cls.clear_isolated_creds))
+ cls.setup_credentials()
+ # Shortcuts to clients
+ cls.setup_clients()
+ # Additional class-wide test resources
+ cls.teardowns.append(('resources', cls.resource_cleanup))
cls.resource_setup()
except Exception:
etype, value, trace = sys.exc_info()
- LOG.info("%s in resource setup. Invoking tearDownClass." % etype)
- # Catch any exception in tearDown so we can re-raise the original
- # exception at the end
+ LOG.info("%s in %s.setUpClass. Invoking tearDownClass." % (
+ cls.__name__, etype))
+ cls.tearDownClass()
try:
- cls.tearDownClass()
- except Exception as te:
- tetype, _, _ = sys.exc_info()
- # TODO(gmann): Till we split-up resource_setup &
- # resource_cleanup in more structural way, log
- # AttributeError as info instead of exception.
- if tetype is AttributeError:
- LOG.info("tearDownClass failed: %s" % te)
- else:
- LOG.exception("tearDownClass failed: %s" % te)
- try:
- raise etype(value), None, trace
+ raise etype, value, trace
finally:
- del trace # for avoiding circular refs
+ del trace # to avoid circular refs
@classmethod
def tearDownClass(cls):
@@ -274,21 +288,78 @@
# It should never be overridden by descendants
if hasattr(super(BaseTestCase, cls), 'tearDownClass'):
super(BaseTestCase, cls).tearDownClass()
- try:
- cls.resource_cleanup()
- finally:
- cls.clear_isolated_creds()
+ # Save any existing exception, we always want to re-raise the original
+ # exception only
+ etype, value, trace = sys.exc_info()
+ # If there was no exception during setup we shall re-raise the first
+ # exception in teardown
+ re_raise = (etype is None)
+ while cls.teardowns:
+ name, teardown = cls.teardowns.pop()
+ # Catch any exception in tearDown so we can re-raise the original
+ # exception at the end
+ try:
+ teardown()
+ except Exception as te:
+ sys_exec_info = sys.exc_info()
+ tetype = sys_exec_info[0]
+ # TODO(andreaf): Till we have the ability to cleanup only
+ # resources that were successfully setup in resource_cleanup,
+ # log AttributeError as info instead of exception.
+ if tetype is AttributeError and name == 'resources':
+ LOG.info("tearDownClass of %s failed: %s" % (name, te))
+ else:
+ LOG.exception("teardown of %s failed: %s" % (name, te))
+ if not etype:
+ etype, value, trace = sys_exec_info
+ # If exceptions were raised during teardown, an not before, re-raise
+ # the first one
+ if re_raise and etype is not None:
+ try:
+ raise etype, value, trace
+ finally:
+ del trace # to avoid circular refs
@classmethod
def resource_setup(cls):
- """Class level setup steps for test cases.
- Recommended order: skip checks, credentials, clients, resources.
+ """Class level resource setup for test cases.
"""
pass
@classmethod
def resource_cleanup(cls):
- """Class level resource cleanup for test cases. """
+ """Class level resource cleanup for test cases.
+ Resource cleanup must be able to handle the case of partially setup
+ resources, in case a failure during `resource_setup` should happen.
+ """
+ pass
+
+ @classmethod
+ def skip_checks(cls):
+ """Class level skip checks. Subclasses verify in here all
+ conditions that might prevent the execution of the entire test class.
+ Checks implemented here may not make use API calls, and should rely on
+ configuration alone.
+ In general skip checks that require an API call are discouraged.
+ If one is really needed it may be implemented either in the
+ resource_setup or at test level.
+ """
+ pass
+
+ @classmethod
+ def setup_credentials(cls):
+ """Allocate credentials and the client managers from them."""
+ # TODO(andreaf) There is a fair amount of code that could me moved from
+ # base / test classes in here. Ideally tests should be able to only
+ # specify a list of (additional) credentials the need to use.
+ pass
+
+ @classmethod
+ def setup_clients(cls):
+ """Create links to the clients into the test object."""
+ # TODO(andreaf) There is a fair amount of code that could me moved from
+ # base / test classes in here. Ideally tests should be able to only
+ # specify which client is `client` and nothing else.
pass
def setUp(self):
@@ -414,12 +485,8 @@
else:
standard_tests, module, loader = args
for test in testtools.iterate_tests(standard_tests):
- schema_file = getattr(test, '_schema_file', None)
schema = getattr(test, '_schema', None)
- if schema_file is not None:
- setattr(test, 'scenarios',
- NegativeAutoTest.generate_scenario(schema_file))
- elif schema is not None:
+ if schema is not None:
setattr(test, 'scenarios',
NegativeAutoTest.generate_scenario(schema))
return testscenarios.load_tests_apply_scenarios(*args)
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index 6679c79..ba69a5d 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -261,9 +261,9 @@
def test_verify_extensions_cinder(self):
def fake_list_extensions():
- return (None, {'extensions': [{'name': 'fake1'},
- {'name': 'fake2'},
- {'name': 'not_fake'}]})
+ return (None, {'extensions': [{'alias': 'fake1'},
+ {'alias': 'fake2'},
+ {'alias': 'not_fake'}]})
fake_os = mock.MagicMock()
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
@@ -283,9 +283,9 @@
def test_verify_extensions_cinder_all(self):
def fake_list_extensions():
- return (None, {'extensions': [{'name': 'fake1'},
- {'name': 'fake2'},
- {'name': 'not_fake'}]})
+ return (None, {'extensions': [{'alias': 'fake1'},
+ {'alias': 'fake2'},
+ {'alias': 'not_fake'}]})
fake_os = mock.MagicMock()
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
@@ -300,9 +300,8 @@
def test_verify_extensions_nova(self):
def fake_list_extensions():
- return (None, {'extensions': [{'alias': 'fake1'},
- {'alias': 'fake2'},
- {'alias': 'not_fake'}]})
+ return (None, [{'alias': 'fake1'}, {'alias': 'fake2'},
+ {'alias': 'not_fake'}])
fake_os = mock.MagicMock()
fake_os.extensions_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
@@ -337,45 +336,6 @@
self.assertEqual(sorted(['fake1', 'fake2', 'not_fake']),
sorted(results['nova']['extensions']))
- def test_verify_extensions_nova_v3(self):
- def fake_list_extensions():
- return (None, {'extensions': [{'alias': 'fake1'},
- {'alias': 'fake2'},
- {'alias': 'not_fake'}]})
- fake_os = mock.MagicMock()
- fake_os.extensions_v3_client.list_extensions = fake_list_extensions
- self.useFixture(mockpatch.PatchObject(
- verify_tempest_config, 'get_enabled_extensions',
- return_value=(['fake1', 'fake2', 'fake3'])))
- results = verify_tempest_config.verify_extensions(fake_os,
- 'nova_v3', {})
- self.assertIn('nova_v3', results)
- self.assertIn('fake1', results['nova_v3'])
- self.assertTrue(results['nova_v3']['fake1'])
- self.assertIn('fake2', results['nova_v3'])
- self.assertTrue(results['nova_v3']['fake2'])
- self.assertIn('fake3', results['nova_v3'])
- self.assertFalse(results['nova_v3']['fake3'])
- self.assertIn('not_fake', results['nova_v3'])
- self.assertFalse(results['nova_v3']['not_fake'])
-
- def test_verify_extensions_nova_v3_all(self):
- def fake_list_extensions():
- return (None, {'extensions': [{'alias': 'fake1'},
- {'alias': 'fake2'},
- {'alias': 'not_fake'}]})
- fake_os = mock.MagicMock()
- fake_os.extensions_v3_client.list_extensions = fake_list_extensions
- self.useFixture(mockpatch.PatchObject(
- verify_tempest_config, 'get_enabled_extensions',
- return_value=(['all'])))
- results = verify_tempest_config.verify_extensions(fake_os,
- 'nova_v3', {})
- self.assertIn('nova_v3', results)
- self.assertIn('extensions', results['nova_v3'])
- self.assertEqual(sorted(['fake1', 'fake2', 'not_fake']),
- sorted(results['nova_v3']['extensions']))
-
def test_verify_extensions_swift(self):
def fake_list_extensions():
return (None, {'fake1': 'metadata',
diff --git a/tempest/tests/common/test_debug.py b/tempest/tests/common/test_debug.py
deleted file mode 100644
index 8a880f2..0000000
--- a/tempest/tests/common/test_debug.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# Copyright 2014 NEC Corporation.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import mock
-
-from tempest.common import debug
-from tempest import config
-from tempest.openstack.common.fixture import mockpatch
-from tempest import test
-from tempest.tests import base
-from tempest.tests import fake_config
-
-
-class TestDebug(base.TestCase):
-
- def setUp(self):
- super(TestDebug, self).setUp()
- self.useFixture(fake_config.ConfigFixture())
- self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
-
- common_pre = 'tempest.common.commands'
- self.ip_addr_raw_mock = self.patch(common_pre + '.ip_addr_raw')
- self.ip_route_raw_mock = self.patch(common_pre + '.ip_route_raw')
- self.iptables_raw_mock = self.patch(common_pre + '.iptables_raw')
- self.ip_ns_list_mock = self.patch(common_pre + '.ip_ns_list')
- self.ip_ns_addr_mock = self.patch(common_pre + '.ip_ns_addr')
- self.ip_ns_route_mock = self.patch(common_pre + '.ip_ns_route')
- self.iptables_ns_mock = self.patch(common_pre + '.iptables_ns')
- self.ovs_db_dump_mock = self.patch(common_pre + '.ovs_db_dump')
-
- self.log_mock = self.patch('tempest.common.debug.LOG')
-
- def test_log_ip_ns_debug_disabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', False))
- debug.log_ip_ns()
- self.assertFalse(self.ip_addr_raw_mock.called)
- self.assertFalse(self.log_mock.info.called)
-
- def test_log_ip_ns_debug_enabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', True))
-
- self.ip_ns_list_mock.return_value = [1, 2]
-
- debug.log_ip_ns()
- self.ip_addr_raw_mock.assert_called_with()
- self.assertTrue(self.log_mock.info.called)
- self.ip_route_raw_mock.assert_called_with()
- self.assertEqual(len(debug.TABLES), self.iptables_raw_mock.call_count)
- for table in debug.TABLES:
- self.assertIn(mock.call(table),
- self.iptables_raw_mock.call_args_list)
-
- self.ip_ns_list_mock.assert_called_with()
- self.assertEqual(len(self.ip_ns_list_mock.return_value),
- self.ip_ns_addr_mock.call_count)
- self.assertEqual(len(self.ip_ns_list_mock.return_value),
- self.ip_ns_route_mock.call_count)
- for ns in self.ip_ns_list_mock.return_value:
- self.assertIn(mock.call(ns),
- self.ip_ns_addr_mock.call_args_list)
- self.assertIn(mock.call(ns),
- self.ip_ns_route_mock.call_args_list)
-
- self.assertEqual(len(debug.TABLES) *
- len(self.ip_ns_list_mock.return_value),
- self.iptables_ns_mock.call_count)
- for ns in self.ip_ns_list_mock.return_value:
- for table in debug.TABLES:
- self.assertIn(mock.call(ns, table),
- self.iptables_ns_mock.call_args_list)
-
- def test_log_ovs_db_debug_disabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', False))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', False))
- debug.log_ovs_db()
- self.assertFalse(self.ovs_db_dump_mock.called)
-
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', True))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', False))
- debug.log_ovs_db()
- self.assertFalse(self.ovs_db_dump_mock.called)
-
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', False))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', True))
- debug.log_ovs_db()
- self.assertFalse(self.ovs_db_dump_mock.called)
-
- def test_log_ovs_db_debug_enabled(self):
- self.useFixture(mockpatch.PatchObject(test.CONF.debug,
- 'enable', True))
- self.useFixture(mockpatch.PatchObject(test.CONF.service_available,
- 'neutron', True))
- debug.log_ovs_db()
- self.ovs_db_dump_mock.assert_called_with()
-
- def test_log_net_debug(self):
- self.log_ip_ns_mock = self.patch('tempest.common.debug.log_ip_ns')
- self.log_ovs_db_mock = self.patch('tempest.common.debug.log_ovs_db')
-
- debug.log_net_debug()
- self.log_ip_ns_mock.assert_called_with()
- self.log_ovs_db_mock.assert_called_with()
diff --git a/tempest/tests/test_commands.py b/tempest/tests/test_commands.py
deleted file mode 100644
index 2379741..0000000
--- a/tempest/tests/test_commands.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import subprocess
-
-import mock
-
-from tempest.common import commands
-from tempest.tests import base
-
-
-class TestCommands(base.TestCase):
-
- def setUp(self):
- super(TestCommands, self).setUp()
- self.subprocess_args = {'stdout': subprocess.PIPE,
- 'stderr': subprocess.STDOUT}
-
- @mock.patch('subprocess.Popen')
- def test_ip_addr_raw(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'a']
- commands.ip_addr_raw()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_route_raw(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'r']
- commands.ip_route_raw()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_raw(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'list']
- commands.ip_ns_raw()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_iptables_raw(self, mock):
- table = 'filter'
- expected = ['/usr/bin/sudo', '-n', 'iptables', '--line-numbers',
- '-L', '-nv', '-t',
- '%s' % table]
- commands.iptables_raw(table)
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_list(self, mock):
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'list']
- commands.ip_ns_list()
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_addr(self, mock):
- ns_list = commands.ip_ns_list()
- for ns in ns_list:
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'exec', ns,
- 'ip', 'a']
- commands.ip_ns_addr(ns)
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_ip_ns_route(self, mock):
- ns_list = commands.ip_ns_list()
- for ns in ns_list:
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'exec', ns,
- 'ip', 'r']
- commands.ip_ns_route(ns)
- mock.assert_called_once_with(expected, **self.subprocess_args)
-
- @mock.patch('subprocess.Popen')
- def test_iptables_ns(self, mock):
- table = 'filter'
- ns_list = commands.ip_ns_list()
- for ns in ns_list:
- expected = ['/usr/bin/sudo', '-n', 'ip', 'netns', 'exec', ns,
- 'iptables', '-v', '-S', '-t', table]
- commands.iptables_ns(ns, table)
- mock.assert_called_once_with(expected, **self.subprocess_args)
diff --git a/tempest/tests/test_compute_xml_common.py b/tempest/tests/test_compute_xml_common.py
deleted file mode 100644
index 1561931..0000000
--- a/tempest/tests/test_compute_xml_common.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-from lxml import etree
-
-from tempest.common import xml_utils as common
-from tempest.tests import base
-
-
-class TestXMLParser(base.TestCase):
-
- def test_xml_to_json_parser_bool_value(self):
- node = etree.fromstring('''<health_monitor
- xmlns="http://openstack.org/quantum/api/v2.0"
- xmlns:quantum="http://openstack.org/quantum/api/v2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <admin_state_up quantum:type="bool">False</admin_state_up>
- <fake_state_up quantum:type="bool">True</fake_state_up>
- </health_monitor>''')
- body = common.xml_to_json(node)
- self.assertEqual(body['admin_state_up'], False)
- self.assertEqual(body['fake_state_up'], True)
-
- def test_xml_to_json_parser_int_value(self):
- node = etree.fromstring('''<health_monitor
- xmlns="http://openstack.org/quantum/api/v2.0"
- xmlns:quantum="http://openstack.org/quantum/api/v2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <delay quantum:type="long">4</delay>
- <max_retries quantum:type="int">3</max_retries>
- </health_monitor>''')
- body = common.xml_to_json(node)
- self.assertEqual(body['delay'], 4L)
- self.assertEqual(body['max_retries'], 3)
-
- def test_xml_to_json_parser_text_value(self):
- node = etree.fromstring('''<health_monitor
- xmlns="http://openstack.org/quantum/api/v2.0"
- xmlns:quantum="http://openstack.org/quantum/api/v2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <status>ACTIVE</status>
- </health_monitor>''')
- body = common.xml_to_json(node)
- self.assertEqual(body['status'], 'ACTIVE')
-
- def test_xml_to_json_parser_list_as_value(self):
- node = etree.fromstring('''<health_monitor
- xmlns="http://openstack.org/quantum/api/v2.0"
- xmlns:quantum="http://openstack.org/quantum/api/v2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <elements>
- <element>first_element</element>
- <element>second_element</element>
- </elements>
- </health_monitor>''')
- body = common.xml_to_json(node, 'elements')
- self.assertEqual(body['elements'], ['first_element', 'second_element'])
diff --git a/tempest/tests/test_hacking.py b/tempest/tests/test_hacking.py
index 6857461..fd01887 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -69,13 +69,18 @@
self.assertFalse(checks.no_setup_teardown_class_for_tests(
" def tearDownClass(cls):", './tempest/test.py'))
- def test_import_no_clients_in_api(self):
+ def test_import_no_clients_in_api_and_scenario_tests(self):
for client in checks.PYTHON_CLIENTS:
string = "import " + client + "client"
- self.assertTrue(checks.import_no_clients_in_api(
- string, './tempest/api/fake_test.py'))
- self.assertFalse(checks.import_no_clients_in_api(
- string, './tempest/scenario/fake_test.py'))
+ self.assertTrue(
+ checks.import_no_clients_in_api_and_scenario_tests(
+ string, './tempest/api/fake_test.py'))
+ self.assertTrue(
+ checks.import_no_clients_in_api_and_scenario_tests(
+ string, './tempest/scenario/fake_test.py'))
+ self.assertFalse(
+ checks.import_no_clients_in_api_and_scenario_tests(
+ string, './tempest/test.py'))
def test_scenario_tests_need_service_tags(self):
self.assertFalse(checks.scenario_tests_need_service_tags(
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
index 5f55ca2..5b2ce7a 100644
--- a/tempest/tests/test_rest_client.py
+++ b/tempest/tests/test_rest_client.py
@@ -18,7 +18,6 @@
from oslotest import mockpatch
from tempest.common import rest_client
-from tempest.common import xml_utils as xml
from tempest import config
from tempest import exceptions
from tempest.tests import base
@@ -236,29 +235,8 @@
)
-class TestRestClientHeadersXML(TestRestClientHeadersJSON):
- TYPE = "xml"
-
- # These two tests are needed in one exemplar
- def test_send_json_accept_xml(self):
- resp, __ = self.rest_client.get(self.url,
- self.rest_client.get_headers("xml",
- "json"))
- resp = dict((k.lower(), v) for k, v in resp.iteritems())
- self.assertEqual("application/json", resp["content-type"])
- self.assertEqual("application/xml", resp["accept"])
-
- def test_send_xml_accept_json(self):
- resp, __ = self.rest_client.get(self.url,
- self.rest_client.get_headers("json",
- "xml"))
- resp = dict((k.lower(), v) for k, v in resp.iteritems())
- self.assertEqual("application/json", resp["accept"])
- self.assertEqual("application/xml", resp["content-type"])
-
-
-class TestRestClientParseRespXML(BaseRestClientTestClass):
- TYPE = "xml"
+class TestRestClientParseRespJSON(BaseRestClientTestClass):
+ TYPE = "json"
keys = ["fake_key1", "fake_key2"]
values = ["fake_value1", "fake_value2"]
@@ -274,39 +252,10 @@
def setUp(self):
self.fake_http = fake_http.fake_httplib2()
- super(TestRestClientParseRespXML, self).setUp()
+ super(TestRestClientParseRespJSON, self).setUp()
self.rest_client.TYPE = self.TYPE
def test_parse_resp_body_item(self):
- body_item = xml.Element("item", **self.item_expected)
- body = self.rest_client._parse_resp(str(xml.Document(body_item)))
- self.assertEqual(self.item_expected, body)
-
- def test_parse_resp_body_list(self):
- self.rest_client.list_tags = ["fake_list", ]
- body_list = xml.Element(self.rest_client.list_tags[0])
- for i in range(2):
- body_list.append(xml.Element("fake_item",
- **self.list_expected["body_list"][i]))
- body = self.rest_client._parse_resp(str(xml.Document(body_list)))
- self.assertEqual(self.list_expected["body_list"], body)
-
- def test_parse_resp_body_dict(self):
- self.rest_client.dict_tags = ["fake_dict", ]
- body_dict = xml.Element(self.rest_client.dict_tags[0])
-
- for i in range(2):
- body_dict.append(xml.Element("fake_item", xml.Text(self.values[i]),
- key=self.keys[i]))
-
- body = self.rest_client._parse_resp(str(xml.Document(body_dict)))
- self.assertEqual(self.dict_expected["body_dict"], body)
-
-
-class TestRestClientParseRespJSON(TestRestClientParseRespXML):
- TYPE = "json"
-
- def test_parse_resp_body_item(self):
body = self.rest_client._parse_resp(json.dumps(self.item_expected))
self.assertEqual(self.item_expected, body)
@@ -402,7 +351,7 @@
**self.set_data("500"))
def test_response_501_with_text(self):
- self.assertRaises(exceptions.ServerFault,
+ self.assertRaises(exceptions.NotImplemented,
self.rest_client._error_checker,
**self.set_data("501"))
@@ -414,7 +363,7 @@
def test_response_501_with_dict(self):
r_body = '{"resp_body": {"err": "fake_resp_body"}}'
- self.assertRaises(exceptions.ServerFault,
+ self.assertRaises(exceptions.NotImplemented,
self.rest_client._error_checker,
**self.set_data("501", r_body=r_body))
@@ -426,10 +375,6 @@
**self.set_data("402"))
-class TestRestClientErrorCheckerXML(TestRestClientErrorCheckerJSON):
- c_type = "application/xml"
-
-
class TestRestClientErrorCheckerTEXT(TestRestClientErrorCheckerJSON):
c_type = "text/plain"
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/test_tenant_isolation.py
index 27c45c2..df9719b 100644
--- a/tempest/tests/test_tenant_isolation.py
+++ b/tempest/tests/test_tenant_isolation.py
@@ -21,9 +21,7 @@
from tempest import exceptions
from tempest.openstack.common.fixture import mockpatch
from tempest.services.identity.json import identity_client as json_iden_client
-from tempest.services.identity.xml import identity_client as xml_iden_client
from tempest.services.network.json import network_client as json_network_client
-from tempest.services.network.xml import network_client as xml_network_client
from tempest.tests import base
from tempest.tests import fake_config
from tempest.tests import fake_http
@@ -49,14 +47,6 @@
self.assertTrue(isinstance(iso_creds.network_admin_client,
json_network_client.NetworkClientJSON))
- def test_tempest_client_xml(self):
- iso_creds = isolated_creds.IsolatedCreds('test class', interface='xml')
- self.assertEqual(iso_creds.interface, 'xml')
- self.assertTrue(isinstance(iso_creds.identity_admin_client,
- xml_iden_client.IdentityClientXML))
- self.assertTrue(isinstance(iso_creds.network_admin_client,
- xml_network_client.NetworkClientXML))
-
def _mock_user_create(self, id, name):
user_fix = self.useFixture(mockpatch.PatchObject(
json_iden_client.IdentityClientJSON,
diff --git a/tempest/tests/test_xml_utils.py b/tempest/tests/test_xml_utils.py
deleted file mode 100644
index 53e31c4..0000000
--- a/tempest/tests/test_xml_utils.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright 2014 Hewlett-Packard Development Company, L.P.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common import xml_utils
-from tempest.tests import base
-
-
-class TestDocumentXML(base.TestCase):
- def test_xml_document_ordering_version_encoding(self):
- expected = '<?xml version="1.0" encoding="UTF-8"?>'
- xml_out = str(xml_utils.Document())
- self.assertEqual(expected, xml_out.strip())
-
- xml_out = str(xml_utils.Document(encoding='UTF-8', version='1.0'))
- self.assertEqual(expected, xml_out.strip())
-
- xml_out = str(xml_utils.Document(version='1.0', encoding='UTF-8'))
- self.assertEqual(expected, xml_out.strip())
-
- def test_xml_document_additonal_attrs(self):
- expected = '<?xml version="1.0" encoding="UTF-8" foo="bar"?>'
- xml_out = str(xml_utils.Document(foo='bar'))
- self.assertEqual(expected, xml_out.strip())
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index f3f11fd..00b17d9 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -306,8 +306,7 @@
volume.detach()
- self.assertVolumeStatusWait(_volume_state, "available")
- wait.re_search_wait(_volume_state, "available")
+ self.assertVolumeStatusWait(volume, "available")
wait.state_wait(_part_state, 'DECREASE')
diff --git a/tox.ini b/tox.ini
index f75e868..edfee15 100644
--- a/tox.ini
+++ b/tox.ini
@@ -17,7 +17,9 @@
whitelist_externals = *
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
-commands = bash tools/pretty_tox.sh '{posargs}'
+commands =
+ find . -type f -name "*.pyc" -delete
+ bash tools/pretty_tox.sh '{posargs}'
[testenv:genconfig]
commands = oslo-config-generator --config-file tools/config/config-generator.tempest.conf
@@ -33,6 +35,7 @@
OS_TEST_TIMEOUT=1200
deps = {[tempestenv]deps}
commands =
+ find . -type f -name "*.pyc" -delete
bash tools/pretty_tox.sh '{posargs}'
[testenv:full]
@@ -42,6 +45,7 @@
# The regex below is used to select which tests to run and exclude the slow tag:
# See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
commands =
+ find . -type f -name "*.pyc" -delete
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
[testenv:full-serial]
@@ -51,6 +55,7 @@
# The regex below is used to select which tests to run and exclude the slow tag:
# See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
commands =
+ find . -type f -name "*.pyc" -delete
bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
[testenv:heat-slow]
@@ -60,6 +65,7 @@
deps = {[tempestenv]deps}
# The regex below is used to select heat api/scenario tests tagged as slow.
commands =
+ find . -type f -name "*.pyc" -delete
bash tools/pretty_tox.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}'
[testenv:large-ops]
@@ -67,6 +73,7 @@
setenv = {[tempestenv]setenv}
deps = {[tempestenv]deps}
commands =
+ find . -type f -name "*.pyc" -delete
python setup.py testr --slowest --testr-args='tempest.scenario.test_large_ops {posargs}'
[testenv:smoke]
@@ -74,6 +81,7 @@
setenv = {[tempestenv]setenv}
deps = {[tempestenv]deps}
commands =
+ find . -type f -name "*.pyc" -delete
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
[testenv:smoke-serial]
@@ -84,6 +92,7 @@
# https://bugs.launchpad.net/tempest/+bug/1216076 so the neutron smoke
# job would fail if we moved it to parallel.
commands =
+ find . -type f -name "*.pyc" -delete
bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
[testenv:stress]