diff --git a/cinderclient/api_versions.py b/cinderclient/api_versions.py index 537b77993..33ba5087d 100644 --- a/cinderclient/api_versions.py +++ b/cinderclient/api_versions.py @@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__) # key is a deprecated version and value is an alternative version. DEPRECATED_VERSIONS = {"1": "2"} DEPRECATED_VERSION = "2.0" -MAX_VERSION = "3.40" +MAX_VERSION = "3.44" MIN_VERSION = "3.0" _SUBSTITUTIONS = {} diff --git a/cinderclient/v3/attachments.py b/cinderclient/v3/attachments.py index 1eab8b100..614662684 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) diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index 9b6f1151d..97740e4c2 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -1937,6 +1937,16 @@ def do_attachment_delete(cs, args): cs.attachments.delete(attachment) +@api_versions.wraps('3.44') +@utils.arg('attachment', + metavar='', nargs='+', + help='ID of attachment or attachments to delete.') +def do_attachment_complete(cs, args): + """Complete an attachment for a cinder volume.""" + for attachment in args.attachment: + cs.attachments.complete(attachment) + + @api_versions.wraps('3.0') def do_version_list(cs, args): """List all API versions."""