multi-region flag for describe regions

This commit is contained in:
Vishvananda Ishaya
2010-09-10 17:12:49 -07:00
parent 4d5f7c0f1f
commit a4082e45dd
2 changed files with 21 additions and 9 deletions

View File

@@ -174,9 +174,18 @@ class CloudController(object):
@rbac.allow('all')
def describe_regions(self, context, region_name=None, **kwargs):
# TODO(vish): region_name is an array. Support filtering
return {'regionInfo': [{'regionName': 'nova',
'regionUrl': FLAGS.ec2_url}]}
if FLAGS.region_list:
regions = []
for region in FLAGS.region_list:
name, _sep, url = region.partition(',')
regions.append({'regionName': name,
'regionUrl': url})
else:
regions = [{'regionName': 'nova',
'regionUrl': FLAGS.ec2_url}]
if region_name:
regions = [r for r in regions if r['regionName'] in region_name]
return {'regionInfo': regions }
@rbac.allow('all')
def describe_snapshots(self,

View File

@@ -166,6 +166,9 @@ def DECLARE(name, module_string, flag_values=FLAGS):
# Define any app-specific flags in their own files, docs at:
# http://code.google.com/p/python-gflags/source/browse/trunk/gflags.py#39
DEFINE_list('region_list',
[],
'list of region,url pairs')
DEFINE_string('connection_type', 'libvirt', 'libvirt, xenapi or fake')
DEFINE_integer('s3_port', 3333, 's3 port')
DEFINE_string('s3_host', '127.0.0.1', 's3 host')