super(NeutronDummyApi, self).__init__(ip, port)
self.compute = compute
+ # create default networks (OSM usually assumes to have these pre-configured)
+ self.compute.create_network("mgmt")
+ self.compute.create_network("mgmtnet")
+
self.api.add_resource(NeutronListAPIVersions, "/")
self.api.add_resource(NeutronShowAPIv2Details, "/v2.0")
self.api.add_resource(NeutronListNetworks, "/v2.0/networks.json", "/v2.0/networks",
:rtype: :class:`flask.response`
"""
LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ # LOG.debug("ARGS: {}".format(request.args))
try:
if request.args.get('name'):
tmp_network = NeutronShowNetwork(self.api)
- return tmp_network.get_network(request.args.get('name'), True)
+ response = tmp_network.get_network(request.args.get('name'), True)
+ LOG.debug("{} RESPONSE (1): {}".format(self.__class__.__name__, response))
+ return response
id_list = request.args.getlist('id')
if len(id_list) == 1:
tmp_network = NeutronShowNetwork(self.api)
- return tmp_network.get_network(request.args.get('id'), True)
+ response = tmp_network.get_network(request.args.get('id'), True)
+ LOG.debug("{} RESPONSE (2): {}".format(self.__class__.__name__, response))
+ return response
network_list = list()
network_dict = dict()
network_list.append(tmp_network_dict)
network_dict["networks"] = network_list
-
+ LOG.debug("{} RESPONSE (3): {}".format(self.__class__.__name__, network_dict))
return Response(json.dumps(network_dict), status=200, mimetype='application/json')
except Exception as ex:
self.api.compute.delete_network(network_id)
- return Response('Network ' + str(network_id) + ' deleted.\n', status=204, mimetype='application/json')
+ return Response('', status=204, mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Delete network exception.")
return Response(ex.message, status=500, mimetype='application/json')
net.subnet_name = subnet_dict["subnet"].get('name', str(net.name) + '-sub')
if net.subnet_id is not None:
+ LOG.error("Only one subnet per network is supported: {}".format(net.subnet_id))
return Response('Only one subnet per network is supported\n', status=409, mimetype='application/json')
if "id" in subnet_dict["subnet"]:
for server in self.api.compute.computeUnits.values():
for port_name in server.port_names:
port = self.api.compute.find_port_by_name_or_id(port_name)
+ if port is None:
+ LOG.warning("Port search for {} returned None.".format(port_name))
+ continue
if port.net_name == net.name:
port.ip_address = None
self.api.compute.dc.net.removeLink(
net.delete_subnet()
- return Response('Subnet ' + str(subnet_id) + ' deleted.\n',
- status=204, mimetype='application/json')
+ return Response('', status=204, mimetype='application/json')
return Response('Could not find subnet.', status=404, mimetype='application/json')
except Exception as ex:
# delete the port
self.api.compute.delete_port(port.id)
- return Response('Port ' + port_id + ' deleted.\n', status=204, mimetype='application/json')
+ return Response('', status=204, mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Delete port exception.")