summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Lucas <glucas@tesora.com>2014-08-29 22:58:04 -0400
committerGreg Lucas <glucas@tesora.com>2014-09-05 11:13:37 -0400
commitb287f672ac650defda96939945192af6df452136 (patch)
treefcd754338ccfa09204777fa1b0f61556fb63d0e0
parent6852bdcefc17712b4b57a530adfb406e059e52e2 (diff)
downloadpython-troveclient-b287f672ac650defda96939945192af6df452136.tar.gz
Use 'replica' instead of 'slave'
Replace the mysql-specific term 'slave' with the more general term 'replica'. In order to merge properly the client currently handles both 'slave' and 'replica' in certain cases. The 'slave' support will be removed completely once the trove runtime is updated to be in sync. Change-Id: Id22d18a84a4ac104ff8af09959e8eb2ae0102e97 Co-Authored-By: Nikhil Manchanda <SlickNik@gmail.com> Partial-Bug: 1360310
-rw-r--r--troveclient/v1/instances.py11
-rw-r--r--troveclient/v1/shell.py16
2 files changed, 16 insertions, 11 deletions
diff --git a/troveclient/v1/instances.py b/troveclient/v1/instances.py
index 2171333..9a10d87 100644
--- a/troveclient/v1/instances.py
+++ b/troveclient/v1/instances.py
@@ -47,11 +47,13 @@ class Instances(base.ManagerWithFind):
"""Manage :class:`Instance` resources."""
resource_class = Instance
+ # TODO(SlickNik): Remove slave_of param after updating tests to replica_of
def create(self, name, flavor_id, volume=None, databases=None, users=None,
restorePoint=None, availability_zone=None, datastore=None,
datastore_version=None, nics=None, configuration=None,
- slave_of=None):
+ replica_of=None, slave_of=None):
"""Create (boot) a new instance."""
+
body = {"instance": {
"name": name,
"flavorRef": flavor_id
@@ -77,8 +79,8 @@ class Instances(base.ManagerWithFind):
body["instance"]["nics"] = nics
if configuration:
body["instance"]["configuration"] = configuration
- if slave_of:
- body["instance"]["slave_of"] = slave_of
+ if replica_of or slave_of:
+ body["instance"]["replica_of"] = replica_of or slave_of
return self._create("/instances", body, "instance")
@@ -109,7 +111,10 @@ class Instances(base.ManagerWithFind):
if name is not None:
body["instance"]["name"] = name
if detach_replica_source:
+ # TODO(glucas): Remove slave_of after updating trove
+ # (see trove.instance.service.InstanceController#edit)
body["instance"]["slave_of"] = None
+ body["instance"]["replica_of"] = None
url = "/instances/%s" % instance_id
resp, body = self.api.client.patch(url, body=body)
diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py
index 83be5be..0ace366 100644
--- a/troveclient/v1/shell.py
+++ b/troveclient/v1/shell.py
@@ -74,11 +74,11 @@ def _print_instance(instance):
info['datastore_version'] = instance.datastore['version']
if hasattr(instance, 'configuration'):
info['configuration'] = instance.configuration['id']
- if hasattr(instance, 'slave_of'):
- info['slave_of'] = instance.slave_of['id']
- if hasattr(instance, 'slaves'):
- slaves = [slave['id'] for slave in instance.slaves]
- info['slaves'] = ', '.join(slaves)
+ if hasattr(instance, 'replica_of'):
+ info['replica_of'] = instance.replica_of['id']
+ if hasattr(instance, 'replicas'):
+ replicas = [replica['id'] for replica in instance.replicas]
+ info['replicas'] = ', '.join(replicas)
info.pop('links', None)
utils.print_dict(info)
@@ -318,8 +318,8 @@ def do_update(cs, args):
metavar='<configuration>',
default=None,
help='ID of the configuration group to attach to the instance.')
-@utils.arg('--slave_of',
- metavar='<master_id>',
+@utils.arg('--replica_of',
+ metavar='<source_id>',
default=None,
help='ID of an existing instance to replicate from.')
@utils.service_type('database')
@@ -356,7 +356,7 @@ def do_create(cs, args):
datastore_version=args.datastore_version,
nics=nics,
configuration=args.configuration,
- slave_of=args.slave_of)
+ replica_of=args.replica_of)
_print_instance(instance)