From e2618ebb246d225c452b1f4aa2871a73633d9f5f Mon Sep 17 00:00:00 2001
From: "jeremy.zhang" <zhangjun_inspur@163.com>
Date: Thu, 25 Jan 2018 21:56:28 +0800
Subject: [PATCH] Add api_version wraps for some v3 volume APIs

This patch is mainly to add api_version wraps for some v3 volume APIs.

Change-Id: Iea8b9b68930548156749da3f98629e3602ffca83
---
 cinderclient/v3/attachments.py     | 5 +++++
 cinderclient/v3/group_snapshots.py | 5 +++++
 cinderclient/v3/volumes.py         | 1 +
 cinderclient/v3/workers.py         | 2 ++
 4 files changed, 13 insertions(+)

diff --git a/cinderclient/v3/attachments.py b/cinderclient/v3/attachments.py
index aaa8bcf2f..e18bf9842 100644
--- a/cinderclient/v3/attachments.py
+++ b/cinderclient/v3/attachments.py
@@ -26,6 +26,7 @@ class VolumeAttachment(base.Resource):
 class VolumeAttachmentManager(base.ManagerWithFind):
     resource_class = VolumeAttachment
 
+    @api_versions.wraps('3.27')
     def create(self, volume_id, connector, instance_id):
         """Create a attachment for specified volume."""
         body = {'attachment': {'volume_uuid': volume_id,
@@ -34,10 +35,12 @@ class VolumeAttachmentManager(base.ManagerWithFind):
         retval = self._create('/attachments', body, 'attachment')
         return retval.to_dict()
 
+    @api_versions.wraps('3.27')
     def delete(self, attachment):
         """Delete an attachment by ID."""
         return self._delete("/attachments/%s" % base.getid(attachment))
 
+    @api_versions.wraps('3.27')
     def list(self, detailed=False, search_opts=None, marker=None, limit=None,
              sort_key=None, sort_dir=None, sort=None):
         """List all attachments."""
@@ -51,6 +54,7 @@ class VolumeAttachmentManager(base.ManagerWithFind):
                                    sort_dir=sort_dir, sort=sort)
         return self._list(url, resource_type, limit=limit)
 
+    @api_versions.wraps('3.27')
     def show(self, id):
         """Attachment show.
 
@@ -61,6 +65,7 @@ class VolumeAttachmentManager(base.ManagerWithFind):
         return self.resource_class(self, body['attachment'], loaded=True,
                                    resp=resp)
 
+    @api_versions.wraps('3.27')
     def update(self, id, connector):
         """Attachment update."""
         body = {'attachment': {'connector': connector}}
diff --git a/cinderclient/v3/group_snapshots.py b/cinderclient/v3/group_snapshots.py
index 741149d70..ed7fe7924 100644
--- a/cinderclient/v3/group_snapshots.py
+++ b/cinderclient/v3/group_snapshots.py
@@ -44,6 +44,7 @@ class GroupSnapshotManager(base.ManagerWithFind):
     """Manage :class:`GroupSnapshot` resources."""
     resource_class = GroupSnapshot
 
+    @api_versions.wraps('3.14')
     def create(self, group_id, name=None, description=None,
                user_id=None,
                project_id=None):
@@ -67,6 +68,7 @@ class GroupSnapshotManager(base.ManagerWithFind):
 
         return self._create('/group_snapshots', body, 'group_snapshot')
 
+    @api_versions.wraps('3.14')
     def get(self, group_snapshot_id):
         """Get a group snapshot.
 
@@ -86,6 +88,7 @@ class GroupSnapshotManager(base.ManagerWithFind):
         body = {'status': state} if state else {}
         return self._action('reset_status', group_snapshot, body)
 
+    @api_versions.wraps('3.14')
     def list(self, detailed=True, search_opts=None):
         """Lists all group snapshots.
 
@@ -102,6 +105,7 @@ class GroupSnapshotManager(base.ManagerWithFind):
         return self._list("/group_snapshots%s%s" % (detail, query_string),
                           "group_snapshots")
 
+    @api_versions.wraps('3.14')
     def delete(self, group_snapshot):
         """Delete a group_snapshot.
 
@@ -109,6 +113,7 @@ class GroupSnapshotManager(base.ManagerWithFind):
         """
         return self._delete("/group_snapshots/%s" % base.getid(group_snapshot))
 
+    @api_versions.wraps('3.14')
     def update(self, group_snapshot, **kwargs):
         """Update the name or description for a group_snapshot.
 
diff --git a/cinderclient/v3/volumes.py b/cinderclient/v3/volumes.py
index 0cee48bf4..a8c2e49f9 100644
--- a/cinderclient/v3/volumes.py
+++ b/cinderclient/v3/volumes.py
@@ -151,6 +151,7 @@ class VolumeManager(volumes.VolumeManager):
         return self._action('revert', volume,
                             info={'snapshot_id': base.getid(snapshot.id)})
 
+    @api_versions.wraps('3.12')
     def summary(self, all_tenants):
         """Get volumes summary."""
         url = "/volumes/summary"
diff --git a/cinderclient/v3/workers.py b/cinderclient/v3/workers.py
index 86f895dc8..3794ee921 100644
--- a/cinderclient/v3/workers.py
+++ b/cinderclient/v3/workers.py
@@ -16,6 +16,7 @@
 """
 Interface to workers API
 """
+from cinderclient import api_versions
 from cinderclient.apiclient import base as common_base
 from cinderclient import base
 
@@ -33,6 +34,7 @@ class Service(base.Resource):
 class WorkerManager(base.Manager):
     base_url = '/workers'
 
+    @api_versions.wraps('3.24')
     def clean(self, **filters):
         url = self.base_url + '/cleanup'
         resp, body = self.api.client.post(url, body=filters)