summaryrefslogtreecommitdiff
path: root/cinderclient/v3/attachments.py
diff options
context:
space:
mode:
authorJohn Griffith <john.griffith8@gmail.com>2017-08-11 23:36:07 +0000
committerj-griffith <john.griffith8@gmail.com>2017-08-14 10:27:44 -0600
commitb7d34684607bbc0d8c507970661d0b1d3bed7843 (patch)
treef5b00d6e6a7827b3e446767e01ffb83ecb2ccd3d /cinderclient/v3/attachments.py
parent09a6506dda4bf7351719ee85e0fc9aac018bf435 (diff)
downloadpython-cinderclient-b7d34684607bbc0d8c507970661d0b1d3bed7843.tar.gz
Add an attachment_complete API call
The new attachment_update method in Cinder's API creates an attachment object and populates it with the provided connector info. In addition, we set the volumes status to in-use and update the attachment object status to "attached". This isn't really accurate though, because we don't know if the volume is actually attached (connected) by the consumer or not. Also a big side effect here is that currently all of our tests and automation use volume-status to determine if a volume is fully connected/ready for use and that everything went well. It's used as an ack in most cases. This change goes back to using multiple states to signify where a an attachment is in it's life-cycle: 1. attachment_create We've created an empty attachment record but haven't done anything with it yet. 2. attachment_update We provided a connector and set up the TGT so that everything is ready for a consumer to connect/use it. 3. attachment_complete An ACK back from the consumer letting us know that they connected it successfully and are doing their thing. It would be cool to just key all these checks of the attachment object itself, and just use attachment_update to do so, maybe in the future? Change-Id: I3b28d2cb89a8d81c7cdec425f355c78bfdfe3450 Related-Bug: #1710295
Diffstat (limited to 'cinderclient/v3/attachments.py')
-rw-r--r--cinderclient/v3/attachments.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/cinderclient/v3/attachments.py b/cinderclient/v3/attachments.py
index 1eab8b1..6146626 100644
--- a/cinderclient/v3/attachments.py
+++ b/cinderclient/v3/attachments.py
@@ -66,3 +66,20 @@ class VolumeAttachmentManager(base.ManagerWithFind):
resp = self._update('/attachments/%s' % id, body)
return self.resource_class(self, resp['attachment'], loaded=True,
resp=resp)
+
+ def complete(self, attachment):
+ """Mark the attachment as completed."""
+ resp, body = self._action_return_resp_and_body('os-complete',
+ attachment,
+ None)
+ return resp
+
+ def _action_return_resp_and_body(self, action, attachment, info=None,
+ **kwargs):
+ """Perform a attachments "action" and return response headers and body.
+
+ """
+ body = {action: info}
+ self.run_hooks('modify_body_for_action', body, **kwargs)
+ url = '/attachments/%s/action' % base.getid(attachment)
+ return self.api.client.post(url, body=body)