def post(self):
"""
Creates a network with the name, specified within the request under ['network']['name'].
:return: * 400, if the network already exists.
* 500, if any exception occurred while creation.
* 201, if everything worked out.
:rtype: :class:`flask.response`
"""
LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
network_dict = json.loads(request.data)
name = network_dict['network']['name']
net = self.api.compute.find_network_by_name_or_id(name)
if net is not None:
return Response('Network already exists.\n', status=400, mimetype='application/json')
net = self.api.compute.create_network(name)
return Response(json.dumps({"network": net.create_network_dict()}), status=201, mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Create network excepiton.")
return Response(ex.message, status=500, mimetype='application/json')
评论列表
文章目录