in gstack/controllers/networks.py [0:0]
def addnetwork(authorization, projectid):
data = json.loads(request.data)
args = {}
args['name'] = data['name']
args['description'] = data['description']
network_result = _add_network(authorization, args)
if 'errortext' in network_result['createsecuritygroupresponse']:
populated_response = {
'kind': 'compute#operation',
'operationType': 'insert',
'targetLink': '',
'status': 'DONE',
'progress': 100,
'error': {
'errors': [{
'code': 'RESOURCE_ALREADY_EXISTS',
'message': 'The resource \'projects/\'' + projectid + '/global/networks/' + args['name']
}]
}
}
else:
populated_response = {
'kind': 'compute#operation',
'operationType': 'insert',
'targetLink': urllib.unquote_plus(
helpers.get_root_url() + url_for(
'getnetwork',
projectid=projectid,
network=data['name']
)
),
'status': 'DONE',
'progress': 100
}
return helpers.create_response(data=populated_response)