Merge "Add update attached volume function to servers_client"

This commit is contained in:
Jenkins 2016-02-12 21:31:39 +00:00 committed by Gerrit Code Review
commit 6ad0ce42c2
3 changed files with 24 additions and 0 deletions

View File

@ -547,3 +547,7 @@ server_actions_delete_password = {
server_actions_confirm_resize = copy.deepcopy(
server_actions_delete_password)
update_attached_volume = {
'status_code': [202]
}

View File

@ -312,6 +312,15 @@ class ServersClient(rest_client.RestClient):
self.validate_response(schema.attach_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def update_attached_volume(self, server_id, attachment_id, **kwargs):
"""Swaps a volume attached to an instance for another volume"""
post_body = json.dumps({'volumeAttachment': kwargs})
resp, body = self.put('servers/%s/os-volume_attachments/%s' %
(server_id, attachment_id),
post_body)
self.validate_response(schema.update_attached_volume, resp, body)
return rest_client.ResponseBody(resp, body)
def detach_volume(self, server_id, volume_id): # noqa
"""Detaches a volume from a server instance."""
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %

View File

@ -564,6 +564,17 @@ class TestServersClient(base.BaseComputeServiceTest):
server_id=self.server_id
)
def test_update_attached_volume(self):
self.check_service_client_function(
self.client.update_attached_volume,
'tempest_lib.common.rest_client.RestClient.put',
{},
status=202,
server_id=self.server_id,
attachment_id='fake-attachment-id',
volumeId='fake-volume-id'
)
def test_detach_volume_with_str_body(self):
self._test_detach_volume_server()