diff options
| author | xing-yang <xing.yang@emc.com> | 2016-07-09 21:56:42 -0400 |
|---|---|---|
| committer | xing-yang <xing.yang@emc.com> | 2017-05-05 02:14:56 -0400 |
| commit | da79866e1431442431cb3c077b57252caa480750 (patch) | |
| tree | 38ee75939524adad9003e61381be8bb1b2610f31 /cinderclient/v3/groups.py | |
| parent | 0fdd41d84ccfa16245d60617a4099e120f6100cf (diff) | |
| download | python-cinderclient-da79866e1431442431cb3c077b57252caa480750.tar.gz | |
Tiramisu: replication group support
This patch adds CLI support for replication group.
It is built upon the generic volume groups.
Server side patch is here:
https://review.openstack.org/#/c/352228/
Depends-On: I4d488252bd670b3ebabbcc9f5e29e0e4e913765a
Change-Id: I462c3ab8c9c3a6a1b434748f81d208359ffd2431
Implements: blueprint replication-cg
Diffstat (limited to 'cinderclient/v3/groups.py')
| -rw-r--r-- | cinderclient/v3/groups.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/cinderclient/v3/groups.py b/cinderclient/v3/groups.py index 386a6a3..6bc298a 100644 --- a/cinderclient/v3/groups.py +++ b/cinderclient/v3/groups.py @@ -39,6 +39,25 @@ class Group(base.Resource): """Reset the group's state with specified one""" return self.manager.reset_state(self, state) + def enable_replication(self): + """Enables replication for this group.""" + return self.manager.enable_replication(self) + + def disable_replication(self): + """Disables replication for this group.""" + return self.manager.disable_replication(self) + + def failover_replication(self, allow_attached_volume=False, + secondary_backend_id=None): + """Fails over replication for this group.""" + return self.manager.failover_replication(self, + allow_attached_volume, + secondary_backend_id) + + def list_replication_targets(self): + """Lists replication targets for this group.""" + return self.manager.list_replication_targets(self) + class GroupManager(base.ManagerWithFind): """Manage :class:`Group` resources.""" @@ -180,3 +199,55 @@ class GroupManager(base.ManagerWithFind): url = '/groups/%s/action' % base.getid(group) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp) + + def enable_replication(self, group): + """Enables replication for a group. + + :param group: the :class:`Group` to enable replication. + """ + body = {'enable_replication': {}} + self.run_hooks('modify_body_for_action', body, 'group') + url = '/groups/%s/action' % base.getid(group) + resp, body = self.api.client.post(url, body=body) + return common_base.TupleWithMeta((resp, body), resp) + + def disable_replication(self, group): + """disables replication for a group. + + :param group: the :class:`Group` to disable replication. + """ + body = {'disable_replication': {}} + self.run_hooks('modify_body_for_action', body, 'group') + url = '/groups/%s/action' % base.getid(group) + resp, body = self.api.client.post(url, body=body) + return common_base.TupleWithMeta((resp, body), resp) + + def failover_replication(self, group, allow_attached_volume=False, + secondary_backend_id=None): + """fails over replication for a group. + + :param group: the :class:`Group` to failover. + :param allow attached volumes: allow attached volumes in the group. + :param secondary_backend_id: secondary backend id. + """ + body = { + 'failover_replication': { + 'allow_attached_volume': allow_attached_volume, + 'secondary_backend_id': secondary_backend_id + } + } + self.run_hooks('modify_body_for_action', body, 'group') + url = '/groups/%s/action' % base.getid(group) + resp, body = self.api.client.post(url, body=body) + return common_base.TupleWithMeta((resp, body), resp) + + def list_replication_targets(self, group): + """List replication targets for a group. + + :param group: the :class:`Group` to list replication targets. + """ + body = {'list_replication_targets': {}} + self.run_hooks('modify_body_for_action', body, 'group') + url = '/groups/%s/action' % base.getid(group) + resp, body = self.api.client.post(url, body=body) + return common_base.TupleWithMeta((resp, body), resp) |
