Merge "Use 'replica' instead of 'slave'"
This commit is contained in:
@@ -47,11 +47,13 @@ class Instances(base.ManagerWithFind):
|
|||||||
"""Manage :class:`Instance` resources."""
|
"""Manage :class:`Instance` resources."""
|
||||||
resource_class = Instance
|
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,
|
def create(self, name, flavor_id, volume=None, databases=None, users=None,
|
||||||
restorePoint=None, availability_zone=None, datastore=None,
|
restorePoint=None, availability_zone=None, datastore=None,
|
||||||
datastore_version=None, nics=None, configuration=None,
|
datastore_version=None, nics=None, configuration=None,
|
||||||
slave_of=None):
|
replica_of=None, slave_of=None):
|
||||||
"""Create (boot) a new instance."""
|
"""Create (boot) a new instance."""
|
||||||
|
|
||||||
body = {"instance": {
|
body = {"instance": {
|
||||||
"name": name,
|
"name": name,
|
||||||
"flavorRef": flavor_id
|
"flavorRef": flavor_id
|
||||||
@@ -77,8 +79,8 @@ class Instances(base.ManagerWithFind):
|
|||||||
body["instance"]["nics"] = nics
|
body["instance"]["nics"] = nics
|
||||||
if configuration:
|
if configuration:
|
||||||
body["instance"]["configuration"] = configuration
|
body["instance"]["configuration"] = configuration
|
||||||
if slave_of:
|
if replica_of or slave_of:
|
||||||
body["instance"]["slave_of"] = slave_of
|
body["instance"]["replica_of"] = replica_of or slave_of
|
||||||
|
|
||||||
return self._create("/instances", body, "instance")
|
return self._create("/instances", body, "instance")
|
||||||
|
|
||||||
@@ -109,7 +111,10 @@ class Instances(base.ManagerWithFind):
|
|||||||
if name is not None:
|
if name is not None:
|
||||||
body["instance"]["name"] = name
|
body["instance"]["name"] = name
|
||||||
if detach_replica_source:
|
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"]["slave_of"] = None
|
||||||
|
body["instance"]["replica_of"] = None
|
||||||
|
|
||||||
url = "/instances/%s" % instance_id
|
url = "/instances/%s" % instance_id
|
||||||
resp, body = self.api.client.patch(url, body=body)
|
resp, body = self.api.client.patch(url, body=body)
|
||||||
|
@@ -74,11 +74,11 @@ def _print_instance(instance):
|
|||||||
info['datastore_version'] = instance.datastore['version']
|
info['datastore_version'] = instance.datastore['version']
|
||||||
if hasattr(instance, 'configuration'):
|
if hasattr(instance, 'configuration'):
|
||||||
info['configuration'] = instance.configuration['id']
|
info['configuration'] = instance.configuration['id']
|
||||||
if hasattr(instance, 'slave_of'):
|
if hasattr(instance, 'replica_of'):
|
||||||
info['slave_of'] = instance.slave_of['id']
|
info['replica_of'] = instance.replica_of['id']
|
||||||
if hasattr(instance, 'slaves'):
|
if hasattr(instance, 'replicas'):
|
||||||
slaves = [slave['id'] for slave in instance.slaves]
|
replicas = [replica['id'] for replica in instance.replicas]
|
||||||
info['slaves'] = ', '.join(slaves)
|
info['replicas'] = ', '.join(replicas)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
utils.print_dict(info)
|
||||||
|
|
||||||
@@ -318,8 +318,8 @@ def do_update(cs, args):
|
|||||||
metavar='<configuration>',
|
metavar='<configuration>',
|
||||||
default=None,
|
default=None,
|
||||||
help='ID of the configuration group to attach to the instance.')
|
help='ID of the configuration group to attach to the instance.')
|
||||||
@utils.arg('--slave_of',
|
@utils.arg('--replica_of',
|
||||||
metavar='<master_id>',
|
metavar='<source_id>',
|
||||||
default=None,
|
default=None,
|
||||||
help='ID of an existing instance to replicate from.')
|
help='ID of an existing instance to replicate from.')
|
||||||
@utils.service_type('database')
|
@utils.service_type('database')
|
||||||
@@ -356,7 +356,7 @@ def do_create(cs, args):
|
|||||||
datastore_version=args.datastore_version,
|
datastore_version=args.datastore_version,
|
||||||
nics=nics,
|
nics=nics,
|
||||||
configuration=args.configuration,
|
configuration=args.configuration,
|
||||||
slave_of=args.slave_of)
|
replica_of=args.replica_of)
|
||||||
_print_instance(instance)
|
_print_instance(instance)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user