Merge "Add update attached volume function to servers_client"
This commit is contained in:
commit
6ad0ce42c2
@ -547,3 +547,7 @@ server_actions_delete_password = {
|
|||||||
|
|
||||||
server_actions_confirm_resize = copy.deepcopy(
|
server_actions_confirm_resize = copy.deepcopy(
|
||||||
server_actions_delete_password)
|
server_actions_delete_password)
|
||||||
|
|
||||||
|
update_attached_volume = {
|
||||||
|
'status_code': [202]
|
||||||
|
}
|
||||||
|
@ -312,6 +312,15 @@ class ServersClient(rest_client.RestClient):
|
|||||||
self.validate_response(schema.attach_volume, resp, body)
|
self.validate_response(schema.attach_volume, resp, body)
|
||||||
return rest_client.ResponseBody(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
|
def detach_volume(self, server_id, volume_id): # noqa
|
||||||
"""Detaches a volume from a server instance."""
|
"""Detaches a volume from a server instance."""
|
||||||
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
|
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
|
||||||
|
@ -564,6 +564,17 @@ class TestServersClient(base.BaseComputeServiceTest):
|
|||||||
server_id=self.server_id
|
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):
|
def test_detach_volume_with_str_body(self):
|
||||||
self._test_detach_volume_server()
|
self._test_detach_volume_server()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user