Skip to content
Permalink
Browse files
Add kwargs to generic description callback param
  • Loading branch information
brogand93 committed Jun 17, 2014
1 parent fbe09a5 commit b7e296dde560872bc17ff1a81d188aa2166cde8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
@@ -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,28 +96,29 @@ 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

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
@@ -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',

0 comments on commit b7e296d

Please sign in to comment.