Skip to content

Instantly share code, notes, and snippets.

@imduffy15
Created September 19, 2013 22:37
Show Gist options
  • Select an option

  • Save imduffy15/6630820 to your computer and use it in GitHub Desktop.

Select an option

Save imduffy15/6630820 to your computer and use it in GitHub Desktop.
@app.route('/' + app.config['PATH'] + '<projectid>/zones/<zone>/instances', methods=['GET'])
@authentication.required
def listinstances(projectid, authorization, zone):
cloudstack_response = _get_instances(authorization)
items = []
if cloudstack_response['listvirtualmachinesresponse']:
for instance in cloudstack_response['listvirtualmachinesresponse']['virtualmachine']:
items.append(_cloudstack_instance_to_gce(instance))
populated_response = {
'kind': 'compute#instanceList',
'id': 'projects/' + projectid + '/instances',
'selfLink': request.base_url,
'items': items
}
res = jsonify(populated_response)
res.status_code = 200
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment