Merge "add test for updating server's disk_config test"
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 9abb86a..ffc8b6b 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -38,6 +38,7 @@
# A server should be rebuilt using the manual disk config option
resp, server = self.create_server(disk_config='AUTO',
wait_until='ACTIVE')
+ self.addCleanup(self.client.delete_server, server['id'])
# Verify the specified attributes are set correctly
resp, server = self.client.get_server(server['id'])
@@ -54,14 +55,12 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
- # Delete the server
- resp, body = self.client.delete_server(server['id'])
-
@attr(type='gate')
def test_rebuild_server_with_auto_disk_config(self):
# A server should be rebuilt using the auto disk config option
resp, server = self.create_server(disk_config='MANUAL',
wait_until='ACTIVE')
+ self.addCleanup(self.client.delete_server, server['id'])
# Verify the specified attributes are set correctly
resp, server = self.client.get_server(server['id'])
@@ -78,16 +77,13 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
- # Delete the server
- resp, body = self.client.delete_server(server['id'])
-
@testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_manual_to_auto(self):
# A server should be resized from manual to auto disk config
resp, server = self.create_server(disk_config='MANUAL',
wait_until='ACTIVE')
-
+ self.addCleanup(self.client.delete_server, server['id'])
# Resize with auto option
self.client.resize(server['id'], self.flavor_ref_alt,
disk_config='AUTO')
@@ -98,15 +94,13 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
- # Delete the server
- resp, body = self.client.delete_server(server['id'])
-
@testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_auto_to_manual(self):
# A server should be resized from auto to manual disk config
resp, server = self.create_server(disk_config='AUTO',
wait_until='ACTIVE')
+ self.addCleanup(self.client.delete_server, server['id'])
# Resize with manual option
self.client.resize(server['id'], self.flavor_ref_alt,
@@ -118,8 +112,26 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
- # Delete the server
- resp, body = self.client.delete_server(server['id'])
+ @attr(type='gate')
+ def test_update_server_from_auto_to_manual(self):
+ # A server should be updated from auto to manual disk config
+ resp, server = self.create_server(disk_config='AUTO',
+ wait_until='ACTIVE')
+ self.addCleanup(self.client.delete_server, server['id'])
+
+ # Verify the disk_config attribute is set correctly
+ resp, server = self.client.get_server(server['id'])
+ self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
+
+ # Update the disk_config attribute to manual
+ resp, server = self.client.update_server(server['id'],
+ disk_config='MANUAL')
+ self.assertEqual(200, resp.status)
+ self.client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ # 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):
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index dfbc01c..07bb6ce 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -89,7 +89,7 @@
return resp, body['server']
def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
- accessIPv6=None):
+ accessIPv6=None, disk_config=None):
"""
Updates the properties of an existing server.
server_id: The id of an existing server.
@@ -113,6 +113,9 @@
if accessIPv6 is not None:
post_body['accessIPv6'] = accessIPv6
+ if disk_config is not None:
+ post_body['OS-DCF:diskConfig'] = disk_config
+
post_body = json.dumps({'server': post_body})
resp, body = self.put("servers/%s" % str(server_id),
post_body, self.headers)
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index ada0398..43de4ef 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -250,7 +250,7 @@
return resp, {"servers": servers}
def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
- accessIPv6=None):
+ accessIPv6=None, disk_config=None):
doc = Document()
server = Element("server")
doc.append(server)
@@ -261,6 +261,10 @@
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 = Element("metadata")
server.append(metadata)