Add kwargs to generic description callback param
Project: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/commit/b7e296dd Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/tree/b7e296dd Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/diff/b7e296dd Branch: refs/heads/master Commit: b7e296dde560872bc17ff1a81d188aa2166cde8f Parents: fbe09a5 Author: BroganD1993 <darrenbro...@hotmail.com> Authored: Tue Jun 17 21:48:32 2014 +0100 Committer: BroganD1993 <darrenbro...@hotmail.com> Committed: Tue Jun 17 21:48:32 2014 +0100 ---------------------------------------------------------------------- gstack/controllers/__init__.py | 15 ++++++++------- gstack/controllers/instances.py | 8 +++++--- 2 files changed, 13 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/b7e296dd/gstack/controllers/__init__.py ---------------------------------------------------------------------- diff --git a/gstack/controllers/__init__.py b/gstack/controllers/__init__.py index a6c7290..5198b53 100644 --- a/gstack/controllers/__init__.py +++ b/gstack/controllers/__init__.py @@ -68,7 +68,7 @@ def _get_item_with_name(authorization, name, args, type): return None -def _get_requested_items(authorization, args, type, to_cloudstack, zone, projectid): +def _get_requested_items(authorization, args, type, to_cloudstack, **kwargs): name = None filter = helpers.get_filter(request.args) @@ -87,7 +87,7 @@ def _get_requested_items(authorization, args, type, to_cloudstack, zone, project if cloudstack_item: items.append( to_cloudstack( - cloudstack_response=cloudstack_item, zone=zone, projectid=projectid + cloudstack_response=cloudstack_item, **kwargs ) ) else: @@ -96,20 +96,21 @@ def _get_requested_items(authorization, args, type, to_cloudstack, zone, project for cloudstack_item in cloudstack_items[type]: items.append( to_cloudstack( - cloudstack_response=cloudstack_item, zone=zone, projectid=projectid) + cloudstack_response=cloudstack_item, **kwargs) ) return items -def describe_items_aggregated(authorization, args, type, gce_type, projectid, to_cloudstack): +def describe_items_aggregated(authorization, args, type, gce_type, to_cloudstack, **kwargs): from gstack.controllers import zones items = {} zone_list = zones.get_zone_names(authorization=authorization) for zone in zone_list: - zone_items = _get_requested_items(authorization, args, type, to_cloudstack, zone, projectid) + kwargs['zone'] = zone + zone_items = _get_requested_items(authorization, args, type, to_cloudstack, **kwargs) items['zone/' + zone] = {} items['zone/' + zone][gce_type] = zone_items @@ -117,7 +118,7 @@ def describe_items_aggregated(authorization, args, type, gce_type, projectid, to return items -def describe_items(authorization, args, type, zone, projectid, to_cloudstack): - items = _get_requested_items(authorization, args, type, to_cloudstack, zone, projectid) +def describe_items(authorization, args, type, to_cloudstack, **kwargs): + items = _get_requested_items(authorization, args, type, to_cloudstack, **kwargs) return items \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/b7e296dd/gstack/controllers/instances.py ---------------------------------------------------------------------- diff --git a/gstack/controllers/instances.py b/gstack/controllers/instances.py index 3caecc1..175bfe9 100755 --- a/gstack/controllers/instances.py +++ b/gstack/controllers/instances.py @@ -105,7 +105,7 @@ def _destroy_virtual_machine(authorization, instance): ) -def _cloudstack_virtual_machine_to_gce(cloudstack_response, zone, projectid): +def _cloudstack_virtual_machine_to_gce(cloudstack_response, projectid, zone, **kwargs): response = {} response['kind'] = 'compute#instance' response['id'] = cloudstack_response['id'] @@ -170,9 +170,10 @@ def _get_virtual_machine_by_name(authorization, instance): @authentication.required def aggregatedlistinstances(authorization, projectid): args = {'command':'listVirtualMachines'} + kwargs = {'projectid':projectid} items = controllers.describe_items_aggregated( authorization, args, 'virtualmachine', 'instances', - projectid, _cloudstack_virtual_machine_to_gce) + _cloudstack_virtual_machine_to_gce, **kwargs) populated_response = { 'kind': 'compute#instanceAggregatedList', @@ -187,9 +188,10 @@ def aggregatedlistinstances(authorization, projectid): @authentication.required def listinstances(authorization, projectid, zone): args = {'command':'listVirtualMachines'} + kwargs = {'projectid':projectid, 'zone':zone} items = controllers.describe_items( authorization, args, 'virtualmachine', - zone, projectid, _cloudstack_virtual_machine_to_gce) + _cloudstack_virtual_machine_to_gce, **kwargs) populated_response = { 'kind': 'compute#instance_list',