Merge "Remove nova v2 API comments"
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 3553ce7..4d05ff7 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -223,5 +223,5 @@
server = self.create_test_server(name=server_name,
availability_zone=az_name,
wait_until='ACTIVE')
- body = admin_servers_client.show_server(server['id'])
+ body = admin_servers_client.show_server(server['id'])['server']
self.assertEqual(self.host, body[self._host_key])
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index 669585c..9cda0cd 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -38,7 +38,7 @@
def resource_setup(cls):
super(FixedIPsTestJson, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
- server = cls.servers_client.show_server(server['id'])
+ server = cls.servers_client.show_server(server['id'])['server']
for ip_set in server['addresses']:
for ip in server['addresses'][ip_set]:
if ip['OS-EXT-IPS:type'] == 'fixed':
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index e67936c..8d745c9 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -40,7 +40,7 @@
def resource_setup(cls):
super(FixedIPsNegativeTestJson, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
- server = cls.servers_client.show_server(server['id'])
+ server = cls.servers_client.show_server(server['id'])['server']
for ip_set in server['addresses']:
for ip in server['addresses'][ip_set]:
if ip['OS-EXT-IPS:type'] == 'fixed':
diff --git a/tempest/api/compute/admin/test_live_migration.py b/tempest/api/compute/admin/test_live_migration.py
index 410f7b7..9d49124 100644
--- a/tempest/api/compute/admin/test_live_migration.py
+++ b/tempest/api/compute/admin/test_live_migration.py
@@ -49,7 +49,7 @@
]
def _get_server_details(self, server_id):
- body = self.admin_servers_client.show_server(server_id)
+ body = self.admin_servers_client.show_server(server_id)['server']
return body
def _get_host_for_server(self, server_id):
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 0528fa5..1849f83 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -66,7 +66,7 @@
# Reset server's state to 'active'
self.client.reset_state(self.s1_id, state='active')
# Verify server's state
- server = self.client.show_server(self.s1_id)
+ server = self.client.show_server(self.s1_id)['server']
self.assertEqual(server['status'], 'ACTIVE')
servers = body['servers']
# Verify error server in list result
@@ -112,11 +112,11 @@
network = self.get_tenant_network()
network_kwargs = fixed_network.set_networks_kwarg(network)
test_server = self.client.create_server(name, image_id, flavor,
- **network_kwargs)
+ **network_kwargs)['server']
self.addCleanup(self.client.delete_server, test_server['id'])
waiters.wait_for_server_status(self.client,
test_server['id'], 'ACTIVE')
- server = self.client.show_server(test_server['id'])
+ server = self.client.show_server(test_server['id'])['server']
self.assertEqual(server['status'], 'ACTIVE')
hostname = server[self._host_key]
params = {'host': hostname}
@@ -135,14 +135,14 @@
self.client.reset_state(self.s1_id)
# Verify server's state
- server = self.client.show_server(self.s1_id)
+ server = self.client.show_server(self.s1_id)['server']
self.assertEqual(server['status'], 'ERROR')
# Reset server's state to 'active'
self.client.reset_state(self.s1_id, state='active')
# Verify server's state
- server = self.client.show_server(self.s1_id)
+ server = self.client.show_server(self.s1_id)['server']
self.assertEqual(server['status'], 'ACTIVE')
@decorators.skip_because(bug="1240043")
@@ -164,7 +164,7 @@
# resetting vm state require admin privilege
self.client.reset_state(self.s1_id, state='error')
rebuilt_server = self.non_admin_client.rebuild_server(
- self.s1_id, self.image_ref_alt)
+ self.s1_id, self.image_ref_alt)['server']
self.addCleanup(waiters.wait_for_server_status, self.non_admin_client,
self.s1_id, 'ACTIVE')
self.addCleanup(self.non_admin_client.rebuild_server, self.s1_id,
@@ -179,7 +179,8 @@
rebuilt_server['id'], 'ACTIVE',
raise_on_error=False)
# Verify the server properties after rebuilding
- server = self.non_admin_client.show_server(rebuilt_server['id'])
+ server = (self.non_admin_client.show_server(rebuilt_server['id'])
+ ['server'])
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 9ec5711..02a183f 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -73,6 +73,7 @@
cls.networks_client = cls.os.networks_client
cls.limits_client = cls.os.limits_client
cls.volumes_extensions_client = cls.os.volumes_extensions_client
+ cls.snapshots_extensions_client = cls.os.snapshots_extensions_client
cls.interfaces_client = cls.os.interfaces_client
cls.fixed_ips_client = cls.os.fixed_ips_client
cls.availability_zone_client = cls.os.availability_zone_client
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index dcdb562..530e422 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -189,7 +189,7 @@
self.client.add_fixed_ip(server['id'], networkId=network_id)
# Remove the fixed IP from server.
server_detail = self.os.servers_client.show_server(
- server['id'])
+ server['id'])['server']
# Get the Fixed IP from server.
fixed_ip = None
for ip_set in server_detail['addresses']:
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 529b596..419bfd7 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -64,7 +64,8 @@
personality=personality,
disk_config=disk_config)
cls.password = cls.server_initial['adminPass']
- cls.server = cls.client.show_server(cls.server_initial['id'])
+ cls.server = (cls.client.show_server(cls.server_initial['id'])
+ ['server'])
def _create_net_subnet_ret_net_from_cidr(self, cidr):
name_net = data_utils.rand_name(self.__class__.__name__)
@@ -185,7 +186,8 @@
self.addCleanup(cleanup_server)
- addresses = self.client.list_addresses(server_multi_nics['id'])
+ addresses = (self.client.list_addresses(server_multi_nics['id'])
+ ['addresses'])
# We can't predict the ip addresses assigned to the server on networks.
# Sometimes the assigned addresses are ['19.80.0.2', '19.86.0.2'], at
@@ -226,7 +228,8 @@
self.addCleanup(cleanup_server)
- addresses = self.client.list_addresses(server_multi_nics['id'])
+ addresses = (self.client.list_addresses(server_multi_nics['id'])
+ ['addresses'])
addr = [addresses[net1['network']['name']][0]['addr'],
addresses[net2['network']['name']][0]['addr'],
@@ -315,7 +318,7 @@
# Get partition number of server without extra specs.
server_no_eph_disk = self.client.show_server(
- server_no_eph_disk['id'])
+ server_no_eph_disk['id'])['server']
linux_client = remote_client.RemoteClient(
self.get_server_ip(server_no_eph_disk),
self.ssh_user,
@@ -333,7 +336,7 @@
flavor=flavor_with_eph_disk_id)
server_with_eph_disk = self.client.show_server(
- server_with_eph_disk['id'])
+ server_with_eph_disk['id'])['server']
linux_client = remote_client.RemoteClient(
self.get_server_ip(server_with_eph_disk),
self.ssh_user,
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 5d461ab..6796bb5 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -150,7 +150,7 @@
server = self.create_test_server(wait_until='ACTIVE')
self.admin_client.reset_state(server['id'], state='error')
# Verify server's state
- server = self.non_admin_client.show_server(server['id'])
+ server = self.non_admin_client.show_server(server['id'])['server']
self.assertEqual(server['status'], 'ERROR')
self.non_admin_client.delete_server(server['id'])
waiters.wait_for_server_termination(self.servers_client,
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 929b300..617cdd5 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -44,12 +44,12 @@
cls.server_id = server['id']
def _update_server_with_disk_config(self, disk_config):
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
if disk_config != server['OS-DCF:diskConfig']:
- server = self.client.update_server(self.server_id,
- disk_config=disk_config)
+ server = self.client.update_server(
+ self.server_id, disk_config=disk_config)['server']
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual(disk_config, server['OS-DCF:diskConfig'])
@test.idempotent_id('bef56b09-2e8c-4883-a370-4950812f430e')
@@ -59,13 +59,13 @@
server = self.client.rebuild_server(self.server_id,
self.image_ref_alt,
- disk_config='MANUAL')
+ disk_config='MANUAL')['server']
# Wait for the server to become active
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the specified attributes are set correctly
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
@test.idempotent_id('9c9fae77-4feb-402f-8450-bf1c8b609713')
@@ -75,17 +75,17 @@
server = self.client.rebuild_server(self.server_id,
self.image_ref_alt,
- disk_config='AUTO')
+ disk_config='AUTO')['server']
# Wait for the server to become active
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the specified attributes are set correctly
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
def _get_alternative_flavor(self):
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
if server['flavor']['id'] == self.flavor_ref:
return self.flavor_ref_alt
@@ -108,7 +108,7 @@
self.client.confirm_resize_server(self.server_id)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
@test.idempotent_id('693d16f3-556c-489a-8bac-3d0ca2490bad')
@@ -127,7 +127,7 @@
self.client.confirm_resize_server(self.server_id)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
@test.idempotent_id('5ef18867-358d-4de9-b3c9-94d4ba35742f')
@@ -137,9 +137,9 @@
# Update the disk_config attribute to manual
server = self.client.update_server(self.server_id,
- disk_config='MANUAL')
+ disk_config='MANUAL')['server']
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the disk_config attribute is set correctly
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 4ac1a49..97d47fd 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -38,7 +38,8 @@
self.client.reboot_server(self.server_id, 'HARD')
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- body = self.client.list_instance_actions(self.server_id)
+ body = (self.client.list_instance_actions(self.server_id)
+ ['instanceActions'])
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']))
@@ -46,7 +47,7 @@
@test.idempotent_id('aacc71ca-1d70-4aa5-bbf6-0ff71470e43c')
def test_get_instance_action(self):
# Get the action details of the provided server
- body = self.client.get_instance_action(self.server_id,
- self.request_id)
+ body = self.client.get_instance_action(
+ self.server_id, self.request_id)['instanceAction']
self.assertEqual(self.server_id, body['instance_uuid'])
self.assertEqual('create', body['action'])
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 16e4392..3acff98 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -274,7 +274,7 @@
if not self.fixed_network_name:
msg = 'fixed_network_name needs to be configured to run this test'
raise self.skipException(msg)
- self.s1 = self.client.show_server(self.s1['id'])
+ self.s1 = self.client.show_server(self.s1['id'])['server']
for addr_spec in self.s1['addresses'][self.fixed_network_name]:
ip = addr_spec['addr']
if addr_spec['version'] == 4:
@@ -298,7 +298,7 @@
if not self.fixed_network_name:
msg = 'fixed_network_name needs to be configured to run this test'
raise self.skipException(msg)
- self.s1 = self.client.show_server(self.s1['id'])
+ self.s1 = self.client.show_server(self.s1['id'])['server']
addr_spec = self.s1['addresses'][self.fixed_network_name][0]
ip = addr_spec['addr'][0:-3]
if addr_spec['version'] == 4:
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 47629c0..c394e44 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -52,8 +52,8 @@
self.__class__.server_id = server['id']
except Exception:
# Rebuild server if something happened to it during a test
- self.__class__.server_id = self.rebuild_server(self.server_id,
- validatable=True)
+ self.__class__.server_id = self.rebuild_server(
+ self.server_id, validatable=True)['server']
def tearDown(self):
self.server_check_teardown()
@@ -87,7 +87,7 @@
if CONF.validation.run_validation:
# Verify that the user can authenticate with the new password
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
linux_client = remote_client.RemoteClient(
self.get_server_ip(server),
self.ssh_user,
@@ -97,7 +97,7 @@
def _test_reboot_server(self, reboot_type):
if CONF.validation.run_validation:
# Get the time the server was last rebooted,
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
linux_client = remote_client.RemoteClient(
self.get_server_ip(server),
self.ssh_user,
@@ -132,7 +132,8 @@
self._test_reboot_server('SOFT')
def _rebuild_server_and_check(self, image_ref):
- rebuilt_server = self.client.rebuild_server(self.server_id, image_ref)
+ rebuilt_server = (self.client.rebuild_server(self.server_id, image_ref)
+ ['server'])
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
msg = ('Server was not rebuilt to the original image. '
'The original image: {0}. The current image: {1}'
@@ -148,12 +149,13 @@
personality = [{'path': 'rebuild.txt',
'contents': base64.b64encode(file_contents)}]
password = 'rebuildPassw0rd'
- rebuilt_server = self.client.rebuild_server(self.server_id,
- self.image_ref_alt,
- name=new_name,
- metadata=meta,
- personality=personality,
- adminPass=password)
+ rebuilt_server = self.client.rebuild_server(
+ self.server_id,
+ self.image_ref_alt,
+ name=new_name,
+ metadata=meta,
+ personality=personality,
+ adminPass=password)['server']
# If the server was rebuilt on a different image, restore it to the
# original image once the test ends
@@ -169,7 +171,7 @@
# Verify the server properties after the rebuild completes
waiters.wait_for_server_status(self.client,
rebuilt_server['id'], 'ACTIVE')
- server = self.client.show_server(rebuilt_server['id'])
+ server = self.client.show_server(rebuilt_server['id'])['server']
rebuilt_image_id = server['image']['id']
self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
self.assertEqual(new_name, server['name'])
@@ -187,13 +189,14 @@
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
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
old_image = server['image']['id']
new_image = (self.image_ref_alt
if old_image == self.image_ref else self.image_ref)
self.client.stop_server(self.server_id)
waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')
- rebuilt_server = self.client.rebuild_server(self.server_id, new_image)
+ rebuilt_server = (self.client.rebuild_server(self.server_id, new_image)
+ ['server'])
# If the server was rebuilt on a different image, restore it to the
# original image once the test ends
if self.image_ref_alt != self.image_ref:
@@ -208,7 +211,7 @@
# Verify the server properties after the rebuild completes
waiters.wait_for_server_status(self.client,
rebuilt_server['id'], 'SHUTOFF')
- server = self.client.show_server(rebuilt_server['id'])
+ server = self.client.show_server(rebuilt_server['id'])['server']
rebuilt_image_id = server['image']['id']
self.assertEqual(new_image, rebuilt_image_id)
@@ -232,7 +235,7 @@
waiters.wait_for_server_status(self.client, self.server_id,
expected_status)
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
self.assertEqual(self.flavor_ref_alt, server['flavor']['id'])
if stop:
@@ -269,7 +272,7 @@
self.client.revert_resize_server(self.server_id)
waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
self.assertEqual(self.flavor_ref, server['flavor']['id'])
@test.idempotent_id('b963d4f1-94b3-4c40-9e97-7b583f46e470')
@@ -358,7 +361,7 @@
def _get_output(self):
output = self.client.get_console_output(
- self.server_id, 10).data
+ self.server_id, 10)['output']
self.assertTrue(output, "Console output was empty.")
lines = len(output.split('\n'))
self.assertEqual(lines, 10)
@@ -387,7 +390,7 @@
def _check_full_length_console_log():
output = self.client.get_console_output(server['id'],
- None).data
+ None)['output']
self.assertTrue(output, "Console output was empty.")
lines = len(output.split('\n'))
@@ -453,7 +456,7 @@
waiters.wait_for_server_status(self.client, self.server_id,
'SHELVED_OFFLOADED')
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
image_name = server['name'] + '-shelved'
params = {'name': image_name}
images = self.images_client.list_images(**params)['images']
@@ -475,7 +478,7 @@
# Lock the server,try server stop(exceptions throw),unlock it and retry
self.client.lock_server(self.server_id)
self.addCleanup(self.client.unlock_server, self.server_id)
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
self.assertEqual(server['status'], 'ACTIVE')
# Locked server is not allowed to be stopped by non-admin user
self.assertRaises(lib_exc.Conflict,
@@ -501,7 +504,7 @@
console_types = ['novnc', 'xvpvnc']
for console_type in console_types:
body = self.client.get_vnc_console(self.server_id,
- console_type)
+ console_type)['console']
self.assertEqual(console_type, body['type'])
self.assertNotEqual('', body['url'])
self._validate_url(body['url'])
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index a17f581..864f38f 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -45,7 +45,7 @@
# All public and private addresses for
# a server should be returned
- addresses = self.client.list_addresses(self.server['id'])
+ addresses = self.client.list_addresses(self.server['id'])['addresses']
# We do not know the exact network configuration, but an instance
# should at least have a single public or private address
@@ -63,7 +63,7 @@
# Providing a network type should filter
# the addresses return by that type
- addresses = self.client.list_addresses(self.server['id'])
+ addresses = self.client.list_addresses(self.server['id'])['addresses']
# Once again we don't know the environment's exact network config,
# but the response for each individual network should be the same
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index 234633b..f9e8b4f 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -34,12 +34,13 @@
def setUp(self):
super(ServerMetadataTestJSON, self).setUp()
meta = {'key1': 'value1', 'key2': 'value2'}
- self.client.set_server_metadata(self.server_id, meta)
+ self.client.set_server_metadata(self.server_id, meta)['metadata']
@test.idempotent_id('479da087-92b3-4dcf-aeb3-fd293b2d14ce')
def test_list_server_metadata(self):
# All metadata key/value pairs for a server should be returned
- resp_metadata = self.client.list_server_metadata(self.server_id)
+ resp_metadata = (self.client.list_server_metadata(self.server_id)
+ ['metadata'])
# Verify the expected metadata items are in the list
expected = {'key1': 'value1', 'key2': 'value2'}
@@ -50,11 +51,13 @@
# 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'}
- self.client.set_server_metadata(self.server_id, req_metadata)
+ self.client.set_server_metadata(self.server_id,
+ req_metadata)['metadata']
# Verify the expected values are correct, and that the
# previous values have been removed
- resp_metadata = self.client.list_server_metadata(self.server_id)
+ resp_metadata = (self.client.list_server_metadata(self.server_id)
+ ['metadata'])
self.assertEqual(resp_metadata, req_metadata)
@test.idempotent_id('344d981e-0c33-4997-8a5d-6c1d803e4134')
@@ -65,7 +68,8 @@
self.client.update_server_metadata(self.server_id, meta)
# Verify the values have been updated to the proper values
- resp_metadata = self.client.list_server_metadata(self.server_id)
+ resp_metadata = (self.client.list_server_metadata(self.server_id)
+ ['metadata'])
expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
self.assertEqual(expected, resp_metadata)
@@ -75,14 +79,16 @@
# passed
meta = {}
self.client.update_server_metadata(self.server_id, meta)
- resp_metadata = self.client.list_server_metadata(self.server_id)
+ resp_metadata = (self.client.list_server_metadata(self.server_id)
+ ['metadata'])
expected = {'key1': 'value1', 'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
@test.idempotent_id('3043c57d-7e0e-49a6-9a96-ad569c265e6a')
def test_get_server_metadata_item(self):
# The value for a specific metadata key should be returned
- meta = self.client.get_server_metadata_item(self.server_id, 'key2')
+ meta = self.client.get_server_metadata_item(self.server_id,
+ 'key2')['meta']
self.assertEqual('value2', meta['key2'])
@test.idempotent_id('58c02d4f-5c67-40be-8744-d3fa5982eb1c')
@@ -93,7 +99,8 @@
self.client.set_server_metadata_item(self.server_id, 'nova', meta)
# Verify the meta item's value has been updated
- resp_metadata = self.client.list_server_metadata(self.server_id)
+ resp_metadata = (self.client.list_server_metadata(self.server_id)
+ ['metadata'])
expected = {'key1': 'value1', 'key2': 'value2', 'nova': 'alt'}
self.assertEqual(expected, resp_metadata)
@@ -103,6 +110,7 @@
self.client.delete_server_metadata_item(self.server_id, 'key1')
# Verify the metadata item has been removed
- resp_metadata = self.client.list_server_metadata(self.server_id)
+ resp_metadata = (self.client.list_server_metadata(self.server_id)
+ ['metadata'])
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 8cfb670..d2fb652 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -52,9 +52,9 @@
wait_until='ACTIVE')
id2 = server['id']
self.assertNotEqual(id1, id2, "Did not create a new server")
- server = self.client.show_server(id1)
+ server = self.client.show_server(id1)['server']
name1 = server['name']
- server = self.client.show_server(id2)
+ server = self.client.show_server(id2)['server']
name2 = server['name']
self.assertEqual(name1, name2)
@@ -68,7 +68,7 @@
self.keypairs_client.list_keypairs()
server = self.create_test_server(key_name=key_name)
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual(key_name, server['key_name'])
def _update_server_name(self, server_id, status):
@@ -80,7 +80,7 @@
waiters.wait_for_server_status(self.client, server_id, status)
# Verify the name of the server has changed
- server = self.client.show_server(server_id)
+ server = self.client.show_server(server_id)['server']
self.assertEqual(new_name, server['name'])
return server
@@ -112,7 +112,7 @@
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
# Verify the access addresses have been updated
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual('1.1.1.1', server['accessIPv4'])
self.assertEqual('::babe:202:202', server['accessIPv6'])
@@ -121,5 +121,5 @@
# Create a server without an IPv4 address(only IPv6 address).
server = self.create_test_server(accessIPv6='2001:2001::3')
waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE')
- server = self.client.show_server(server['id'])
+ server = self.client.show_server(server['id'])['server']
self.assertEqual('2001:2001::3', server['accessIPv6'])
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index d5b60da..dbaa6a1 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -476,7 +476,7 @@
self.server_id,
'SHELVED')
- server = self.client.show_server(self.server_id)
+ server = self.client.show_server(self.server_id)['server']
image_name = server['name'] + '-shelved'
params = {'name': image_name}
images = self.images_client.list_images(**params)['images']
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index b5a24c7..e60874f 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -64,7 +64,7 @@
def resource_setup(cls):
super(AuthorizationTestJSON, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
- cls.server = cls.client.show_server(server['id'])
+ cls.server = cls.client.show_server(server['id'])['server']
name = data_utils.rand_name('image')
body = cls.glance_client.create_image(name=name,
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index ba34039..ab4ddf7 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -70,8 +70,8 @@
adminPass=admin_pass)
# Record addresses so that we can ssh later
- self.server['addresses'] = (
- self.servers_client.list_addresses(self.server['id']))
+ self.server['addresses'] = self.servers_client.list_addresses(
+ self.server['id'])['addresses']
# Create a volume and wait for it to become ready
self.volume = self.volumes_client.create_volume(
@@ -84,7 +84,7 @@
self.attachment = self.servers_client.attach_volume(
self.server['id'],
volumeId=self.volume['id'],
- device='/dev/%s' % self.device)
+ device='/dev/%s' % self.device)['volumeAttachment']
self.volumes_client.wait_for_volume_status(self.volume['id'], 'in-use')
self.addCleanup(self._detach, self.server['id'], self.volume['id'])
@@ -139,14 +139,14 @@
self._create_and_attach()
# List Volume attachment of the server
body = self.servers_client.list_volume_attachments(
- self.server['id'])
+ self.server['id'])['volumeAttachments']
self.assertEqual(1, len(body))
self.assertIn(self.attachment, body)
# Get Volume attachment of the server
body = self.servers_client.get_volume_attachment(
self.server['id'],
- self.attachment['id'])
+ self.attachment['id'])['volumeAttachment']
self.assertEqual(self.server['id'], body['serverId'])
self.assertEqual(self.volume['id'], body['volumeId'])
self.assertEqual(self.attachment['id'], body['id'])
diff --git a/tempest/api/compute/volumes/test_volume_snapshots.py b/tempest/api/compute/volumes/test_volume_snapshots.py
new file mode 100644
index 0000000..a00c0ba
--- /dev/null
+++ b/tempest/api/compute/volumes/test_volume_snapshots.py
@@ -0,0 +1,73 @@
+# Copyright 2015 Fujitsu(fnst) 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.common import waiters
+from tempest import config
+from tempest import test
+
+
+CONF = config.CONF
+
+
+class VolumesSnapshotsTestJSON(base.BaseV2ComputeTest):
+
+ @classmethod
+ def skip_checks(cls):
+ super(VolumesSnapshotsTestJSON, cls).skip_checks()
+ if not CONF.service_available.cinder:
+ skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ @classmethod
+ def setup_clients(cls):
+ super(VolumesSnapshotsTestJSON, cls).setup_clients()
+ cls.volumes_client = cls.volumes_extensions_client
+ cls.snapshots_client = cls.snapshots_extensions_client
+
+ @test.idempotent_id('cd4ec87d-7825-450d-8040-6e2068f2da8f')
+ def test_volume_snapshot_create_get_list_delete(self):
+ v_name = data_utils.rand_name('Volume')
+ volume = self.volumes_client.create_volume(
+ size=CONF.volume.volume_size,
+ display_name=v_name)['volume']
+ self.addCleanup(self.delete_volume, volume['id'])
+ waiters.wait_for_volume_status(self.volumes_client, volume['id'],
+ 'available')
+ s_name = data_utils.rand_name('Snapshot')
+ # Create snapshot
+ snapshot = self.snapshots_client.create_snapshot(
+ volume['id'],
+ display_name=s_name)['snapshot']
+
+ def delete_snapshot(snapshot_id):
+ waiters.wait_for_snapshot_status(self.snapshots_client,
+ snapshot_id,
+ 'available')
+ # Delete snapshot
+ self.snapshots_client.delete_snapshot(snapshot_id)
+ self.snapshots_client.wait_for_resource_deletion(snapshot_id)
+
+ self.addCleanup(delete_snapshot, snapshot['id'])
+ self.assertEqual(volume['id'], snapshot['volumeId'])
+ # Get snapshot
+ fetched_snapshot = self.snapshots_client.show_snapshot(
+ snapshot['id'])['snapshot']
+ self.assertEqual(s_name, fetched_snapshot['displayName'])
+ self.assertEqual(volume['id'], fetched_snapshot['volumeId'])
+ # Fetch all snapshots
+ snapshots = self.snapshots_client.list_snapshots()['snapshots']
+ self.assertIn(snapshot['id'], map(lambda x: x['id'], snapshots))
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index c97ddd7..62c1e05 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -28,7 +28,8 @@
@test.idempotent_id('c94b825e-0132-4686-8049-8a4a2bc09525')
def test_get_db_flavor(self):
# The expected flavor details should be returned
- flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
+ flavor = (self.client.get_db_flavor_details(self.db_flavor_ref)
+ ['flavor'])
self.assertEqual(self.db_flavor_ref, str(flavor['id']))
self.assertIn('ram', flavor)
self.assertIn('links', flavor)
@@ -37,9 +38,10 @@
@test.attr(type='smoke')
@test.idempotent_id('685025d6-0cec-4673-8a8d-995cb8e0d3bb')
def test_list_db_flavors(self):
- flavor = self.client.get_db_flavor_details(self.db_flavor_ref)
+ flavor = (self.client.get_db_flavor_details(self.db_flavor_ref)
+ ['flavor'])
# List of all flavors should contain the expected flavor
- flavors = self.client.list_db_flavors()
+ flavors = self.client.list_db_flavors()['flavors']
self.assertIn(flavor, flavors)
def _check_values(self, names, db_flavor, os_flavor, in_db=True):
@@ -57,7 +59,7 @@
@test.idempotent_id('afb2667f-4ec2-4925-bcb7-313fdcffb80d')
@test.services('compute')
def test_compare_db_flavors_with_os(self):
- db_flavors = self.client.list_db_flavors()
+ db_flavors = self.client.list_db_flavors()['flavors']
os_flavors = (self.os_flavors_client.list_flavors(detail=True)
['flavors'])
self.assertEqual(len(os_flavors), len(db_flavors),
@@ -65,7 +67,7 @@
(os_flavors, db_flavors))
for os_flavor in os_flavors:
db_flavor =\
- self.client.get_db_flavor_details(os_flavor['id'])
+ self.client.get_db_flavor_details(os_flavor['id'])['flavor']
self._check_values(['id', 'name', 'ram'], db_flavor, os_flavor)
self._check_values(['disk', 'vcpus', 'swap'], db_flavor, os_flavor,
in_db=False)
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index cb6d1db..8f1f0d6 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -87,7 +87,7 @@
server_id = body['physical_resource_id']
LOG.debug('Console output for %s', server_id)
output = cls.servers_client.get_console_output(
- server_id, None).data
+ server_id, None)['output']
LOG.debug(output)
raise e
@@ -184,7 +184,7 @@
def test_created_server(self):
"""Verifies created sever."""
server_id = self.test_resources.get('Server')['physical_resource_id']
- server = self.servers_client.show_server(server_id)
+ server = self.servers_client.show_server(server_id)['server']
self.assertEqual(self.keypair_name, server['key_name'])
self.assertEqual('ACTIVE', server['status'])
network = server['addresses'][self.neutron_basic_template['resources'][
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 784f1b6..aa6bfdf 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -15,10 +15,18 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
+ @classmethod
+ def skip_checks(cls):
+ super(SnapshotsActionsV2Test, cls).skip_checks()
+ if not CONF.volume_feature_enabled.snapshot:
+ raise cls.skipException("Cinder snapshot feature disabled")
@classmethod
def setup_clients(cls):
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index ce6ba90..e50ca95 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -16,10 +16,18 @@
from testtools import matchers
from tempest.api.volume import base
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class SnapshotV2MetadataTestJSON(base.BaseVolumeTest):
+ @classmethod
+ def skip_checks(cls):
+ super(SnapshotV2MetadataTestJSON, cls).skip_checks()
+ if not CONF.volume_feature_enabled.snapshot:
+ raise cls.skipException("Cinder snapshot feature disabled")
@classmethod
def setup_clients(cls):
diff --git a/tempest/api_schema/response/compute/v2_1/snapshots.py b/tempest/api_schema/response/compute/v2_1/snapshots.py
new file mode 100644
index 0000000..01a524b
--- /dev/null
+++ b/tempest/api_schema/response/compute/v2_1/snapshots.py
@@ -0,0 +1,61 @@
+# Copyright 2015 Fujitsu(fnst) 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.
+
+common_snapshot_info = {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string'},
+ 'volumeId': {'type': 'string'},
+ 'status': {'type': 'string'},
+ 'size': {'type': 'integer'},
+ 'createdAt': {'type': 'string'},
+ 'displayName': {'type': ['string', 'null']},
+ 'displayDescription': {'type': ['string', 'null']}
+ },
+ 'additionalProperties': False,
+ 'required': ['id', 'volumeId', 'status', 'size',
+ 'createdAt', 'displayName', 'displayDescription']
+}
+
+create_get_snapshot = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'snapshot': common_snapshot_info
+ },
+ 'additionalProperties': False,
+ 'required': ['snapshot']
+ }
+}
+
+list_snapshots = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'snapshots': {
+ 'type': 'array',
+ 'items': common_snapshot_info
+ }
+ },
+ 'additionalProperties': False,
+ 'required': ['snapshots']
+ }
+}
+
+delete_snapshot = {
+ 'status_code': [202]
+}
diff --git a/tempest/clients.py b/tempest/clients.py
index c0d4585..28efd9d 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -16,8 +16,8 @@
import copy
from oslo_log import log as logging
-from tempest_lib.services.identity.v2.token_client import TokenClientJSON
-from tempest_lib.services.identity.v3.token_client import V3TokenClientJSON
+from tempest_lib.services.identity.v2.token_client import TokenClient
+from tempest_lib.services.identity.v3.token_client import V3TokenClient
from tempest.common import cred_provider
from tempest.common import negative_rest_client
@@ -73,6 +73,8 @@
ServerGroupsClient
from tempest.services.compute.json.servers_client import ServersClient
from tempest.services.compute.json.services_client import ServicesClient
+from tempest.services.compute.json.snapshots_extensions_client import \
+ SnapshotsExtensionsClient
from tempest.services.compute.json.tenant_networks_client import \
TenantNetworksClient
from tempest.services.compute.json.tenant_usages_client import \
@@ -325,6 +327,8 @@
self.auth_provider, **params_volume)
self.compute_versions_client = VersionsClient(self.auth_provider,
**params_volume)
+ self.snapshots_extensions_client = SnapshotsExtensionsClient(
+ self.auth_provider, **params_volume)
def _set_database_clients(self):
self.database_flavors_client = DatabaseFlavorsClient(
@@ -377,14 +381,14 @@
# API version is marked as enabled
if CONF.identity_feature_enabled.api_v2:
if CONF.identity.uri:
- self.token_client = TokenClientJSON(
+ self.token_client = TokenClient(
CONF.identity.uri, **self.default_params)
else:
msg = 'Identity v2 API enabled, but no identity.uri set'
raise exceptions.InvalidConfiguration(msg)
if CONF.identity_feature_enabled.api_v3:
if CONF.identity.uri_v3:
- self.token_v3_client = V3TokenClientJSON(
+ self.token_v3_client = V3TokenClient(
CONF.identity.uri_v3, **self.default_params)
else:
msg = 'Identity v3 API enabled, but no identity.uri_v3 set'
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 6973c87..5d06b90 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -457,7 +457,7 @@
found,
"Couldn't find expected server %s" % server['name'])
- found = client.servers.show_server(found['id'])
+ found = client.servers.show_server(found['id'])['server']
# validate neutron is enabled and ironic disabled:
if (CONF.service_available.neutron and
not CONF.baremetal.driver_enabled):
@@ -869,7 +869,7 @@
kwargs['networks'] = [{'uuid': get_net_id(network)}
for network in server['networks']]
body = client.servers.create_server(
- server['name'], image_id, flavor_id, **kwargs)
+ server['name'], image_id, flavor_id, **kwargs)['server']
server_id = body['id']
client.servers.wait_for_server_status(server_id, 'ACTIVE')
# create security group(s) after server spawning
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 5c4d8af..a76696e 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -18,6 +18,7 @@
from tempest_lib.common.utils import data_utils
from tempest.common import fixed_network
+from tempest.common import service_client
from tempest.common import waiters
from tempest import config
@@ -88,12 +89,15 @@
**kwargs)
# handle the case of multiple servers
- servers = [body]
+ servers = []
if 'min_count' in kwargs or 'max_count' in kwargs:
# Get servers created which name match with name param.
body_servers = clients.servers_client.list_servers()
servers = \
[s for s in body_servers['servers'] if s['name'].startswith(name)]
+ else:
+ body = service_client.ResponseBody(body.response, body['server'])
+ servers = [body]
# The name of the method to associate a floating IP to as server is too
# long for PEP8 compliance so:
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 248513e..867d3f6 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -34,7 +34,7 @@
# NOTE(afazekas): UNKNOWN status possible on ERROR
# or in a very early stage.
- body = client.show_server(server_id)
+ body = client.show_server(server_id)['server']
old_status = server_status = body['status']
old_task_state = task_state = _get_task_state(body)
start_time = int(time.time())
@@ -61,7 +61,7 @@
return
time.sleep(client.build_interval)
- body = client.show_server(server_id)
+ body = client.show_server(server_id)['server']
server_status = body['status']
task_state = _get_task_state(body)
if (server_status != old_status) or (task_state != old_task_state):
@@ -102,7 +102,7 @@
start_time = int(time.time())
while True:
try:
- body = client.show_server(server_id)
+ body = client.show_server(server_id)['server']
except lib_exc.NotFound:
return
@@ -183,6 +183,27 @@
raise exceptions.TimeoutException(message)
+def wait_for_snapshot_status(client, snapshot_id, status):
+ """Waits for a Snapshot to reach a given status."""
+ body = client.show_snapshot(snapshot_id)['snapshot']
+ snapshot_status = body['status']
+ start = int(time.time())
+
+ while snapshot_status != status:
+ time.sleep(client.build_interval)
+ body = client.show_snapshot(snapshot_id)['snapshot']
+ snapshot_status = body['status']
+ if snapshot_status == 'error':
+ raise exceptions.SnapshotBuildErrorException(
+ snapshot_id=snapshot_id)
+ if int(time.time()) - start >= client.build_timeout:
+ message = ('Snapshot %s failed to reach %s status (current %s) '
+ 'within the required time (%s s).' %
+ (snapshot_id, status, snapshot_status,
+ client.build_timeout))
+ raise exceptions.TimeoutException(message)
+
+
def wait_for_bm_node_status(client, node_id, attr, status):
"""Waits for a baremetal node attribute to reach given status.
diff --git a/tempest/config.py b/tempest/config.py
index 295b74d..ccfcd9c 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -1143,7 +1143,7 @@
title='Baremetal provisioning service options',
help='When enabling baremetal tests, Nova '
'must be configured to use the Ironic '
- 'driver. The following paremeters for the '
+ 'driver. The following parameters for the '
'[compute] section must be disabled: '
'console_output, interface_attach, '
'live_migration, pause, rescue, resize '
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 15482ab..b3d60f6 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -64,7 +64,7 @@
class InvalidIdentityVersion(TempestException):
- message = "Invalid version %(identity_version) of the identity service"
+ message = "Invalid version %(identity_version)s of the identity service"
class TimeoutException(TempestException):
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 4f113d3..d70021c 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -179,7 +179,7 @@
LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
name, image, flavor)
server = self.servers_client.create_server(name, image, flavor,
- **create_kwargs)
+ **create_kwargs)['server']
if wait_on_delete:
self.addCleanup(waiters.wait_for_server_termination,
self.servers_client,
@@ -197,7 +197,7 @@
# The instance retrieved on creation is missing network
# details, necessitating retrieval after it becomes active to
# ensure correct details.
- server = self.servers_client.show_server(server['id'])
+ server = self.servers_client.show_server(server['id'])['server']
self.assertEqual(server['name'], name)
return server
@@ -400,7 +400,7 @@
servers = servers['servers']
for server in servers:
console_output = self.servers_client.get_console_output(
- server['id'], length=None).data
+ server['id'], length=None)['output']
LOG.debug('Console output for %s\nbody=\n%s',
server['id'], console_output)
@@ -450,7 +450,7 @@
def nova_volume_attach(self):
volume = self.servers_client.attach_volume(
self.server['id'], volumeId=self.volume['id'], device='/dev/%s'
- % CONF.compute.volume_device_name)
+ % CONF.compute.volume_device_name)['volumeAttachment']
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
@@ -1278,7 +1278,8 @@
waiters.wait_for_server_status(self.servers_client,
self.instance['id'], 'ACTIVE')
self.node = self.get_node(instance_id=self.instance['id'])
- self.instance = self.servers_client.show_server(self.instance['id'])
+ self.instance = (self.servers_client.show_server(self.instance['id'])
+ ['server'])
def terminate_instance(self):
self.servers_client.delete_server(self.instance['id'])
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 402bc68..eac8311 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -62,7 +62,8 @@
self.assertIn(self.server['id'], [x['id'] for x in servers])
def nova_show(self):
- got_server = self.servers_client.show_server(self.server['id'])
+ got_server = (self.servers_client.show_server(self.server['id'])
+ ['server'])
excluded_keys = ['OS-EXT-AZ:availability_zone']
# Exclude these keys because of LP:#1486475
excluded_keys.extend(['OS-EXT-STS:power_state', 'updated'])
@@ -98,7 +99,8 @@
self.server['id'], secgroup['name'])
def wait_for_secgroup_add():
- body = self.servers_client.show_server(self.server['id'])
+ body = (self.servers_client.show_server(self.server['id'])
+ ['server'])
return {'name': secgroup['name']} in body['security_groups']
if not test.call_until_true(wait_for_secgroup_add,
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index 99eecae..c83dbb1 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -81,19 +81,22 @@
self.servers_client.suspend_server(instance_id)
waiters.wait_for_server_status(self.servers_client, instance_id,
'SUSPENDED')
- fetched_instance = self.servers_client.show_server(instance_id)
+ fetched_instance = (self.servers_client.show_server(instance_id)
+ ['server'])
LOG.debug("Resuming instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.resume_server(instance_id)
waiters.wait_for_server_status(self.servers_client, instance_id,
'ACTIVE')
- fetched_instance = self.servers_client.show_server(instance_id)
+ fetched_instance = (self.servers_client.show_server(instance_id)
+ ['server'])
LOG.debug("Suspending instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.suspend_server(instance_id)
waiters.wait_for_server_status(self.servers_client, instance_id,
'SUSPENDED')
- fetched_instance = self.servers_client.show_server(instance_id)
+ fetched_instance = (self.servers_client.show_server(instance_id)
+ ['server'])
LOG.debug("Resuming instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.resume_server(instance_id)
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index a7bdba3..5f1e7fe 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -106,7 +106,7 @@
def _attach_volume(self, server, volume):
attached_volume = self.servers_client.attach_volume(
server['id'], volumeId=volume['id'], device='/dev/%s'
- % CONF.compute.volume_device_name)
+ % CONF.compute.volume_device_name)['volumeAttachment']
self.assertEqual(volume['id'], attached_volume['id'])
self._wait_for_volume_status(attached_volume, 'in-use')
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 5603fed..a36603f 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -95,7 +95,7 @@
else:
create_schema = schema.create_server
self.validate_response(create_schema, resp, body)
- return service_client.ResponseBody(resp, body['server'])
+ return service_client.ResponseBody(resp, body)
def update_server(self, server_id, **kwargs):
"""Updates the properties of an existing server.
@@ -110,14 +110,14 @@
resp, body = self.put("servers/%s" % server_id, post_body)
body = json.loads(body)
self.validate_response(schema.update_server, resp, body)
- return service_client.ResponseBody(resp, body['server'])
+ return service_client.ResponseBody(resp, body)
def show_server(self, server_id):
"""Returns the details of an existing server."""
resp, body = self.get("servers/%s" % server_id)
body = json.loads(body)
self.validate_response(schema.get_server, resp, body)
- return service_client.ResponseBody(resp, body['server'])
+ return service_client.ResponseBody(resp, body)
def delete_server(self, server_id):
"""Deletes the given server."""
@@ -147,7 +147,7 @@
resp, body = self.get("servers/%s/ips" % server_id)
body = json.loads(body)
self.validate_response(schema.list_addresses, resp, body)
- return service_client.ResponseBody(resp, body['addresses'])
+ return service_client.ResponseBody(resp, body)
def list_addresses_by_network(self, server_id, network_id):
"""Lists all addresses of a specific network type for a server."""
@@ -157,30 +157,27 @@
self.validate_response(schema.list_addresses_by_network, resp, body)
return service_client.ResponseBody(resp, body)
- def action(self, server_id, action_name, response_key,
+ def action(self, server_id, action_name,
schema=schema.server_actions_common_schema,
- response_class=service_client.ResponseBody, **kwargs):
+ **kwargs):
post_body = json.dumps({action_name: kwargs})
resp, body = self.post('servers/%s/action' % server_id,
post_body)
- if response_key is not None:
+ if body:
body = json.loads(body)
- self.validate_response(schema, resp, body)
- body = body[response_key]
- else:
- self.validate_response(schema, resp, body)
- return response_class(resp, body)
+ self.validate_response(schema, resp, body)
+ return service_client.ResponseBody(resp, body)
def create_backup(self, server_id, backup_type, rotation, name):
"""Backup a server instance."""
- return self.action(server_id, "createBackup", None,
+ return self.action(server_id, "createBackup",
backup_type=backup_type,
rotation=rotation,
name=name)
def change_password(self, server_id, adminPass):
"""Changes the root password for the server."""
- return self.action(server_id, 'changePassword', None,
+ return self.action(server_id, 'changePassword',
adminPass=adminPass)
def get_password(self, server_id):
@@ -204,7 +201,7 @@
def reboot_server(self, server_id, reboot_type):
"""Reboots a server."""
- return self.action(server_id, 'reboot', None, type=reboot_type)
+ return self.action(server_id, 'reboot', type=reboot_type)
def rebuild_server(self, server_id, image_ref, **kwargs):
"""Rebuilds a server with a new image.
@@ -219,7 +216,7 @@
rebuild_schema = schema.rebuild_server_with_admin_pass
else:
rebuild_schema = schema.rebuild_server
- return self.action(server_id, 'rebuild', 'server',
+ return self.action(server_id, 'rebuild',
rebuild_schema, **kwargs)
def resize_server(self, server_id, flavor_ref, **kwargs):
@@ -231,23 +228,23 @@
kwargs['flavorRef'] = flavor_ref
if 'disk_config' in kwargs:
kwargs['OS-DCF:diskConfig'] = kwargs.pop('disk_config')
- return self.action(server_id, 'resize', None, **kwargs)
+ return self.action(server_id, 'resize', **kwargs)
def confirm_resize_server(self, server_id, **kwargs):
"""Confirms the flavor change for a server."""
return self.action(server_id, 'confirmResize',
- None, schema.server_actions_confirm_resize,
+ schema.server_actions_confirm_resize,
**kwargs)
def revert_resize_server(self, server_id, **kwargs):
"""Reverts a server back to its original flavor."""
- return self.action(server_id, 'revertResize', None, **kwargs)
+ return self.action(server_id, 'revertResize', **kwargs)
def list_server_metadata(self, server_id):
resp, body = self.get("servers/%s/metadata" % server_id)
body = json.loads(body)
self.validate_response(schema.list_server_metadata, resp, body)
- return service_client.ResponseBody(resp, body['metadata'])
+ return service_client.ResponseBody(resp, body)
def set_server_metadata(self, server_id, meta, no_metadata_field=False):
if no_metadata_field:
@@ -258,7 +255,7 @@
post_body)
body = json.loads(body)
self.validate_response(schema.set_server_metadata, resp, body)
- return service_client.ResponseBody(resp, body['metadata'])
+ return service_client.ResponseBody(resp, body)
def update_server_metadata(self, server_id, meta):
post_body = json.dumps({'metadata': meta})
@@ -267,14 +264,14 @@
body = json.loads(body)
self.validate_response(schema.update_server_metadata,
resp, body)
- return service_client.ResponseBody(resp, body['metadata'])
+ return service_client.ResponseBody(resp, body)
def get_server_metadata_item(self, server_id, key):
resp, body = self.get("servers/%s/metadata/%s" % (server_id, key))
body = json.loads(body)
self.validate_response(schema.set_get_server_metadata_item,
resp, body)
- return service_client.ResponseBody(resp, body['meta'])
+ return service_client.ResponseBody(resp, body)
def set_server_metadata_item(self, server_id, key, meta):
post_body = json.dumps({'meta': meta})
@@ -283,7 +280,7 @@
body = json.loads(body)
self.validate_response(schema.set_get_server_metadata_item,
resp, body)
- return service_client.ResponseBody(resp, body['meta'])
+ return service_client.ResponseBody(resp, body)
def delete_server_metadata_item(self, server_id, key):
resp, body = self.delete("servers/%s/metadata/%s" %
@@ -293,10 +290,10 @@
return service_client.ResponseBody(resp, body)
def stop_server(self, server_id, **kwargs):
- return self.action(server_id, 'os-stop', None, **kwargs)
+ return self.action(server_id, 'os-stop', **kwargs)
def start_server(self, server_id, **kwargs):
- return self.action(server_id, 'os-start', None, **kwargs)
+ return self.action(server_id, 'os-start', **kwargs)
def attach_volume(self, server_id, **kwargs):
"""Attaches a volume to a server instance."""
@@ -305,7 +302,7 @@
post_body)
body = json.loads(body)
self.validate_response(schema.attach_volume, resp, body)
- return service_client.ResponseBody(resp, body['volumeAttachment'])
+ return service_client.ResponseBody(resp, body)
def detach_volume(self, server_id, volume_id):
"""Detaches a volume from a server instance."""
@@ -320,7 +317,7 @@
server_id, attach_id))
body = json.loads(body)
self.validate_response(schema.get_volume_attachment, resp, body)
- return service_client.ResponseBody(resp, body['volumeAttachment'])
+ return service_client.ResponseBody(resp, body)
def list_volume_attachments(self, server_id):
"""Returns the list of volume attachments for a given instance."""
@@ -328,15 +325,15 @@
server_id))
body = json.loads(body)
self.validate_response(schema.list_volume_attachments, resp, body)
- return service_client.ResponseBodyList(resp, body['volumeAttachments'])
+ return service_client.ResponseBody(resp, body)
def add_security_group(self, server_id, name):
"""Adds a security group to the server."""
- return self.action(server_id, 'addSecurityGroup', None, name=name)
+ return self.action(server_id, 'addSecurityGroup', name=name)
def remove_security_group(self, server_id, name):
"""Removes a security group from the server."""
- return self.action(server_id, 'removeSecurityGroup', None, name=name)
+ return self.action(server_id, 'removeSecurityGroup', name=name)
def live_migrate_server(self, server_id, **kwargs):
"""This should be called with administrator privileges ."""
@@ -350,53 +347,52 @@
def migrate_server(self, server_id, **kwargs):
"""Migrates a server to a new host."""
- return self.action(server_id, 'migrate', None, **kwargs)
+ return self.action(server_id, 'migrate', **kwargs)
def lock_server(self, server_id, **kwargs):
"""Locks the given server."""
- return self.action(server_id, 'lock', None, **kwargs)
+ return self.action(server_id, 'lock', **kwargs)
def unlock_server(self, server_id, **kwargs):
"""UNlocks the given server."""
- return self.action(server_id, 'unlock', None, **kwargs)
+ return self.action(server_id, 'unlock', **kwargs)
def suspend_server(self, server_id, **kwargs):
"""Suspends the provided server."""
- return self.action(server_id, 'suspend', None, **kwargs)
+ return self.action(server_id, 'suspend', **kwargs)
def resume_server(self, server_id, **kwargs):
"""Un-suspends the provided server."""
- return self.action(server_id, 'resume', None, **kwargs)
+ return self.action(server_id, 'resume', **kwargs)
def pause_server(self, server_id, **kwargs):
"""Pauses the provided server."""
- return self.action(server_id, 'pause', None, **kwargs)
+ return self.action(server_id, 'pause', **kwargs)
def unpause_server(self, server_id, **kwargs):
"""Un-pauses the provided server."""
- return self.action(server_id, 'unpause', None, **kwargs)
+ return self.action(server_id, 'unpause', **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)
+ return self.action(server_id, 'os-resetState', state=state)
def shelve_server(self, server_id, **kwargs):
"""Shelves the provided server."""
- return self.action(server_id, 'shelve', None, **kwargs)
+ return self.action(server_id, 'shelve', **kwargs)
def unshelve_server(self, server_id, **kwargs):
"""Un-shelves the provided server."""
- return self.action(server_id, 'unshelve', None, **kwargs)
+ return self.action(server_id, 'unshelve', **kwargs)
def shelve_offload_server(self, server_id, **kwargs):
"""Shelve-offload the provided server."""
- return self.action(server_id, 'shelveOffload', None, **kwargs)
+ return self.action(server_id, 'shelveOffload', **kwargs)
def get_console_output(self, server_id, length):
kwargs = {'length': length} if length else {}
- return self.action(server_id, 'os-getConsoleOutput', 'output',
+ return self.action(server_id, 'os-getConsoleOutput',
schema.get_console_output,
- response_class=service_client.ResponseBodyData,
**kwargs)
def list_virtual_interfaces(self, server_id):
@@ -411,14 +407,13 @@
def rescue_server(self, server_id, **kwargs):
"""Rescue the provided server."""
- return self.action(server_id, 'rescue', 'adminPass',
+ return self.action(server_id, 'rescue',
schema.rescue_server,
- response_class=service_client.ResponseBodyData,
**kwargs)
def unrescue_server(self, server_id):
"""Unrescue the provided server."""
- return self.action(server_id, 'unrescue', None)
+ return self.action(server_id, 'unrescue')
def get_server_diagnostics(self, server_id):
"""Get the usage data for a server."""
@@ -431,7 +426,7 @@
server_id)
body = json.loads(body)
self.validate_response(schema.list_instance_actions, resp, body)
- return service_client.ResponseBodyList(resp, body['instanceActions'])
+ return service_client.ResponseBody(resp, body)
def get_instance_action(self, server_id, request_id):
"""Returns the action details of the provided server."""
@@ -439,26 +434,26 @@
(server_id, request_id))
body = json.loads(body)
self.validate_response(schema.get_instance_action, resp, body)
- return service_client.ResponseBody(resp, body['instanceAction'])
+ return service_client.ResponseBody(resp, body)
def force_delete_server(self, server_id, **kwargs):
"""Force delete a server."""
- return self.action(server_id, 'forceDelete', None, **kwargs)
+ return self.action(server_id, 'forceDelete', **kwargs)
def restore_soft_deleted_server(self, server_id, **kwargs):
"""Restore a soft-deleted server."""
- return self.action(server_id, 'restore', None, **kwargs)
+ return self.action(server_id, 'restore', **kwargs)
def reset_network(self, server_id, **kwargs):
"""Resets the Network of a server"""
- return self.action(server_id, 'resetNetwork', None, **kwargs)
+ return self.action(server_id, 'resetNetwork', **kwargs)
def inject_network_info(self, server_id, **kwargs):
"""Inject the Network Info into server"""
- return self.action(server_id, 'injectNetworkInfo', None, **kwargs)
+ return self.action(server_id, 'injectNetworkInfo', **kwargs)
def get_vnc_console(self, server_id, console_type):
"""Get URL of VNC console."""
return self.action(server_id, "os-getVNCConsole",
- "console", schema.get_vnc_console,
+ schema.get_vnc_console,
type=console_type)
diff --git a/tempest/services/compute/json/snapshots_extensions_client.py b/tempest/services/compute/json/snapshots_extensions_client.py
new file mode 100644
index 0000000..6902a39
--- /dev/null
+++ b/tempest/services/compute/json/snapshots_extensions_client.py
@@ -0,0 +1,71 @@
+# Copyright 2015 Fujitsu(fnst) 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 oslo_serialization import jsonutils as json
+from six.moves.urllib import parse as urllib
+from tempest_lib import exceptions as lib_exc
+
+from tempest.api_schema.response.compute.v2_1 import snapshots as schema
+from tempest.common import service_client
+
+
+class SnapshotsExtensionsClient(service_client.ServiceClient):
+
+ def create_snapshot(self, volume_id, **kwargs):
+ post_body = {
+ 'volume_id': volume_id
+ }
+ post_body.update(kwargs)
+ post_body = json.dumps({'snapshot': post_body})
+ resp, body = self.post('os-snapshots', post_body)
+ body = json.loads(body)
+ self.validate_response(schema.create_get_snapshot, resp, body)
+ return service_client.ResponseBody(resp, body)
+
+ def show_snapshot(self, snapshot_id):
+ url = "os-snapshots/%s" % snapshot_id
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.validate_response(schema.create_get_snapshot, resp, body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_snapshots(self, detail=False, params=None):
+ url = 'os-snapshots'
+
+ if detail:
+ url += '/detail'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.validate_response(schema.list_snapshots, resp, body)
+ return service_client.ResponseBody(resp, body)
+
+ def delete_snapshot(self, snapshot_id):
+ resp, body = self.delete("os-snapshots/%s" % snapshot_id)
+ self.validate_response(schema.delete_snapshot, resp, body)
+ return service_client.ResponseBody(resp, body)
+
+ def is_resource_deleted(self, id):
+ try:
+ self.show_snapshot(id)
+ except lib_exc.NotFound:
+ return True
+ return False
+
+ @property
+ def resource_type(self):
+ """Returns the primary type of resource this client works with."""
+ return 'snapshot'
diff --git a/tempest/services/database/json/flavors_client.py b/tempest/services/database/json/flavors_client.py
index 4fe5a46..88feb17 100644
--- a/tempest/services/database/json/flavors_client.py
+++ b/tempest/services/database/json/flavors_client.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_serialization import jsonutils as json
import urllib
from tempest.common import service_client
@@ -27,9 +28,11 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
def get_db_flavor_details(self, db_flavor_id):
resp, body = self.get("flavors/%s" % str(db_flavor_id))
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, self._parse_resp(body))
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/stress/actions/server_create_destroy.py b/tempest/stress/actions/server_create_destroy.py
index 17f4bc9..37664de 100644
--- a/tempest/stress/actions/server_create_destroy.py
+++ b/tempest/stress/actions/server_create_destroy.py
@@ -30,7 +30,7 @@
name = data_utils.rand_name("instance")
self.logger.info("creating %s" % name)
server = self.manager.servers_client.create_server(
- name, self.image, self.flavor)
+ name, self.image, self.flavor)['server']
server_id = server['id']
waiters.wait_for_server_status(self.manager.servers_client, server_id,
'ACTIVE')
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 2505a77..81bb071 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -77,7 +77,7 @@
vm_args['security_groups'] = [self.sec_grp]
server = servers_client.create_server(name, self.image,
self.flavor,
- **vm_args)
+ **vm_args)['server']
self.server_id = server['id']
if self.wait_after_vm_create:
waiters.wait_for_server_status(self.manager.servers_client,
diff --git a/tempest/stress/actions/volume_attach_delete.py b/tempest/stress/actions/volume_attach_delete.py
index b35f587..b3753a5 100644
--- a/tempest/stress/actions/volume_attach_delete.py
+++ b/tempest/stress/actions/volume_attach_delete.py
@@ -39,7 +39,7 @@
vm_name = data_utils.rand_name("instance")
self.logger.info("creating vm: %s" % vm_name)
server = self.manager.servers_client.create_server(
- vm_name, self.image, self.flavor)
+ vm_name, self.image, self.flavor)['server']
server_id = server['id']
waiters.wait_for_server_status(self.manager.servers_client, server_id,
'ACTIVE')
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index fe481c4..8105626 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -41,7 +41,7 @@
vm_args['key_name'] = self.key['name']
server = servers_client.create_server(name, self.image,
self.flavor,
- **vm_args)
+ **vm_args)['server']
self.server_id = server['id']
waiters.wait_for_server_status(self.manager.servers_client,
self.server_id, 'ACTIVE')
diff --git a/tempest/tests/services/compute/test_volumes_extensions_client.py b/tempest/tests/services/compute/test_volumes_extensions_client.py
new file mode 100644
index 0000000..2fe8497
--- /dev/null
+++ b/tempest/tests/services/compute/test_volumes_extensions_client.py
@@ -0,0 +1,114 @@
+# Copyright 2015 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 oslotest import mockpatch
+from tempest_lib import exceptions as lib_exc
+
+from tempest.services.compute.json import volumes_extensions_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestVolumesExtensionsClient(base.BaseComputeServiceTest):
+
+ FAKE_VOLUME = {
+ "id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
+ "displayName": u"v\u12345ol-001",
+ "displayDescription": u"Another \u1234volume.",
+ "size": 30,
+ "status": "Active",
+ "volumeType": "289da7f8-6440-407c-9fb4-7db01ec49164",
+ "metadata": {
+ "contents": "junk"
+ },
+ "availabilityZone": "us-east1",
+ "snapshotId": None,
+ "attachments": [],
+ "createdAt": "2012-02-14T20:53:07Z"
+ }
+
+ FAKE_VOLUMES = {"volumes": [FAKE_VOLUME]}
+
+ def setUp(self):
+ super(TestVolumesExtensionsClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = volumes_extensions_client.VolumesExtensionsClient(
+ fake_auth, 'compute', 'regionOne')
+
+ def _test_list_volumes(self, bytes_body=False, **params):
+ self.check_service_client_function(
+ self.client.list_volumes,
+ 'tempest.common.service_client.ServiceClient.get',
+ self.FAKE_VOLUMES, to_utf=bytes_body, **params)
+
+ def test_list_volumes_with_str_body(self):
+ self._test_list_volumes()
+
+ def test_list_volumes_with_byte_body(self):
+ self._test_list_volumes(bytes_body=True)
+
+ def test_list_volumes_with_params(self):
+ self._test_list_volumes(name='fake')
+
+ def _test_show_volume(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.show_volume,
+ 'tempest.common.service_client.ServiceClient.get',
+ {"volume": self.FAKE_VOLUME},
+ to_utf=bytes_body, volume_id=self.FAKE_VOLUME['id'])
+
+ def test_show_volume_with_str_body(self):
+ self._test_show_volume()
+
+ def test_show_volume_with_bytes_body(self):
+ self._test_show_volume(bytes_body=True)
+
+ def _test_create_volume(self, bytes_body=False):
+ post_body = copy.deepcopy(self.FAKE_VOLUME)
+ del post_body['id']
+ del post_body['createdAt']
+ del post_body['status']
+ self.check_service_client_function(
+ self.client.create_volume,
+ 'tempest.common.service_client.ServiceClient.post',
+ {"volume": self.FAKE_VOLUME},
+ to_utf=bytes_body, status=200, **post_body)
+
+ def test_create_volume_with_str_body(self):
+ self._test_create_volume()
+
+ def test_create_volume_with_bytes_body(self):
+ self._test_create_volume(bytes_body=True)
+
+ def test_delete_volume(self):
+ self.check_service_client_function(
+ self.client.delete_volume,
+ 'tempest.common.service_client.ServiceClient.delete',
+ {}, status=202, volume_id=self.FAKE_VOLUME['id'])
+
+ def test_is_resource_deleted_true(self):
+ module = ('tempest.services.compute.json.volumes_extensions_client.'
+ 'VolumesExtensionsClient.show_volume')
+ self.useFixture(mockpatch.Patch(
+ module, side_effect=lib_exc.NotFound))
+ self.assertTrue(self.client.is_resource_deleted('fake-id'))
+
+ def test_is_resource_deleted_false(self):
+ module = ('tempest.services.compute.json.volumes_extensions_client.'
+ 'VolumesExtensionsClient.show_volume')
+ self.useFixture(mockpatch.Patch(
+ module, return_value={}))
+ self.assertFalse(self.client.is_resource_deleted('fake-id'))