Multi-Region Support

This is an initial attempt at supporting multiple regions.  It should
handle the mechanics of deploying an instance/volume to a remote
region.  Additional changes may be required to allow the guest
agent on the instance to connect back to the originating region.

Co-Authored-By: Doug Shelley <doug@tesora.com>
Depends-On: I386efb2d5c147417af7ea25704405977c9b6bbcd
Change-Id: Ib0b35100c0780dc07c60d20622554ba77c4bc850
This commit is contained in:
Morgan Jones 2016-10-05 11:08:18 -04:00 committed by amrith
parent c4d9ebb66d
commit aed18902d0
4 changed files with 29 additions and 6 deletions

View File

@ -0,0 +1,4 @@
features:
- Adds --region option to create and cluster-create APIs. For now, these
options are excluded from CLI help strings. This is the first step in
multiregion support.

View File

@ -166,6 +166,7 @@ class FakeHTTPClient(base_client.HTTPClient):
"ip": ["10.0.0.13"],
"volume": {"size": 2},
"flavor": {"id": "02"},
"region": "regionOne",
"datastore": {"version": "5.6", "type": "mysql"}},
{
"id": "5678",
@ -174,6 +175,7 @@ class FakeHTTPClient(base_client.HTTPClient):
"ip": ["10.0.0.14"],
"volume": {"size": 2},
"flavor": {"id": "2"},
"region": "regionOne",
"datastore": {"version": "5.6", "type": "mysql"}}]})
def get_instances_1234(self, **kw):

View File

@ -92,7 +92,7 @@ class Instances(base.ManagerWithFind):
restorePoint=None, availability_zone=None, datastore=None,
datastore_version=None, nics=None, configuration=None,
replica_of=None, slave_of=None, replica_count=None,
modules=None, locality=None):
modules=None, locality=None, region_name=None):
"""Create (boot) a new instance."""
body = {"instance": {
@ -134,6 +134,8 @@ class Instances(base.ManagerWithFind):
body["instance"]["modules"] = self._get_module_list(modules)
if locality:
body["instance"]["locality"] = locality
if region_name:
body["instance"]["region_name"] = region_name
return self._create("/instances", body, "instance")

View File

@ -274,7 +274,7 @@ def _print_instances(instances):
setattr(instance, 'datastore', instance.datastore['type'])
utils.print_list(instances, ['id', 'name', 'datastore',
'datastore_version', 'status',
'flavor_id', 'size'])
'flavor_id', 'size', 'region'])
@utils.arg('--limit', metavar='<limit>', type=int, default=None,
@ -526,6 +526,11 @@ def do_update(cs, args):
choices=LOCALITY_DOMAIN,
help=_('Locality policy to use when creating replicas. Choose '
'one of %(choices)s.'))
@utils.arg('--region', metavar='<region>',
type=str,
default=None,
help=argparse.SUPPRESS)
# help=_('Name of region in which to create the instance.'))
@utils.service_type('database')
def do_create(cs, args):
"""Creates a new instance."""
@ -579,7 +584,9 @@ def do_create(cs, args):
configuration=args.configuration,
replica_of=replica_of,
replica_count=replica_count,
modules=modules, locality=locality)
modules=modules,
locality=locality,
region_name=args.region)
_print_instance(instance)
@ -647,6 +654,10 @@ def _get_availability_zone(opts_str):
return _strip_option(opts_str, 'availability_zone', is_required=False)
def _get_region(cs, opts_str):
return _strip_option(opts_str, 'region', is_required=False)
def _get_modules(cs, opts_str):
modules, opts_str = _strip_option(
opts_str, 'module', is_required=False, allow_multiple=True)
@ -756,6 +767,10 @@ def _parse_instance_options(cs, instance_options, for_grow=False):
if name:
instance_info["name"] = name
region, instance_opts = _get_region(cs, instance_opts)
if region:
instance_info["region"] = region
if instance_opts:
raise exceptions.ValidationError(
_("Unknown option(s) '%s' specified for instance")
@ -981,9 +996,9 @@ def do_backup_create(cs, args):
@utils.arg('backup', metavar='<backup>',
help=_('Backup ID of the source backup.'),
default=None)
@utils.arg('--region', metavar='<region>', help=_('Region where the source '
'backup resides.'),
default=None)
@utils.arg('--region', metavar='<region>', default=None,
# help=_('Region where the source backup resides.'))
help=argparse.SUPPRESS)
@utils.arg('--description', metavar='<description>',
default=None,
help=_('An optional description for the backup.'))