Add 'slave_of' option for enabling replication
Add a new create option (--slave_of) that can be used to enable replication and configure the newly created instance as a slave of the specified existing instance. DocImpact Introduces new option when creating an instance. partially Implements: blueprint replication-v1 Change-Id: Idf22d3d9e676138969cbdf3afd4903b8e475c313
This commit is contained in:
parent
a48272cb2d
commit
258b47b2a0
|
@ -45,7 +45,8 @@ 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):
|
||||
datastore_version=None, nics=None, configuration=None,
|
||||
slave_of=None):
|
||||
"""Create (boot) a new instance."""
|
||||
body = {"instance": {
|
||||
"name": name,
|
||||
|
@ -72,6 +73,8 @@ class Instances(base.ManagerWithFind):
|
|||
body["instance"]["nics"] = nics
|
||||
if configuration:
|
||||
body["instance"]["configuration"] = configuration
|
||||
if slave_of:
|
||||
body["instance"]["slave_of"] = slave_of
|
||||
|
||||
return self._create("/instances", body, "instance")
|
||||
|
||||
|
|
|
@ -218,6 +218,10 @@ 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>',
|
||||
default=None,
|
||||
help='ID of an existing instance to replicate from.')
|
||||
@utils.service_type('database')
|
||||
def do_create(cs, args):
|
||||
"""Creates a new instance."""
|
||||
|
@ -251,7 +255,8 @@ def do_create(cs, args):
|
|||
datastore=args.datastore,
|
||||
datastore_version=args.datastore_version,
|
||||
nics=nics,
|
||||
configuration=args.configuration)
|
||||
configuration=args.configuration,
|
||||
slave_of=args.slave_of)
|
||||
if hasattr(instance, 'configuration'):
|
||||
instance._info['configuration'] = instance.configuration['id']
|
||||
instance._info['flavor'] = instance.flavor['id']
|
||||
|
|
Loading…
Reference in New Issue