from flask_restful import Api, Resource
import logging
+LOG = logging.getLogger("api.openstack.base")
+
class BaseOpenstackDummy(Resource):
"""
self.api = Api(self.app)
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
+ LOG.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
if self.app is not None:
self.app.before_request(self.dump_playbook)
self.app.run(self.ip, self.port, debug=True, use_reloader=False)
import json
+LOG = logging.getLogger("api.openstack.glance")
+
+
class GlanceDummyApi(BaseOpenstackDummy):
def __init__(self, in_ip, in_port, compute):
super(GlanceDummyApi, self).__init__(in_ip, in_port)
resource_class_kwargs={'api': self})
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % ("GlanceDummyApi", self.ip, self.port))
+ LOG.info("Starting %s endpoint @ http://%s:%d" % ("GlanceDummyApi", self.ip, self.port))
if self.app is not None:
self.app.before_request(self.dump_playbook)
self.app.run(self.ip, self.port, debug=True, use_reloader=False)
class Shutdown(Resource):
def get(self):
- logging.debug(("%s is beeing shut down") % (__name__))
+ LOG.debug(("%s is beeing shut down") % (__name__))
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
class GlanceListApiVersions(Resource):
def get(self):
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
resp = dict()
resp['versions'] = dict()
versions = [{
class GlanceSchema(Resource):
def get(self):
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
resp = dict()
resp['name'] = 'someImageName'
resp['properties'] = dict()
self.api = api
def get(self):
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
resp['next'] = None
return Response(json.dumps(resp), status=200, mimetype="application/json")
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of images." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of images." % __name__)
return ex.message, 500
def post(self):
should already be registered with Docker. However, this function returns a reply that looks
like the image was just created to make orchestrators, like OSM, happy.
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
# lets see what we should create
img_name = request.headers.get("X-Image-Meta-Name")
img_size = request.headers.get("X-Image-Meta-Size")
for image in self.api.compute.images.values():
if img_name in image.name:
img_id = image.id
- logging.debug("Image name: %s" % img_name)
- logging.debug("Image id: %s" % img_id)
+ LOG.debug("Image name: %s" % img_name)
+ LOG.debug("Image id: %s" % img_id)
# build a response body that looks like a real one
resp = dict()
f = dict()
self.api = api
def get(self, id):
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
from emuvim.api.heat.openstack_dummies.nova_dummy_api import NovaListImages
nova = NovaListImages(self.api)
return nova.get(id)
def put(self, id):
- logging.debug("API CALL: %s " % str(self.__class__.__name__))
- logging.warning("Endpoint not implemented")
+ LOG.debug("API CALL: %s " % str(self.__class__.__name__))
+ LOG.warning("Endpoint not implemented")
return None
import json
+LOG = logging.getLogger("api.openstack.heat")
+
+
class HeatDummyApi(BaseOpenstackDummy):
def __init__(self, in_ip, in_port, compute):
super(HeatDummyApi, self).__init__(in_ip, in_port)
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
+ LOG.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
if self.app is not None:
self.app.before_request(self.dump_playbook)
self.app.run(self.ip, self.port, debug=True, use_reloader=False)
"""
def get(self):
- logging.debug(("%s is beeing shut down") % (__name__))
+ LOG.debug(("%s is beeing shut down") % (__name__))
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
self.api = api
def get(self):
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
resp = dict()
resp['versions'] = dict()
500, if any exception occurred while creation.
201, if everything worked out.
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
stack_dict = json.loads(request.data)
return Response(json.dumps(return_dict), status=201, mimetype="application/json")
except Exception as ex:
- logging.exception("Heat: Create Stack exception.")
+ LOG.exception("Heat: Create Stack exception.")
return ex.message, 500
def get(self, tenant_id):
500, if any exception occurred.
200, if everything worked out.
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
return_stacks = dict()
return_stacks['stacks'] = list()
return Response(json.dumps(return_stacks), status=200, mimetype="application/json")
except Exception as ex:
- logging.exception("Heat: List Stack exception.")
+ LOG.exception("Heat: List Stack exception.")
return ex.message, 500
500, if any exception occurred.
200, if everything worked out.
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
stack = None
if stack_name_or_id in self.api.compute.stacks:
return Response(json.dumps(return_stack), status=200, mimetype="application/json")
except Exception as ex:
- logging.exception("Heat: Show stack exception.")
+ LOG.exception("Heat: Show stack exception.")
return ex.message, 500
500, if any exception occurred while updating.
202, if everything worked out.
"""
- logging.debug("API CALL: %s PUT" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s PUT" % str(self.__class__.__name__))
try:
old_stack = None
if stack_name_or_id in self.api.compute.stacks:
return Response(status=202, mimetype="application/json")
except Exception as ex:
- logging.exception("Heat: Update Stack exception")
+ LOG.exception("Heat: Update Stack exception")
return ex.message, 500
:return: 500, if any exception occurred while deletion.
204, if everything worked out.
"""
- logging.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
try:
if stack_name_or_id in self.api.compute.stacks:
self.api.compute.delete_stack(stack_name_or_id)
return Response('Deleted Stack: ' + stack_name_or_id, 204)
except Exception as ex:
- logging.exception("Heat: Delete Stack exception")
+ LOG.exception("Heat: Delete Stack exception")
return ex.message, 500
import logging
import json
+LOG = logging.getLogger("api.openstack.keystone")
+
class KeystoneDummyApi(BaseOpenstackDummy):
def __init__(self, in_ip, in_port):
self.api.add_resource(KeystoneGetTokenv3, "/v3/auth/tokens", resource_class_kwargs={'api': self})
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
+ LOG.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
if self.app is not None:
self.app.before_request(self.dump_playbook)
self.app.run(self.ip, self.port, debug=True, use_reloader=False)
"""
def get(self):
- logging.debug(("%s is beeing shut down") % (__name__))
+ LOG.debug(("%s is beeing shut down") % (__name__))
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
:return: Returns the api versions.
:rtype: :class:`flask.response` containing a static json encoded dict.
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
resp = dict()
resp['versions'] = dict()
:return: Returns an openstack style response for all entrypoints.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
neutron_port = self.api.port + 4696
heat_port = self.api.port + 3004
:return: Returns an openstack style response for all entrypoints.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
neutron_port = self.api.port + 4696
heat_port = self.api.port + 3004
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
ret = dict()
req = json.loads(request.data)
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
ret = dict()
req = json.loads(request.data)
import copy
+LOG = logging.getLogger("api.openstack.neutron")
+
+
class NeutronDummyApi(BaseOpenstackDummy):
def __init__(self, ip, port, compute):
super(NeutronDummyApi, self).__init__(ip, port)
resource_class_kwargs={'api': self})
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
+ LOG.info("Starting %s endpoint @ http://%s:%d" % (__name__, self.ip, self.port))
if self.app is not None:
self.app.before_request(self.dump_playbook)
self.app.run(self.ip, self.port, debug=True, use_reloader=False)
class Shutdown(Resource):
def get(self):
- logging.debug(("%s is beeing shut down") % (__name__))
+ LOG.debug(("%s is beeing shut down") % (__name__))
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
:return: Returns a json with API versions.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: Neutron - List API Versions")
+ LOG.debug("API CALL: Neutron - List API Versions")
resp = dict()
resp['versions'] = dict()
:return: Returns a json with API details.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
resp = dict()
resp['resources'] = dict()
:return: Returns a json response, starting with 'networks' as root node.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
if request.args.get('name'):
tmp_network = NeutronShowNetwork(self.api)
return Response(json.dumps(network_dict), status=200, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: List networks exception.")
+ LOG.exception("Neutron: List networks exception.")
return Response(ex.message, status=500, mimetype='application/json')
:return: Returns a json response, starting with 'network' as root node and one network description.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
return self.get_network(network_id, False)
def get_network(self, network_name_or_id, as_list):
* 201, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ 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.create_network(name)
return Response(json.dumps({"network": net.create_network_dict()}), status=201, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Create network excepiton.")
+ LOG.exception("Neutron: Create network excepiton.")
return Response(ex.message, status=500, mimetype='application/json')
* 200, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s PUT" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s PUT" % str(self.__class__.__name__))
try:
if network_id in self.api.compute.nets:
net = self.api.compute.nets[network_id]
return Response('Network not found.\n', status=404, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Show networks exception.")
+ LOG.exception("Neutron: Show networks exception.")
return Response(ex.message, status=500, mimetype='application/json')
* 204, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
try:
if network_id not in self.api.compute.nets:
return Response('Could not find network. (' + network_id + ')\n',
return Response('Network ' + str(network_id) + ' deleted.\n', status=204, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Delete network exception.")
+ LOG.exception("Neutron: Delete network exception.")
return Response(ex.message, status=500, mimetype='application/json')
:return: Returns a json response, starting with 'subnets' as root node.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
if request.args.get('name'):
show_subnet = NeutronShowSubnet(self.api)
return Response(json.dumps(subnet_dict), status=200, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: List subnets exception.")
+ LOG.exception("Neutron: List subnets exception.")
return Response(ex.message, status=500, mimetype='application/json')
:return: Returns a json response, starting with 'subnet' as root node and one subnet description.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
return self.get_subnet(subnet_id, False)
def get_subnet(self, subnet_name_or_id, as_list):
return Response('Subnet not found. (' + subnet_name_or_id + ')\n', status=404, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Show subnet exception.")
+ LOG.exception("Neutron: Show subnet exception.")
return Response(ex.message, status=500, mimetype='application/json')
* 201, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
subnet_dict = json.loads(request.data)
net = self.api.compute.find_network_by_name_or_id(subnet_dict['subnet']['network_id'])
return Response(json.dumps({'subnet': net.create_subnet_dict()}), status=201, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Create network excepiton.")
+ LOG.exception("Neutron: Create network excepiton.")
return Response(ex.message, status=500, mimetype='application/json')
* 200, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s PUT" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s PUT" % str(self.__class__.__name__))
try:
for net in self.api.compute.nets.values():
if net.subnet_id == subnet_id:
return Response('Network not found.\n', status=404, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Show networks exception.")
+ LOG.exception("Neutron: Show networks exception.")
return Response(ex.message, status=500, mimetype='application/json')
* 204, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
try:
for net in self.api.compute.nets.values():
if net.subnet_id == subnet_id:
return Response('Could not find subnet.', status=404, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Delete subnet exception.")
+ LOG.exception("Neutron: Delete subnet exception.")
return Response(ex.message, status=500, mimetype='application/json')
:return: Returns a json response, starting with 'ports' as root node.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
if request.args.get('name'):
show_port = NeutronShowPort(self.api)
return Response(json.dumps(port_dict), status=200, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: List ports exception.")
+ LOG.exception("Neutron: List ports exception.")
return Response(ex.message, status=500, mimetype='application/json')
:return: Returns a json response, starting with 'port' as root node and one network description.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
return self.get_port(port_id, False)
def get_port(self, port_name_or_id, as_list):
tmp_dict["port"] = tmp_port_dict
return Response(json.dumps(tmp_dict), status=200, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Show port exception.")
+ LOG.exception("Neutron: Show port exception.")
return Response(ex.message, status=500, mimetype='application/json')
* 201, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
port_dict = json.loads(request.data)
net_id = port_dict['port']['network_id']
return Response(json.dumps({'port': port.create_port_dict(self.api.compute)}), status=201,
mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Show port exception.")
+ LOG.exception("Neutron: Show port exception.")
return Response(ex.message, status=500, mimetype='application/json')
* 200, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s PUT" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s PUT" % str(self.__class__.__name__))
try:
port_dict = json.loads(request.data)
port = self.api.compute.find_port_by_name_or_id(port_id)
return Response(json.dumps({'port': port.create_port_dict(self.api.compute)}), status=200,
mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Update port exception.")
+ LOG.exception("Neutron: Update port exception.")
return Response(ex.message, status=500, mimetype='application/json')
* 204, if everything worked out.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s DELETE" % str(self.__class__.__name__))
try:
port = self.api.compute.find_port_by_name_or_id(port_id)
if port is None:
return Response('Port ' + port_id + ' deleted.\n', status=204, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Delete port exception.")
+ LOG.exception("Neutron: Delete port exception.")
return Response(ex.message, status=500, mimetype='application/json')
:return: Returns a floating network description.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
# Fiddle with floating_network !
req = json.loads(request.data)
return Response(json.dumps(response), status=200, mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron: Create FloatingIP exception %s.", ex)
+ LOG.exception("Neutron: Create FloatingIP exception %s.", ex)
return Response(ex.message, status=500, mimetype='application/json')
from mininet.link import Link
+LOG = logging.getLogger("api.openstack.nova")
+
+
class NovaDummyApi(BaseOpenstackDummy):
def __init__(self, in_ip, in_port, compute):
super(NovaDummyApi, self).__init__(in_ip, in_port)
resource_class_kwargs={'api': self})
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % ("NovaDummyApi", self.ip, self.port))
+ LOG.info("Starting %s endpoint @ http://%s:%d" % ("NovaDummyApi", self.ip, self.port))
# add some flavors for good measure
self.compute.add_flavor('m1.tiny', 1, 512, "MB", 1, "GB")
self.compute.add_flavor('m1.nano', 1, 64, "MB", 0, "GB")
"""
def get(self):
- logging.debug(("%s is beeing shut doen") % (__name__))
+ LOG.debug(("%s is beeing shut doen") % (__name__))
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
:return: Returns a json with API versions.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = """
{
return response
except Exception as ex:
- logging.exception(u"%s: Could not show list of versions." % __name__)
+ LOG.exception(u"%s: Could not show list of versions." % __name__)
return ex.message, 500
:return: Returns a json with API details.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = """
return response
except Exception as ex:
- logging.exception(u"%s: Could not show list of versions." % __name__)
+ LOG.exception(u"%s: Could not show list of versions." % __name__)
return ex.message, 500
:return: Returns a json response with a dictionary that contains the server information.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of servers." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of servers." % __name__)
return ex.message, 500
def post(self, id):
:return: Returns a flask response, with detailed information about the just created server.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
server_dict = json.loads(request.data)['server']
networks = server_dict.get('networks', None)
return response
except Exception as ex:
- logging.exception(u"%s: Could not create the server." % __name__)
+ LOG.exception(u"%s: Could not create the server." % __name__)
return ex.message, 500
:return: Returns a json response with a dictionary that contains the server information.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of servers." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of servers." % __name__)
return ex.message, 500
:return: Returns a flask response, with detailed information aboit the servers and their flavor and image.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = {"servers": list()}
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of servers." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of servers." % __name__)
return ex.message, 500
:return: Returns a flask response with a list of all flavors.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
resp['flavors'] = list()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of servers." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of servers." % __name__)
return ex.message, 500
def post(self, id):
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
data = json.loads(request.data).get("flavor")
- logging.warning("Create Flavor: %s" % str(data))
+ LOG.warning("Create Flavor: %s" % str(data))
# add to internal dict
f = self.api.compute.add_flavor(
data.get("name"),
:return: Returns a flask response with a list of all flavors with additional information.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
resp['flavors'] = list()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of servers." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of servers." % __name__)
return ex.message, 500
def post(self, id):
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
data = json.loads(request.data).get("flavor")
- logging.warning("Create Flavor: %s" % str(data))
+ LOG.warning("Create Flavor: %s" % str(data))
# add to internal dict
f = self.api.compute.add_flavor(
data.get("name"),
:return: Returns a flask response with detailed information about the flavor.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
resp['flavor'] = dict()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve flavor with id %s" % (__name__, flavorid))
+ LOG.exception(u"%s: Could not retrieve flavor with id %s" % (__name__, flavorid))
return ex.message, 500
:return: Returns a flask response with a list of available images.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
resp['images'] = list()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of images." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of images." % __name__)
return ex.message, 500
:return: Returns a flask response with a list of images and their metadata.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
resp['images'] = list()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the list of images." % __name__)
+ LOG.exception(u"%s: Could not retrieve the list of images." % __name__)
return ex.message, 500
:return: Returns a flask response with the information about one image.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
resp = dict()
i = resp['image'] = dict()
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve image with id %s." % (__name__, imageid))
+ LOG.exception(u"%s: Could not retrieve image with id %s." % (__name__, imageid))
return ex.message, 500
:return: Returns a flask response with details about the server.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
server = self.api.compute.find_server_by_name_or_id(serverid)
if server is None:
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve the server details." % __name__)
+ LOG.exception(u"%s: Could not retrieve the server details." % __name__)
return ex.message, 500
def delete(self, id, serverid):
:return: Returns 200 if everything is fine.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s POST" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
server = self.api.compute.find_server_by_name_or_id(serverid)
if server is None:
return response
except Exception as ex:
- logging.exception(u"%s: Could not create the server." % __name__)
+ LOG.exception(u"%s: Could not create the server." % __name__)
return ex.message, 500
:return: Returns a flask response with information about the attached interface.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
server = self.api.compute.find_server_by_name_or_id(serverid)
if server is None:
return Response("Server with id or name %s does not exists." % serverid, status=404)
if server.emulator_compute is None:
- logging.error("The targeted container does not exist.")
+ LOG.error("The targeted container does not exist.")
return Response("The targeted container of %s does not exist." % serverid, status=404)
data = json.loads(request.data).get("interfaceAttachment")
resp = dict()
return response
except Exception as ex:
- logging.exception(u"%s: Could not add interface to the server." % __name__)
+ LOG.exception(u"%s: Could not add interface to the server." % __name__)
return ex.message, 500
error message.
:rtype: :class:`flask.response`
"""
- logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
+ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
server = self.api.compute.find_server_by_name_or_id(serverid)
if server is None:
return response
except Exception as ex:
- logging.exception(u"%s: Could not detach interface from the server." % __name__)
+ LOG.exception(u"%s: Could not detach interface from the server." % __name__)
return ex.message, 500
import json
from copy import deepcopy
-logging.basicConfig(level=logging.INFO)
+logging.basicConfig()
CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
from flask import request
import json
-logging.basicConfig(level=logging.INFO)
+logging.basicConfig()
CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
return str(c), 200, CORS_HEADER
except Exception as ex:
logging.exception("API error.")
- return ex.message, 500, CORS_HEADER
\ No newline at end of file
+ return ex.message, 500, CORS_HEADER
import json
import networkx
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig()
CORS_HEADER = {'Access-Control-Allow-Origin': '*'}
links.append(edge_dict)
json = {"nodes":nodes, "links":links}
- return json, 200, CORS_HEADER
\ No newline at end of file
+ return json, 200, CORS_HEADER
import pkg_resources
from os import path
-logging.basicConfig(level=logging.INFO)
+logging.basicConfig()
class RestApiEndpoint(object):
import json\r
from copy import deepcopy\r
\r
-logging.basicConfig(level=logging.INFO)\r
+logging.basicConfig()\r
\r
"""\r
class to read openflow stats from the Ryu controller of the DCNetwork\r