Replication V2
The V2 implentation of replication, including: - promote-to-replica-source - eject-replica-source Implements: blueprint replication-v2 Change-Id: I9075365a8fae754e29d27d6e371a1d8c8980e26b Authored-By: Morgan Jones <morgan@parelastic.com> Co-Authored-By: Peter Stachowski <peter@tesora.com>
This commit is contained in:
parent
6991168726
commit
a36ebe539c
|
@ -51,7 +51,7 @@ class Instances(base.ManagerWithFind):
|
|||
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,
|
||||
replica_of=None, slave_of=None):
|
||||
replica_of=None, slave_of=None, replica_count=None):
|
||||
"""Create (boot) a new instance."""
|
||||
|
||||
body = {"instance": {
|
||||
|
@ -81,6 +81,8 @@ class Instances(base.ManagerWithFind):
|
|||
body["instance"]["configuration"] = configuration
|
||||
if replica_of or slave_of:
|
||||
body["instance"]["replica_of"] = base.getid(replica_of) or slave_of
|
||||
if replica_count:
|
||||
body["instance"]["replica_count"] = replica_count
|
||||
|
||||
return self._create("/instances", body, "instance")
|
||||
|
||||
|
@ -189,6 +191,24 @@ class Instances(base.ManagerWithFind):
|
|||
return self._get("/instances/%s/configuration" % base.getid(instance),
|
||||
"instance")
|
||||
|
||||
def promote_to_replica_source(self, instance):
|
||||
"""Promote a replica to be the new replica_source of its set
|
||||
|
||||
:param instance: The :class:`Instance` (or its ID) of the database
|
||||
instance to promote.
|
||||
"""
|
||||
body = {'promote_to_replica_source': {}}
|
||||
self._action(instance, body)
|
||||
|
||||
def eject_replica_source(self, instance):
|
||||
"""Eject a replica source from its set
|
||||
|
||||
:param instance: The :class:`Instance` (or its ID) of the database
|
||||
instance to eject.
|
||||
"""
|
||||
body = {'eject_replica_source': {}}
|
||||
self._action(instance, body)
|
||||
|
||||
|
||||
class InstanceStatus(object):
|
||||
|
||||
|
@ -200,3 +220,5 @@ class InstanceStatus(object):
|
|||
RESIZE = "RESIZE"
|
||||
SHUTDOWN = "SHUTDOWN"
|
||||
RESTART_REQUIRED = "RESTART_REQUIRED"
|
||||
PROMOTING = "PROMOTING"
|
||||
EJECTING = "EJECTING"
|
||||
|
|
|
@ -354,6 +354,11 @@ def do_update(cs, args):
|
|||
metavar='<source_instance>',
|
||||
default=None,
|
||||
help='ID or name of an existing instance to replicate from.')
|
||||
@utils.arg('--replica_count',
|
||||
metavar='<count>',
|
||||
type=int,
|
||||
default=1,
|
||||
help='Number of replicas to create (defaults to 1).')
|
||||
@utils.service_type('database')
|
||||
def do_create(cs, args):
|
||||
"""Creates a new instance."""
|
||||
|
@ -380,6 +385,7 @@ def do_create(cs, args):
|
|||
"(but not both) specified." % nic_str)
|
||||
raise exceptions.CommandError(err_msg)
|
||||
nics.append(nic_info)
|
||||
|
||||
instance = cs.instances.create(args.name,
|
||||
args.flavor_id,
|
||||
volume=volume,
|
||||
|
@ -391,7 +397,8 @@ def do_create(cs, args):
|
|||
datastore_version=args.datastore_version,
|
||||
nics=nics,
|
||||
configuration=args.configuration,
|
||||
replica_of=replica_of_instance)
|
||||
replica_of=replica_of_instance,
|
||||
replica_count=args.replica_count)
|
||||
_print_instance(instance)
|
||||
|
||||
|
||||
|
@ -498,6 +505,8 @@ def do_restart(cs, args):
|
|||
instance = _find_instance(cs, args.instance)
|
||||
cs.instances.restart(instance)
|
||||
|
||||
# Replication related commands
|
||||
|
||||
|
||||
@utils.arg('instance',
|
||||
metavar='<instance>',
|
||||
|
@ -508,6 +517,26 @@ def do_detach_replica(cs, args):
|
|||
instance = _find_instance(cs, args.instance)
|
||||
cs.instances.edit(instance, detach_replica_source=True)
|
||||
|
||||
|
||||
@utils.arg('instance',
|
||||
metavar='<instance>',
|
||||
type=str,
|
||||
help='ID or name of the instance.')
|
||||
def do_promote_to_replica_source(cs, args):
|
||||
"""Promotes a replica to be the new replica source of its set."""
|
||||
instance = _find_instance(cs, args.instance)
|
||||
cs.instances.promote_to_replica_source(instance)
|
||||
|
||||
|
||||
@utils.arg('instance',
|
||||
metavar='<instance>',
|
||||
type=str,
|
||||
help='ID or name of the instance.')
|
||||
def do_eject_replica_source(cs, args):
|
||||
"""Ejects a replica source from its set."""
|
||||
instance = _find_instance(cs, args.instance)
|
||||
cs.instances.eject_replica_source(instance)
|
||||
|
||||
# Backup related commands
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue