Refactoring: Made complete codebase PEP8 compatible.
Only PEP8 rule E501 (line too long) is not yet reflected
by this change.
The patch also adds automated code style checks to the
CI test stage using flake8.
It will let the tests fail if there is a code style
violation.
Change-Id: I90956dd424a46691546ef720351757d3c43451a7
Signed-off-by: peusterm <manuel.peuster@uni-paderborn.de>
diff --git a/src/emuvim/api/openstack/__init__.py b/src/emuvim/api/openstack/__init__.py
index 9979159..d888119 100755
--- a/src/emuvim/api/openstack/__init__.py
+++ b/src/emuvim/api/openstack/__init__.py
@@ -1,27 +1,25 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
diff --git a/src/emuvim/api/openstack/chain_api.py b/src/emuvim/api/openstack/chain_api.py
index 20258bb..47af63c 100755
--- a/src/emuvim/api/openstack/chain_api.py
+++ b/src/emuvim/api/openstack/chain_api.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import json
import logging
import copy
@@ -34,8 +32,6 @@
from flask import Flask
from flask import Response, request
from flask_restful import Api, Resource
-from mininet.link import Link
-import uuid
class ChainApi(Resource):
@@ -77,7 +73,8 @@
return response
def _start_flask(self):
- logging.info("Starting %s endpoint @ http://%s:%d" % ("ChainDummyApi", self.ip, self.port))
+ logging.info("Starting %s endpoint @ http://%s:%d" %
+ ("ChainDummyApi", 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)
@@ -88,8 +85,8 @@
if len(request.data) > 0:
data = "# CHAIN API\n"
data += "curl -X {type} -H \"Content-type: application/json\" -d '{data}' {url}".format(type=request.method,
- data=request.data,
- url=request.url)
+ data=request.data,
+ url=request.url)
logfile.write(data + "\n")
@@ -139,7 +136,8 @@
return Response(resp, status=200, mimetype="application/json")
except Exception as ex:
- logging.exception(u"%s: Could not show list of versions." % __name__)
+ logging.exception(
+ u"%s: Could not show list of versions." % __name__)
return ex.message, 500
@@ -162,10 +160,12 @@
for chain in self.api.manage.full_chain_data.values():
resp["chains"].append(chain)
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
except Exception as ex:
- logging.exception(u"%s: Could not list all network chains." % __name__)
+ logging.exception(
+ u"%s: Could not list all network chains." % __name__)
return ex.message, 500
@@ -188,10 +188,12 @@
for lb in self.api.manage.full_lb_data.values():
resp["loadbalancers"].append(lb)
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
except Exception as ex:
- logging.exception(u"%s: Could not list all live loadbalancers." % __name__)
+ logging.exception(
+ u"%s: Could not list all live loadbalancers." % __name__)
return ex.message, 500
@@ -271,11 +273,14 @@
vnf_dst_interface=dst_intfs, bidirectional=True,
path=path, layer2=layer2)
resp = {'cookie': cookie}
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
except Exception as e:
- logging.exception(u"%s: Error setting up the chain.\n %s" % (__name__, e))
- return Response(u"Error setting up the chain", status=500, mimetype="application/json")
+ logging.exception(
+ u"%s: Error setting up the chain.\n %s" % (__name__, e))
+ return Response(u"Error setting up the chain",
+ status=500, mimetype="application/json")
def delete(self, src_vnf, src_intfs, dst_vnf, dst_intfs):
"""
@@ -307,10 +312,13 @@
try:
cookie = self.api.manage.network_action_stop(src_vnf, dst_vnf, vnf_src_interface=src_intfs,
vnf_dst_interface=dst_intfs, bidirectional=True)
- return Response(json.dumps(cookie), status=200, mimetype="application/json")
+ return Response(json.dumps(cookie), status=200,
+ mimetype="application/json")
except Exception as e:
- logging.exception(u"%s: Error deleting the chain.\n %s" % (__name__, e))
- return Response(u"Error deleting the chain", status=500, mimetype="application/json")
+ logging.exception(
+ u"%s: Error deleting the chain.\n %s" % (__name__, e))
+ return Response(u"Error deleting the chain",
+ status=500, mimetype="application/json")
class ChainVnfDcStackInterfaces(Resource):
@@ -322,7 +330,8 @@
def __init__(self, api):
self.api = api
- def put(self, src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs):
+ def put(self, src_dc, src_stack, src_vnf, src_intfs,
+ dst_dc, dst_stack, dst_vnf, dst_intfs):
"""
A PUT request to "/v1/chain/<src_dc>/<src_stack>/<src_vnf>/<src_intfs>/<dst_dc>/<dst_stack>/<dst_vnf>/<dst_intfs>"
will set up chain.
@@ -352,18 +361,21 @@
"""
# search for real names
- real_names = self._findNames(src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
- if type(real_names) is not tuple:
+ real_names = self._findNames(
+ src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
+ if not isinstance(real_names, tuple):
# something went wrong
return real_names
container_src, container_dst, interface_src, interface_dst = real_names
# check if both VNFs exist
- if not self.api.manage.check_vnf_intf_pair(container_src, interface_src):
+ if not self.api.manage.check_vnf_intf_pair(
+ container_src, interface_src):
return Response(u"VNF %s or intfs %s does not exist" % (container_src, interface_src), status=501,
mimetype="application/json")
- if not self.api.manage.check_vnf_intf_pair(container_dst, interface_dst):
+ if not self.api.manage.check_vnf_intf_pair(
+ container_dst, interface_dst):
return Response(u"VNF %s or intfs %s does not exist" % (container_dst, interface_dst), status=501,
mimetype="application/json")
@@ -372,13 +384,17 @@
vnf_dst_interface=interface_dst, bidirectional=True,
layer2=True)
resp = {'cookie': cookie}
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
except Exception as e:
- logging.exception(u"%s: Error setting up the chain.\n %s" % (__name__, e))
- return Response(u"Error setting up the chain", status=500, mimetype="application/json")
+ logging.exception(
+ u"%s: Error setting up the chain.\n %s" % (__name__, e))
+ return Response(u"Error setting up the chain",
+ status=500, mimetype="application/json")
- def post(self, src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs):
+ def post(self, src_dc, src_stack, src_vnf, src_intfs,
+ dst_dc, dst_stack, dst_vnf, dst_intfs):
"""
A post request to "/v1/chain/<src_dc>/<src_stack>/<src_vnf>/<src_intfs>/<dst_dc>/<dst_stack>/<dst_vnf>/<dst_intfs>"
will create a chain between two interfaces at the specified vnfs.
@@ -410,8 +426,9 @@
layer2 = True
# search for real names
- real_names = self._findNames(src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
- if type(real_names) is not tuple:
+ real_names = self._findNames(
+ src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
+ if not isinstance(real_names, tuple):
# something went wrong
return real_names
@@ -422,13 +439,17 @@
vnf_dst_interface=interface_dst, bidirectional=True,
path=path, layer2=layer2)
resp = {'cookie': cookie}
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
except Exception as e:
- logging.exception(u"%s: Error setting up the chain.\n %s" % (__name__, e))
- return Response(u"Error setting up the chain", status=500, mimetype="application/json")
+ logging.exception(
+ u"%s: Error setting up the chain.\n %s" % (__name__, e))
+ return Response(u"Error setting up the chain",
+ status=500, mimetype="application/json")
- def delete(self, src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs):
+ def delete(self, src_dc, src_stack, src_vnf, src_intfs,
+ dst_dc, dst_stack, dst_vnf, dst_intfs):
"""
A DELETE request to "/v1/chain/<src_dc>/<src_stack>/<src_vnf>/<src_intfs>/<dst_dc>/<dst_stack>/<dst_vnf>/<dst_intfs>"
will delete a previously created chain.
@@ -456,8 +477,9 @@
"""
# search for real names
- real_names = self._findNames(src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
- if type(real_names) is not tuple:
+ real_names = self._findNames(
+ src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs)
+ if not isinstance(real_names, tuple):
# something went wrong, real_names is a Response object
return real_names
@@ -466,17 +488,22 @@
try:
cookie = self.api.manage.network_action_stop(container_src, container_dst, vnf_src_interface=interface_src,
vnf_dst_interface=interface_dst, bidirectional=True)
- return Response(json.dumps(cookie), status=200, mimetype="application/json")
+ return Response(json.dumps(cookie), status=200,
+ mimetype="application/json")
except Exception as e:
- logging.exception(u"%s: Error deleting the chain.\n %s" % (__name__, e))
- return Response(u"Error deleting the chain", status=500, mimetype="application/json")
+ logging.exception(
+ u"%s: Error deleting the chain.\n %s" % (__name__, e))
+ return Response(u"Error deleting the chain",
+ status=500, mimetype="application/json")
# Tries to find real container and interface names according to heat template names
# Returns a tuple of 4 or a Response object
- def _findNames(self, src_dc, src_stack, src_vnf, src_intfs, dst_dc, dst_stack, dst_vnf, dst_intfs):
+ def _findNames(self, src_dc, src_stack, src_vnf, src_intfs,
+ dst_dc, dst_stack, dst_vnf, dst_intfs):
# search for datacenters
if src_dc not in self.api.manage.net.dcs or dst_dc not in self.api.manage.net.dcs:
- return Response(u"At least one DC does not exist", status=500, mimetype="application/json")
+ return Response(u"At least one DC does not exist",
+ status=500, mimetype="application/json")
dc_src = self.api.manage.net.dcs[src_dc]
dc_dst = self.api.manage.net.dcs[dst_dc]
# search for related OpenStackAPIs
@@ -489,7 +516,8 @@
if api.compute.dc == dc_dst:
api_dst = api
if api_src is None or api_dst is None:
- return Response(u"At least one OpenStackAPI does not exist", status=500, mimetype="application/json")
+ return Response(u"At least one OpenStackAPI does not exist",
+ status=500, mimetype="application/json")
# search for stacks
stack_src = None
stack_dst = None
@@ -500,7 +528,8 @@
if stack.stack_name == dst_stack:
stack_dst = stack
if stack_src is None or stack_dst is None:
- return Response(u"At least one Stack does not exist", status=500, mimetype="application/json")
+ return Response(u"At least one Stack does not exist",
+ status=500, mimetype="application/json")
# search for servers
server_src = None
server_dst = None
@@ -513,7 +542,8 @@
server_dst = server
break
if server_src is None or server_dst is None:
- return Response(u"At least one VNF does not exist", status=500, mimetype="application/json")
+ return Response(u"At least one VNF does not exist",
+ status=500, mimetype="application/json")
container_src = server_src.name
container_dst = server_dst.name
@@ -526,7 +556,8 @@
if dst_intfs in server_dst.port_names:
port_dst = stack_dst.ports[dst_intfs]
if port_src is None or port_dst is None:
- return Response(u"At least one Port does not exist", status=500, mimetype="application/json")
+ return Response(u"At least one Port does not exist",
+ status=500, mimetype="application/json")
interface_src = port_src.intf_name
interface_dst = port_dst.intf_name
@@ -576,8 +607,9 @@
# check src vnf/port
if src_stack != "floating":
- real_src = self._findName(src_dc, src_stack, vnf_src_name, vnf_src_interface)
- if type(real_src) is not tuple:
+ real_src = self._findName(
+ src_dc, src_stack, vnf_src_name, vnf_src_interface)
+ if not isinstance(real_src, tuple):
# something went wrong, real_src is a Response object
return real_src
@@ -590,20 +622,24 @@
dst_server = dst_vnf.get('server', None)
dst_port = dst_vnf.get('port', None)
if dst_dc is not None and dst_stack is not None and dst_server is not None and dst_port is not None:
- real_dst = self._findName(dst_dc, dst_stack, dst_server, dst_port)
- if type(real_dst) is not tuple:
+ real_dst = self._findName(
+ dst_dc, dst_stack, dst_server, dst_port)
+ if not isinstance(real_dst, tuple):
# something went wrong, real_dst is a Response object
return real_dst
real_dst_dict[real_dst[0]] = real_dst[1]
- input_object = {"dst_vnf_interfaces": real_dst_dict, "path": req.get("path", None)}
+ input_object = {"dst_vnf_interfaces": real_dst_dict,
+ "path": req.get("path", None)}
if src_stack != "floating":
- self.api.manage.add_loadbalancer(container_src, interface_src, lb_data=input_object)
+ self.api.manage.add_loadbalancer(
+ container_src, interface_src, lb_data=input_object)
return Response(u"Loadbalancer set up at %s:%s" % (container_src, interface_src),
status=200, mimetype="application/json")
else:
- cookie, floating_ip = self.api.manage.add_floating_lb(src_dc, lb_data=input_object)
+ cookie, floating_ip = self.api.manage.add_floating_lb(
+ src_dc, lb_data=input_object)
return Response(json.dumps({"cookie": "%d" % cookie, "floating_ip": "%s" % floating_ip}),
status=200, mimetype="application/json")
@@ -612,7 +648,8 @@
logging.exception(u"%s: Error setting up the loadbalancer at %s %s %s:%s.\n %s" %
(__name__, src_dc, src_stack, vnf_src_name, vnf_src_interface, e))
return Response(u"%s: Error setting up the loadbalancer at %s %s %s:%s.\n %s" %
- (__name__, src_dc, src_stack, vnf_src_name, vnf_src_interface, e), status=500,
+ (__name__, src_dc, src_stack, vnf_src_name,
+ vnf_src_interface, e), status=500,
mimetype="application/json")
def delete(self, src_dc, src_stack, vnf_src_name, vnf_src_interface):
@@ -634,14 +671,16 @@
try:
# check src vnf/port
if src_stack != "floating":
- real_src = self._findName(src_dc, src_stack, vnf_src_name, vnf_src_interface)
- if type(real_src) is not tuple:
+ real_src = self._findName(
+ src_dc, src_stack, vnf_src_name, vnf_src_interface)
+ if not isinstance(real_src, tuple):
# something went wrong, real_src is a Response object
return real_src
container_src, interface_src = real_src
- self.api.manage.delete_loadbalancer(container_src, interface_src)
+ self.api.manage.delete_loadbalancer(
+ container_src, interface_src)
return Response(u"Loadbalancer deleted at %s:%s" % (vnf_src_name, vnf_src_interface),
status=200, mimetype="application/json")
else:
@@ -654,7 +693,8 @@
logging.exception(u"%s: Error deleting the loadbalancer at %s %s %s%s.\n %s" %
(__name__, src_dc, src_stack, vnf_src_name, vnf_src_interface, e))
return Response(u"%s: Error deleting the loadbalancer at %s %s %s%s." %
- (__name__, src_dc, src_stack, vnf_src_name, vnf_src_interface), status=500,
+ (__name__, src_dc, src_stack, vnf_src_name,
+ vnf_src_interface), status=500,
mimetype="application/json")
# Tries to find real container and port name according to heat template names
@@ -662,7 +702,8 @@
def _findName(self, dc, stack, vnf, port):
# search for datacenters
if dc not in self.api.manage.net.dcs:
- return Response(u"DC does not exist", status=500, mimetype="application/json")
+ return Response(u"DC does not exist", status=500,
+ mimetype="application/json")
dc_real = self.api.manage.net.dcs[dc]
# search for related OpenStackAPIs
api_real = None
@@ -671,14 +712,16 @@
if api.compute.dc == dc_real:
api_real = api
if api_real is None:
- return Response(u"OpenStackAPI does not exist", status=500, mimetype="application/json")
+ return Response(u"OpenStackAPI does not exist",
+ status=500, mimetype="application/json")
# search for stacks
stack_real = None
for stackObj in api_real.compute.stacks.values():
if stackObj.stack_name == stack:
stack_real = stackObj
if stack_real is None:
- return Response(u"Stack does not exist", status=500, mimetype="application/json")
+ return Response(u"Stack does not exist", status=500,
+ mimetype="application/json")
# search for servers
server_real = None
for server in stack_real.servers.values():
@@ -686,7 +729,8 @@
server_real = server
break
if server_real is None:
- return Response(u"VNF does not exist", status=500, mimetype="application/json")
+ return Response(u"VNF does not exist", status=500,
+ mimetype="application/json")
container_real = server_real.name
@@ -695,7 +739,8 @@
if port in server_real.port_names:
port_real = stack_real.ports[port]
if port_real is None:
- return Response(u"At least one Port does not exist", status=500, mimetype="application/json")
+ return Response(u"At least one Port does not exist",
+ status=500, mimetype="application/json")
interface_real = port_real.intf_name
@@ -733,16 +778,19 @@
if vnf_src_name != "floating":
# check if VNF exist
- if not self.api.manage.check_vnf_intf_pair(vnf_src_name, vnf_src_interface):
+ if not self.api.manage.check_vnf_intf_pair(
+ vnf_src_name, vnf_src_interface):
return Response(u"VNF %s or intfs %s does not exist" % (vnf_src_name, vnf_src_interface),
status=501,
mimetype="application/json")
- self.api.manage.add_loadbalancer(vnf_src_name, vnf_src_interface, lb_data=req)
+ self.api.manage.add_loadbalancer(
+ vnf_src_name, vnf_src_interface, lb_data=req)
return Response(u"Loadbalancer set up at %s:%s" % (vnf_src_name, vnf_src_interface),
status=200, mimetype="application/json")
else:
- cookie, floating_ip = self.api.manage.add_floating_lb(vnf_src_interface, lb_data=req)
+ cookie, floating_ip = self.api.manage.add_floating_lb(
+ vnf_src_interface, lb_data=req)
return Response(json.dumps({"cookie": "%d" % cookie, "floating_ip": "%s" % floating_ip}),
status=200, mimetype="application/json")
@@ -766,11 +814,13 @@
"""
# check if VNF exist
- if not self.api.manage.check_vnf_intf_pair(vnf_src_name, vnf_src_interface):
+ if not self.api.manage.check_vnf_intf_pair(
+ vnf_src_name, vnf_src_interface):
return Response(u"VNF %s or intfs %s does not exist" % (vnf_src_name, vnf_src_interface), status=501,
mimetype="application/json")
try:
- logging.debug("Deleting loadbalancer at %s: interface: %s" % (vnf_src_name, vnf_src_interface))
+ logging.debug("Deleting loadbalancer at %s: interface: %s" %
+ (vnf_src_name, vnf_src_interface))
net = self.api.manage.net
if vnf_src_name != "floating":
@@ -779,7 +829,8 @@
return Response(u"Source VNF or interface can not be found." % vnf_src_name,
status=404, mimetype="application/json")
- self.api.manage.delete_loadbalancer(vnf_src_name, vnf_src_interface)
+ self.api.manage.delete_loadbalancer(
+ vnf_src_name, vnf_src_interface)
return Response(u"Loadbalancer deleted at %s:%s" % (vnf_src_name, vnf_src_interface),
status=200, mimetype="application/json")
@@ -848,7 +899,8 @@
# with their unique keys
link = copy.copy(data)
for edge in link:
- # do not add any links to the floating switch to the topology!
+ # do not add any links to the floating switch
+ # to the topology!
if graph_node == "fs1":
continue
# the translator wants everything as a string!
diff --git a/src/emuvim/api/openstack/compute.py b/src/emuvim/api/openstack/compute.py
index b812953..6fc4c1b 100755
--- a/src/emuvim/api/openstack/compute.py
+++ b/src/emuvim/api/openstack/compute.py
@@ -1,33 +1,40 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from mininet.link import Link
-from resources import *
+from resources.instance_flavor import InstanceFlavor
+from resources.net import Net
+from resources.port import Port
+from resources.port_pair import PortPair
+from resources.port_pair_group import PortPairGroup
+from resources.flow_classifier import FlowClassifier
+from resources.port_chain import PortChain
+from resources.server import Server
+from resources.image import Image
+
from docker import DockerClient
import logging
import threading
@@ -89,7 +96,8 @@
for image in self.dcli.images.list():
if len(image.tags) > 0:
for t in image.tags:
- t = t.replace(":latest", "") # only use short tag names for OSM compatibility
+ # only use short tag names for OSM compatibility
+ t = t.replace(":latest", "")
if t not in self._images:
self._images[t] = Image(t)
return self._images
@@ -103,7 +111,8 @@
"""
if not self.check_stack(stack):
self.clean_broken_stack(stack)
- raise HeatApiStackInvalidException("Stack did not pass validity checks")
+ raise HeatApiStackInvalidException(
+ "Stack did not pass validity checks")
self.stacks[stack.id] = stack
def clean_broken_stack(self, stack):
@@ -132,7 +141,7 @@
for port_name in server.port_names:
if port_name not in stack.ports:
LOG.warning("Server %s of stack %s has a port named %s that is not known." %
- (server.name, stack.stack_name, port_name))
+ (server.name, stack.stack_name, port_name))
everything_ok = False
if server.image is None:
LOG.warning("Server %s holds no image." % (server.name))
@@ -143,7 +152,7 @@
for port in stack.ports.values():
if port.net_name not in stack.nets:
LOG.warning("Port %s of stack %s has a network named %s that is not known." %
- (port.name, stack.stack_name, port.net_name))
+ (port.name, stack.stack_name, port.net_name))
everything_ok = False
if port.intf_name is None:
LOG.warning("Port %s has no interface name." % (port.name))
@@ -160,11 +169,12 @@
break
if not found:
LOG.warning("Router %s of stack %s has a network named %s that is not known." %
- (router.name, stack.stack_name, subnet_name))
+ (router.name, stack.stack_name, subnet_name))
everything_ok = False
return everything_ok
- def add_flavor(self, name, cpu, memory, memory_unit, storage, storage_unit):
+ def add_flavor(self, name, cpu, memory,
+ memory_unit, storage, storage_unit):
"""
Adds a flavor to the stack.
@@ -181,7 +191,8 @@
:param storage_unit:
:type storage_unit: ``str``
"""
- flavor = InstanceFlavor(name, cpu, memory, memory_unit, storage, storage_unit)
+ flavor = InstanceFlavor(
+ name, cpu, memory, memory_unit, storage, storage_unit)
self.flavors[flavor.name] = flavor
return flavor
@@ -244,7 +255,8 @@
* *False*: else
:rtype: ``bool``
"""
- LOG.debug("updating stack {} with new_stack {}".format(old_stack_id, new_stack))
+ LOG.debug("updating stack {} with new_stack {}".format(
+ old_stack_id, new_stack))
if old_stack_id not in self.stacks:
return False
old_stack = self.stacks[old_stack_id]
@@ -281,24 +293,26 @@
# Remove unnecessary networks
for net in old_stack.nets.values():
- if not net.name in new_stack.nets:
+ if net.name not in new_stack.nets:
self.delete_network(net.id)
# Remove all unnecessary servers
for server in old_stack.servers.values():
if server.name in new_stack.servers:
- if not server.compare_attributes(new_stack.servers[server.name]):
+ if not server.compare_attributes(
+ new_stack.servers[server.name]):
self.stop_compute(server)
else:
# Delete unused and changed links
for port_name in server.port_names:
if port_name in old_stack.ports and port_name in new_stack.ports:
- if not old_stack.ports.get(port_name) == new_stack.ports.get(port_name):
+ if not old_stack.ports.get(
+ port_name) == new_stack.ports.get(port_name):
my_links = self.dc.net.links
for link in my_links:
if str(link.intf1) == old_stack.ports[port_name].intf_name and \
- str(link.intf1.ip) == \
- old_stack.ports[port_name].ip_address.split('/')[0]:
+ str(link.intf1.ip) == \
+ old_stack.ports[port_name].ip_address.split('/')[0]:
self._remove_link(server.name, link)
# Add changed link
@@ -367,15 +381,18 @@
if port.compare_attributes(old_port):
for net in new_stack.nets.values():
if net.name == port.net_name:
- if net.assign_ip_address(old_port.ip_address, port.name):
+ if net.assign_ip_address(
+ old_port.ip_address, port.name):
port.ip_address = old_port.ip_address
port.mac_address = old_port.mac_address
else:
- port.ip_address = net.get_new_ip_address(port.name)
+ port.ip_address = net.get_new_ip_address(
+ port.name)
for port in new_stack.ports.values():
for net in new_stack.nets.values():
- if port.net_name == net.name and not net.is_my_ip(port.ip_address, port.name):
+ if port.net_name == net.name and not net.is_my_ip(
+ port.ip_address, port.name):
port.ip_address = net.get_new_ip_address(port.name)
def update_subnet_cidr(self, old_stack, new_stack):
@@ -446,7 +463,8 @@
if port is not None:
network_dict['id'] = port.intf_name
network_dict['ip'] = port.ip_address
- network_dict[network_dict['id']] = self.find_network_by_name_or_id(port.net_name).name
+ network_dict[network_dict['id']] = self.find_network_by_name_or_id(
+ port.net_name).name
network.append(network_dict)
# default network dict
if len(network) < 1:
@@ -481,7 +499,8 @@
if "SON_EMU_CMD=" in env_var:
cmd = str(env_var.split("=")[1])
server.son_emu_command = cmd
- # execute command in new thread to ensure that GK is not blocked by VNF
+ # execute command in new thread to ensure that GK is not
+ # blocked by VNF
t = threading.Thread(target=c.cmdPrint, args=(cmd,))
t.daemon = True
t.start()
@@ -493,7 +512,8 @@
:param server: The server that should be removed
:type server: ``heat.resources.server``
"""
- LOG.debug("Stopping container %s with full name %s" % (server.name, server.full_name))
+ LOG.debug("Stopping container %s with full name %s" %
+ (server.name, server.full_name))
link_names = list()
for port_name in server.port_names:
prt = self.find_port_by_name_or_id(port_name)
@@ -502,7 +522,8 @@
my_links = self.dc.net.links
for link in my_links:
if str(link.intf1) in link_names:
- # Remove all self created links that connect the server to the main switch
+ # Remove all self created links that connect the server to the
+ # main switch
self._remove_link(server.name, link)
# Stop the server and the remaining connection to the datacenter switch
@@ -528,11 +549,13 @@
return self.computeUnits[name_or_id]
for server in self.computeUnits.values():
- if server.name == name_or_id or server.template_name == name_or_id or server.full_name == name_or_id:
+ if (server.name == name_or_id or
+ server.template_name == name_or_id or
+ server.full_name == name_or_id):
return server
- if (server.name == self._shorten_server_name(name_or_id)
- or server.template_name == self._shorten_server_name(name_or_id)
- or server.full_name == self._shorten_server_name(name_or_id)):
+ if (server.name == self._shorten_server_name(name_or_id) or
+ server.template_name == self._shorten_server_name(name_or_id) or
+ server.full_name == self._shorten_server_name(name_or_id)):
return server
return None
@@ -548,7 +571,8 @@
:return: Returns the created server.
:rtype: :class:`heat.resources.server`
"""
- if self.find_server_by_name_or_id(name) is not None and not stack_operation:
+ if self.find_server_by_name_or_id(
+ name) is not None and not stack_operation:
raise Exception("Server with name %s already exists." % name)
safe_name = self._shorten_server_name(name)
server = Server(safe_name)
@@ -570,7 +594,6 @@
LOG.info("Short server name: {}".format(h))
return name
-
def delete_server(self, server):
"""
Deletes the given server from the stack dictionary and the computeUnits dictionary.
@@ -625,8 +648,10 @@
:return: :class:`heat.resources.net`
"""
LOG.debug("Creating network with name %s" % name)
- if self.find_network_by_name_or_id(name) is not None and not stack_operation:
- LOG.warning("Creating network with name %s failed, as it already exists" % name)
+ if self.find_network_by_name_or_id(
+ name) is not None and not stack_operation:
+ LOG.warning(
+ "Creating network with name %s failed, as it already exists" % name)
raise Exception("Network with name %s already exists." % name)
network = Net(name)
network.id = str(uuid.uuid4())
@@ -643,7 +668,8 @@
"""
net = self.find_network_by_name_or_id(name_or_id)
if net is None:
- raise Exception("Network with name or id %s does not exists." % name_or_id)
+ raise Exception(
+ "Network with name or id %s does not exists." % name_or_id)
for stack in self.stacks.values():
stack.nets.pop(net.name, None)
@@ -664,7 +690,8 @@
"""
port = self.find_port_by_name_or_id(name)
if port is not None and not stack_operation:
- LOG.warning("Creating port with name %s failed, as it already exists" % name)
+ LOG.warning(
+ "Creating port with name %s failed, as it already exists" % name)
raise Exception("Port with name %s already exists." % name)
LOG.debug("Creating port with name %s" % name)
port = Port(name)
@@ -699,13 +726,14 @@
"""
port = self.find_port_by_name_or_id(name_or_id)
if port is None:
- LOG.warning("Port with name or id %s does not exist. Can't delete it." % name_or_id)
+ LOG.warning(
+ "Port with name or id %s does not exist. Can't delete it." % name_or_id)
return
my_links = self.dc.net.links
for link in my_links:
if str(link.intf1) == port.intf_name and \
- str(link.intf1.ip) == port.ip_address.split('/')[0]:
+ str(link.intf1.ip) == port.ip_address.split('/')[0]:
self._remove_link(link.intf1.node.name, link)
break
@@ -727,7 +755,8 @@
"""
port_pair = self.find_port_pair_by_name_or_id(name)
if port_pair is not None and not stack_operation:
- logging.warning("Creating port pair with name %s failed, as it already exists" % name)
+ logging.warning(
+ "Creating port pair with name %s failed, as it already exists" % name)
raise Exception("Port pair with name %s already exists." % name)
logging.debug("Creating port pair with name %s" % name)
port_pair = PortPair(name)
@@ -761,7 +790,8 @@
"""
port_pair = self.find_port_pair_by_name_or_id(name_or_id)
if port_pair is None:
- raise Exception("Port pair with name or id %s does not exists." % name_or_id)
+ raise Exception(
+ "Port pair with name or id %s does not exists." % name_or_id)
self.port_pairs.pop(port_pair.id, None)
@@ -779,8 +809,10 @@
"""
port_pair_group = self.find_port_pair_group_by_name_or_id(name)
if port_pair_group is not None and not stack_operation:
- logging.warning("Creating port pair group with name %s failed, as it already exists" % name)
- raise Exception("Port pair group with name %s already exists." % name)
+ logging.warning(
+ "Creating port pair group with name %s failed, as it already exists" % name)
+ raise Exception(
+ "Port pair group with name %s already exists." % name)
logging.debug("Creating port pair group with name %s" % name)
port_pair_group = PortPairGroup(name)
if not stack_operation:
@@ -813,7 +845,8 @@
"""
port_pair_group = self.find_port_pair_group_by_name_or_id(name_or_id)
if port_pair_group is None:
- raise Exception("Port pair with name or id %s does not exists." % name_or_id)
+ raise Exception(
+ "Port pair with name or id %s does not exists." % name_or_id)
self.port_pair_groups.pop(port_pair_group.id, None)
@@ -831,7 +864,8 @@
"""
port_chain = self.find_port_chain_by_name_or_id(name)
if port_chain is not None and not stack_operation:
- logging.warning("Creating port chain with name %s failed, as it already exists" % name)
+ logging.warning(
+ "Creating port chain with name %s failed, as it already exists" % name)
raise Exception("Port chain with name %s already exists." % name)
logging.debug("Creating port chain with name %s" % name)
port_chain = PortChain(name)
@@ -865,7 +899,8 @@
port_chain = self.find_port_chain_by_name_or_id(name_or_id)
port_chain.uninstall(self)
if port_chain is None:
- raise Exception("Port chain with name or id %s does not exists." % name_or_id)
+ raise Exception(
+ "Port chain with name or id %s does not exists." % name_or_id)
self.port_chains.pop(port_chain.id, None)
@@ -883,8 +918,10 @@
"""
flow_classifier = self.find_flow_classifier_by_name_or_id(name)
if flow_classifier is not None and not stack_operation:
- logging.warning("Creating flow classifier with name %s failed, as it already exists" % name)
- raise Exception("Flow classifier with name %s already exists." % name)
+ logging.warning(
+ "Creating flow classifier with name %s failed, as it already exists" % name)
+ raise Exception(
+ "Flow classifier with name %s already exists." % name)
logging.debug("Creating flow classifier with name %s" % name)
flow_classifier = FlowClassifier(name)
if not stack_operation:
@@ -917,7 +954,8 @@
"""
flow_classifier = self.find_flow_classifier_by_name_or_id(name_or_id)
if flow_classifier is None:
- raise Exception("Flow classifier with name or id %s does not exists." % name_or_id)
+ raise Exception(
+ "Flow classifier with name or id %s does not exists." % name_or_id)
self.flow_classifiers.pop(flow_classifier.id, None)
diff --git a/src/emuvim/api/openstack/docker_util.py b/src/emuvim/api/openstack/docker_util.py
index a93e75e..f32d971 100755
--- a/src/emuvim/api/openstack/docker_util.py
+++ b/src/emuvim/api/openstack/docker_util.py
@@ -1,31 +1,29 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-from docker import DockerClient, APIClient
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
+from docker import APIClient
import time
import re
@@ -64,7 +62,8 @@
cpu_usage = 0
for number in numbers:
cpu_usage += number
- return {'CPU_used': cpu_usage, 'CPU_used_systime': sys_time, 'CPU_cores': len(numbers)}
+ return {'CPU_used': cpu_usage,
+ 'CPU_used_systime': sys_time, 'CPU_cores': len(numbers)}
def docker_mem_used(container_id):
@@ -123,7 +122,8 @@
out_dict = dict()
out_dict['MEM_used'] = docker_mem_used(container_id)
out_dict['MEM_limit'] = docker_max_mem(container_id)
- out_dict['MEM_%'] = float(out_dict['MEM_used']) / float(out_dict['MEM_limit'])
+ out_dict['MEM_%'] = float(out_dict['MEM_used']) / \
+ float(out_dict['MEM_limit'])
return out_dict
@@ -218,9 +218,12 @@
second_disk_io = docker_block_rw(container_id)
# Disk access
- time_div = (int(second_disk_io['BLOCK_systime']) - int(first_disk_io['BLOCK_systime']))
- read_div = int(second_disk_io['BLOCK_read']) - int(first_disk_io['BLOCK_read'])
- write_div = int(second_disk_io['BLOCK_write']) - int(first_disk_io['BLOCK_write'])
+ time_div = (int(second_disk_io['BLOCK_systime']
+ ) - int(first_disk_io['BLOCK_systime']))
+ read_div = int(second_disk_io['BLOCK_read']) - \
+ int(first_disk_io['BLOCK_read'])
+ write_div = int(second_disk_io['BLOCK_write']) - \
+ int(first_disk_io['BLOCK_write'])
out_dict = {'BLOCK_read/s': int(read_div * 1000000000 / float(time_div) + 0.5),
'BLOCK_write/s': int(write_div * 1000000000 / float(time_div) + 0.5)}
@@ -232,7 +235,10 @@
'NET_out/s': int(out_div * 1000000000 / float(time_div) + 0.5)})
# CPU utilization
- time_div = (int(second_cpu_usage['CPU_used_systime']) - int(first_cpu_usage['CPU_used_systime']))
- usage_div = int(second_cpu_usage['CPU_used']) - int(first_cpu_usage['CPU_used'])
- out_dict.update({'CPU_%': usage_div / float(time_div), 'CPU_cores': first_cpu_usage['CPU_cores']})
+ time_div = (int(second_cpu_usage['CPU_used_systime']
+ ) - int(first_cpu_usage['CPU_used_systime']))
+ usage_div = int(second_cpu_usage['CPU_used']) - \
+ int(first_cpu_usage['CPU_used'])
+ out_dict.update({'CPU_%': usage_div / float(time_div),
+ 'CPU_cores': first_cpu_usage['CPU_cores']})
return out_dict
diff --git a/src/emuvim/api/openstack/heat_parser.py b/src/emuvim/api/openstack/heat_parser.py
index 9bf80ee..ffcaa0a 100755
--- a/src/emuvim/api/openstack/heat_parser.py
+++ b/src/emuvim/api/openstack/heat_parser.py
@@ -1,32 +1,30 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from __future__ import print_function # TODO remove when print is no longer needed for debugging
-from resources import *
+from resources.router import Router
from datetime import datetime
import re
import sys
@@ -68,7 +66,8 @@
* *False*: Else
:rtype: ``bool``
"""
- if not self.check_template_version(str(input_dict['heat_template_version'])):
+ if not self.check_template_version(
+ str(input_dict['heat_template_version'])):
print('Unsupported template version: ' + input_dict['heat_template_version'], file=sys.stderr)
return False
@@ -81,15 +80,19 @@
self.bufferResource = list()
for resource in self.resources.values():
- self.handle_resource(resource, stack, dc_label, stack_update=stack_update)
+ self.handle_resource(resource, stack, dc_label,
+ stack_update=stack_update)
- # This loop tries to create all classes which had unresolved dependencies.
+ # This loop tries to create all classes which had unresolved
+ # dependencies.
unresolved_resources_last_round = len(self.bufferResource) + 1
- while len(self.bufferResource) > 0 and unresolved_resources_last_round > len(self.bufferResource):
+ while len(self.bufferResource) > 0 and unresolved_resources_last_round > len(
+ self.bufferResource):
unresolved_resources_last_round = len(self.bufferResource)
number_of_items = len(self.bufferResource)
while number_of_items > 0:
- self.handle_resource(self.bufferResource.pop(0), stack, dc_label, stack_update=stack_update)
+ self.handle_resource(self.bufferResource.pop(
+ 0), stack, dc_label, stack_update=stack_update)
number_of_items -= 1
if len(self.bufferResource) > 0:
@@ -123,7 +126,8 @@
try:
net_name = resource['properties']['name']
if net_name not in stack.nets:
- stack.nets[net_name] = self.compute.create_network(net_name, True)
+ stack.nets[net_name] = self.compute.create_network(
+ net_name, True)
except Exception as e:
LOG.warning('Could not create Net: ' + e.message)
@@ -141,7 +145,8 @@
net.subnet_name = resource['properties']['name']
if 'gateway_ip' in resource['properties']:
net.gateway_ip = resource['properties']['gateway_ip']
- net.subnet_id = resource['properties'].get('id', str(uuid.uuid4()))
+ net.subnet_id = resource['properties'].get(
+ 'id', str(uuid.uuid4()))
net.subnet_creation_time = str(datetime.now())
if not stack_update:
net.set_cidr(IP.get_new_cidr(net.subnet_id))
@@ -158,8 +163,10 @@
else:
port = stack.ports[port_name]
- if str(resource['properties']['network']['get_resource']) in stack.nets:
- net = stack.nets[resource['properties']['network']['get_resource']]
+ if str(resource['properties']['network']
+ ['get_resource']) in stack.nets:
+ net = stack.nets[resource['properties']
+ ['network']['get_resource']]
if net.subnet_id is not None:
port.net_name = net.name
port.ip_address = net.get_new_ip_address(port.name)
@@ -171,20 +178,24 @@
if 'OS::Nova::Server' in resource['type']:
try:
- compute_name = str(dc_label) + '_' + str(stack.stack_name) + '_' + str(resource['properties']['name'])
+ compute_name = str(dc_label) + '_' + str(stack.stack_name) + \
+ '_' + str(resource['properties']['name'])
shortened_name = str(dc_label) + '_' + str(stack.stack_name) + '_' + \
- self.shorten_server_name(str(resource['properties']['name']), stack)
+ self.shorten_server_name(
+ str(resource['properties']['name']), stack)
nw_list = resource['properties']['networks']
if shortened_name not in stack.servers:
- server = self.compute.create_server(shortened_name, stack_update)
+ server = self.compute.create_server(
+ shortened_name, stack_update)
stack.servers[shortened_name] = server
else:
server = stack.servers[shortened_name]
server.full_name = compute_name
server.template_name = str(resource['properties']['name'])
- server.command = resource['properties'].get('command', '/bin/sh')
+ server.command = resource['properties'].get(
+ 'command', '/bin/sh')
server.image = resource['properties']['image']
server.flavor = resource['properties']['flavor']
@@ -194,7 +205,8 @@
# we don't know which network it belongs to yet, but the resource will appear later in a valid
# template
if port_name not in stack.ports:
- stack.ports[port_name] = self.compute.create_port(port_name, stack_update)
+ stack.ports[port_name] = self.compute.create_port(
+ port_name, stack_update)
server.port_names.append(port_name)
return
except Exception as e:
@@ -219,7 +231,8 @@
stack.routers[router_name].add_subnet(subnet_name)
return
except Exception as e:
- LOG.warning('Could not create RouterInterface: ' + e.__repr__())
+ LOG.warning(
+ 'Could not create RouterInterface: ' + e.__repr__())
self.bufferResource.append(resource)
return
@@ -228,7 +241,8 @@
port_name = resource['properties']['port_id']['get_resource']
floating_network_id = resource['properties']['floating_network_id']
if port_name not in stack.ports:
- stack.ports[port_name] = self.compute.create_port(port_name, stack_update)
+ stack.ports[port_name] = self.compute.create_port(
+ port_name, stack_update)
stack.ports[port_name].floating_ip = floating_network_id
except Exception as e:
@@ -247,14 +261,17 @@
if 'OS::Heat::ResourceGroup' in resource['type']:
try:
embedded_resource = resource['properties']['resource_def']
- LOG.debug("Found resource in resource group: {}".format(embedded_resource))
+ LOG.debug("Found resource in resource group: {}".format(
+ embedded_resource))
# recursively parse embedded resource
- self.handle_resource(embedded_resource, stack, dc_label, stack_update)
+ self.handle_resource(
+ embedded_resource, stack, dc_label, stack_update)
except Exception as e:
print('Could not create Router: ' + e.message)
return
- LOG.warning('Could not determine resource type: {}'.format(resource['type']))
+ LOG.warning(
+ 'Could not determine resource type: {}'.format(resource['type']))
return
def shorten_server_name(self, server_name, stack):
@@ -310,8 +327,8 @@
if year < 2015:
return False
if year == 2015:
- if month < 04:
+ if month < 0o4:
return False
- if month == 04 and day < 30:
+ if month == 0o4 and day < 30:
return False
return True
diff --git a/src/emuvim/api/openstack/helper.py b/src/emuvim/api/openstack/helper.py
index 09a51f6..c7ef69b 100644
--- a/src/emuvim/api/openstack/helper.py
+++ b/src/emuvim/api/openstack/helper.py
@@ -1,38 +1,37 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from urlparse import urlparse
import logging
LOG = logging.getLogger("api.openstack.helper")
+
def get_host(r):
try:
return urlparse(r.base_url).hostname
- except:
+ except BaseException:
LOG.error("Could not get host part of request URL.")
return "0.0.0.0"
diff --git a/src/emuvim/api/openstack/ip_handler.py b/src/emuvim/api/openstack/ip_handler.py
index 208a910..9138342 100755
--- a/src/emuvim/api/openstack/ip_handler.py
+++ b/src/emuvim/api/openstack/ip_handler.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from resources.net import Net
import threading
@@ -128,7 +126,7 @@
int_ip = Net.cidr_2_int(cidr)
- if not int_ip in __issued_ips:
+ if int_ip not in __issued_ips:
return False
if __issued_ips[int_ip] == uuid:
diff --git a/src/emuvim/api/openstack/manage.py b/src/emuvim/api/openstack/manage.py
index 5405e78..083550e 100755
--- a/src/emuvim/api/openstack/manage.py
+++ b/src/emuvim/api/openstack/manage.py
@@ -1,38 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-"""Openstack manage component of PG Sandman.
-
-.. module:: manage
- :synopsis: Module containing the OpenstackManage class.
-.. moduleauthor: PG Sandman
-
-"""
-
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import logging
import threading
import uuid
@@ -40,7 +30,8 @@
import chain_api
import json
import random
-from emuvim.api.openstack.resources import Net, Port
+from emuvim.api.openstack.resources.net import Net
+from emuvim.api.openstack.resources.port import Port
from mininet.node import OVSSwitch, RemoteController, Node
@@ -71,7 +62,8 @@
self.ip = ip
self.port = port
self._net = None
- # to keep track which src_vnf(input port on the switch) handles a load balancer
+ # to keep track which src_vnf(input port on the switch) handles a load
+ # balancer
self.lb_flow_cookies = dict()
self.chain_flow_cookies = dict()
@@ -83,7 +75,8 @@
# debug and to maintain
self.flow_groups = dict()
- # we want one global chain api. this should not be datacenter dependent!
+ # we want one global chain api. this should not be datacenter
+ # dependent!
self.chain = chain_api.ChainApi(ip, port, self)
self.thread = threading.Thread(target=self.chain._start_flask, args=())
self.thread.daemon = True
@@ -128,7 +121,7 @@
# create a port for the host
port = Port("root-port")
- #port.id = str(uuid.uuid4())
+ # port.id = str(uuid.uuid4())
port.net_name = fn.name
# get next free ip
@@ -137,16 +130,19 @@
# floating ip network setup
# wierd way of getting a datacenter object
first_dc = self.net.dcs.values()[0]
- # set a dpid for the switch. for this we have to get the id of the next possible dc
- self.floating_switch = self.net.addSwitch("fs1", dpid=hex(first_dc._get_next_dc_dpid())[2:])
+ # set a dpid for the switch. for this we have to get the id of the
+ # next possible dc
+ self.floating_switch = self.net.addSwitch(
+ "fs1", dpid=hex(first_dc._get_next_dc_dpid())[2:])
# this is the interface appearing on the physical host
self.floating_root = Node('root', inNamespace=False)
self.net.hosts.append(self.floating_root)
self.net.nameToNode['root'] = self.floating_root
- self.floating_intf = self.net.addLink(self.floating_root, self.floating_switch).intf1
+ self.floating_intf = self.net.addLink(
+ self.floating_root, self.floating_switch).intf1
self.floating_root.setIP(root_ip, intf=self.floating_intf)
- self.floating_nodes[(self.floating_root.name, root_ip)] = self.floating_root
-
+ self.floating_nodes[(self.floating_root.name,
+ root_ip)] = self.floating_root
def stop_floating_network(self):
self._net = None
@@ -235,16 +231,21 @@
vnf_dst_interface = kwargs.get('vnf_dst_interface')
layer2 = kwargs.get('layer2', True)
match = kwargs.get('match')
- flow = (vnf_src_name, vnf_src_interface, vnf_dst_name, vnf_dst_interface)
+ flow = (vnf_src_name, vnf_src_interface,
+ vnf_dst_name, vnf_dst_interface)
if flow in self.chain_flow_cookies:
- raise Exception("There is already a chain at the specified src/dst pair!")
- # set up a layer 2 chain, this allows multiple chains for the same interface
+ raise Exception(
+ "There is already a chain at the specified src/dst pair!")
+ # set up a layer 2 chain, this allows multiple chains for the same
+ # interface
src_node = self.net.getNodeByName(vnf_src_name)
dst_node = self.net.getNodeByName(vnf_dst_name)
dst_intf = dst_node.intf(vnf_dst_interface)
if layer2:
- switch, inport = self._get_connected_switch_data(vnf_src_name, vnf_src_interface)
- self.setup_arp_reply_at(switch, inport, dst_intf.IP(), dst_intf.MAC())
+ switch, inport = self._get_connected_switch_data(
+ vnf_src_name, vnf_src_interface)
+ self.setup_arp_reply_at(
+ switch, inport, dst_intf.IP(), dst_intf.MAC())
if isinstance(match, str):
match += ",dl_dst=%s" % dst_intf.MAC()
else:
@@ -252,7 +253,7 @@
cookie = kwargs.get('cookie', self.get_cookie())
self.cookies.add(cookie)
- c = self.net.setChain(
+ self.net.setChain(
vnf_src_name, vnf_dst_name,
vnf_src_interface=vnf_src_interface,
vnf_dst_interface=vnf_dst_interface,
@@ -263,7 +264,8 @@
cookie=cookie,
path=kwargs.get('path'))
- # to keep this logic seperate of the core son-emu do the housekeeping here
+ # to keep this logic seperate of the core son-emu do the
+ # housekeeping here
data = dict()
data["src_vnf"] = vnf_src_name
data["src_intf"] = vnf_src_interface
@@ -278,15 +280,18 @@
vnf_dst_interface)[0]
# add route to dst ip to this interface
- # this might block on containers that are still setting up, so start a new thread
+ # this might block on containers that are still setting up, so
+ # start a new thread
if not kwargs.get('no_route'):
# son_emu does not like concurrent commands for a container so we need to lock this if multiple chains
# on the same interface are created
- src_node.setHostRoute(dst_node.intf(vnf_dst_interface).IP(), vnf_src_interface)
+ src_node.setHostRoute(dst_node.intf(
+ vnf_dst_interface).IP(), vnf_src_interface)
try:
- son_emu_data = json.loads(self.get_son_emu_chain_data(vnf_src_name))
- except:
+ son_emu_data = json.loads(
+ self.get_son_emu_chain_data(vnf_src_name))
+ except BaseException:
son_emu_data = dict()
if "son_emu_data" not in son_emu_data:
son_emu_data["son_emu_data"] = dict()
@@ -294,7 +299,8 @@
son_emu_data["son_emu_data"]["interfaces"] = dict()
if vnf_src_interface not in son_emu_data["son_emu_data"]["interfaces"]:
son_emu_data["son_emu_data"]["interfaces"][vnf_src_interface] = list()
- son_emu_data["son_emu_data"]["interfaces"][vnf_src_interface].append(dst_intf.IP())
+ son_emu_data["son_emu_data"]["interfaces"][vnf_src_interface].append(
+ dst_intf.IP())
self.set_son_emu_chain_data(vnf_src_name, son_emu_data)
@@ -356,12 +362,14 @@
:param data: Raw data to store on the node.
:type data: ``str``
"""
- self.net.getNodeByName(vnf_name).cmd("echo \'%s\' > /tmp/son_emu_data.json" % json.dumps(data))
+ self.net.getNodeByName(vnf_name).cmd(
+ "echo \'%s\' > /tmp/son_emu_data.json" % json.dumps(data))
ip_list = []
for intf in data['son_emu_data']['interfaces'].values():
ip_list.extend(intf)
- self.net.getNodeByName(vnf_name).cmd("echo \'%s\' > /tmp/son_emu_data" % "\n".join(ip_list))
+ self.net.getNodeByName(vnf_name).cmd(
+ "echo \'%s\' > /tmp/son_emu_data" % "\n".join(ip_list))
def get_son_emu_chain_data(self, vnf_name):
"""
@@ -372,7 +380,8 @@
:return: raw data stored on the node
:rtype: ``str``
"""
- return self.net.getNodeByName(vnf_name).cmd("cat /tmp/son_emu_data.json")
+ return self.net.getNodeByName(vnf_name).cmd(
+ "cat /tmp/son_emu_data.json")
def _get_connected_switch_data(self, vnf_name, vnf_interface):
"""
@@ -390,8 +399,8 @@
link_dict = self.net.DCNetwork_graph[vnf_name][connected_sw]
for link in link_dict:
if (link_dict[link]['src_port_id'] == vnf_interface or
- link_dict[link][
- 'src_port_name'] == vnf_interface):
+ link_dict[link][
+ 'src_port_name'] == vnf_interface):
# found the right link and connected switch
src_sw = connected_sw
src_sw_inport_nr = link_dict[link]['dst_port_nr']
@@ -415,7 +424,8 @@
:return: path, src_sw, dst_sw
:rtype: ``list``, ``str``, ``str``
"""
- # modified version of the _chainAddFlow from emuvim.dcemulator.net._chainAddFlow
+ # modified version of the _chainAddFlow from
+ # emuvim.dcemulator.net._chainAddFlow
src_sw = None
dst_sw = None
logging.debug("Find shortest path from vnf %s to %s",
@@ -425,8 +435,8 @@
link_dict = self.net.DCNetwork_graph[src_vnf][connected_sw]
for link in link_dict:
if (link_dict[link]['src_port_id'] == src_vnf_intf or
- link_dict[link][
- 'src_port_name'] == src_vnf_intf):
+ link_dict[link][
+ 'src_port_name'] == src_vnf_intf):
# found the right link and connected switch
src_sw = connected_sw
break
@@ -435,8 +445,8 @@
link_dict = self.net.DCNetwork_graph[connected_sw][dst_vnf]
for link in link_dict:
if link_dict[link]['dst_port_id'] == dst_vnf_intf or \
- link_dict[link][
- 'dst_port_name'] == dst_vnf_intf:
+ link_dict[link][
+ 'dst_port_name'] == dst_vnf_intf:
# found the right link and connected
dst_sw = connected_sw
break
@@ -447,16 +457,18 @@
# returns the first found shortest path
# if all shortest paths are wanted, use: all_shortest_paths
path = nx.shortest_path(self.net.DCNetwork_graph, src_sw, dst_sw)
- except:
+ except BaseException:
logging.exception("No path could be found between {0} and {1} using src_sw={2} and dst_sw={3}".format(
src_vnf, dst_vnf, src_sw, dst_sw))
logging.debug("Graph nodes: %r" % self.net.DCNetwork_graph.nodes())
logging.debug("Graph edges: %r" % self.net.DCNetwork_graph.edges())
for e, v in self.net.DCNetwork_graph.edges():
logging.debug("%r" % self.net.DCNetwork_graph[e][v])
- return "No path could be found between {0} and {1}".format(src_vnf, dst_vnf)
+ return "No path could be found between {0} and {1}".format(
+ src_vnf, dst_vnf)
- logging.info("Shortest path between {0} and {1}: {2}".format(src_vnf, dst_vnf, path))
+ logging.info("Shortest path between {0} and {1}: {2}".format(
+ src_vnf, dst_vnf, path))
return path, src_sw, dst_sw
def add_loadbalancer(self, src_vnf_name, src_vnf_interface, lb_data):
@@ -483,12 +495,15 @@
custom_paths = lb_data.get('path', dict())
dest_vnf_outport_nrs = list()
- logging.debug("Call to add_loadbalancer at %s intfs:%s" % (src_vnf_name, src_vnf_interface))
+ logging.debug("Call to add_loadbalancer at %s intfs:%s" %
+ (src_vnf_name, src_vnf_interface))
if not self.check_vnf_intf_pair(src_vnf_name, src_vnf_interface):
- raise Exception(u"Source VNF %s or intfs %s does not exist" % (src_vnf_name, src_vnf_interface))
+ raise Exception(u"Source VNF %s or intfs %s does not exist" % (
+ src_vnf_name, src_vnf_interface))
- # find the switch belonging to the source interface, as well as the inport nr
+ # find the switch belonging to the source interface, as well as the
+ # inport nr
for connected_sw in net.DCNetwork_graph.neighbors(src_vnf_name):
link_dict = net.DCNetwork_graph[src_vnf_name][connected_sw]
for link in link_dict:
@@ -508,19 +523,18 @@
link_dict = net.DCNetwork_graph[vnf_name][connected_sw]
for link in link_dict:
if link_dict[link]['src_port_name'] == dest_intfs_mapping[vnf_name]:
- dest_vnf_outport_nrs.append(int(link_dict[link]['dst_port_nr']))
+ dest_vnf_outport_nrs.append(
+ int(link_dict[link]['dst_port_nr']))
# get first switch
if (src_vnf_name, src_vnf_interface) not in self.lb_flow_cookies:
self.lb_flow_cookies[(src_vnf_name, src_vnf_interface)] = list()
- src_intf = None
src_ip = None
src_mac = None
for intf in net[src_vnf_name].intfs.values():
if intf.name == src_vnf_interface:
src_mac = intf.mac
src_ip = intf.ip
- src_intf = intf
# set up paths for each destination vnf individually
index = 0
@@ -536,7 +550,8 @@
data["cookie"] = cookie
# lb mac for src -> target connections
- lb_mac = "31:33:70:%02x:%02x:%02x" % (random.randint(0, 255),random.randint(0, 255),random.randint(0, 255))
+ lb_mac = "31:33:70:%02x:%02x:%02x" % (random.randint(
+ 0, 255), random.randint(0, 255), random.randint(0, 255))
# calculate lb ip as src_intf.ip +1
octets = src_ip.split('.')
@@ -544,8 +559,10 @@
plus_one = '.'.join(octets)
# set up arp reply as well as add the route to the interface
- self.setup_arp_reply_at(src_sw, src_sw_inport_nr, plus_one, lb_mac, cookie=cookie)
- net.getNodeByName(src_vnf_name).setHostRoute(plus_one, src_vnf_interface)
+ self.setup_arp_reply_at(src_sw, src_sw_inport_nr,
+ plus_one, lb_mac, cookie=cookie)
+ net.getNodeByName(src_vnf_name).setHostRoute(
+ plus_one, src_vnf_interface)
for dst_vnf_name, dst_vnf_interface in dest_intfs_mapping.items():
path, src_sw, dst_sw = self._get_path(src_vnf_name, dst_vnf_name,
@@ -556,14 +573,17 @@
if custom_paths is not None and dst_vnf_name in custom_paths:
if dst_vnf_interface in custom_paths[dst_vnf_name]:
path = custom_paths[dst_vnf_name][dst_vnf_interface]
- logging.debug("Taking custom path from %s to %s: %s" % (src_vnf_name, dst_vnf_name, path))
+ logging.debug("Taking custom path from %s to %s: %s" % (
+ src_vnf_name, dst_vnf_name, path))
if not self.check_vnf_intf_pair(dst_vnf_name, dst_vnf_interface):
self.delete_loadbalancer(src_vnf_name, src_vnf_interface)
- raise Exception(u"VNF %s or intfs %s does not exist" % (dst_vnf_name, dst_vnf_interface))
+ raise Exception(u"VNF %s or intfs %s does not exist" %
+ (dst_vnf_name, dst_vnf_interface))
if isinstance(path, dict):
self.delete_loadbalancer(src_vnf_name, src_vnf_interface)
- raise Exception(u"Can not find a valid path. Are you specifying the right interfaces?.")
+ raise Exception(
+ u"Can not find a valid path. Are you specifying the right interfaces?.")
target_mac = "fa:17:00:03:13:37"
target_ip = "0.0.0.0"
@@ -575,8 +595,9 @@
current_hop = src_sw
switch_inport_nr = src_sw_inport_nr
- #self.setup_arp_reply_at(src_sw, src_sw_inport_nr, target_ip, target_mac, cookie=cookie)
- net.getNodeByName(dst_vnf_name).setHostRoute(src_ip, dst_vnf_interface)
+ # self.setup_arp_reply_at(src_sw, src_sw_inport_nr, target_ip, target_mac, cookie=cookie)
+ net.getNodeByName(dst_vnf_name).setHostRoute(
+ src_ip, dst_vnf_interface)
# choose free vlan if path contains more than 1 switch
if len(path) > 1:
@@ -607,16 +628,20 @@
switch_outport_nr = dst_sw_outport_nr
logging.info("end node reached: {0}".format(dst_vnf_name))
elif not isinstance(next_node, OVSSwitch):
- logging.info("Next node: {0} is not a switch".format(next_hop))
+ logging.info(
+ "Next node: {0} is not a switch".format(next_hop))
return "Next node: {0} is not a switch".format(next_hop)
else:
# take first link between switches by default
index_edge_out = 0
switch_outport_nr = net.DCNetwork_graph[current_hop][next_hop][index_edge_out]['src_port_nr']
- cmd = 'priority=1,in_port=%s,cookie=%s' % (switch_inport_nr, cookie)
- cmd_back = 'priority=1,in_port=%s,cookie=%s' % (switch_outport_nr, cookie)
- # if a vlan is picked, the connection is routed through multiple switches
+ cmd = 'priority=1,in_port=%s,cookie=%s' % (
+ switch_inport_nr, cookie)
+ cmd_back = 'priority=1,in_port=%s,cookie=%s' % (
+ switch_outport_nr, cookie)
+ # if a vlan is picked, the connection is routed through
+ # multiple switches
if vlan is not None:
if path.index(current_hop) == 0: # first node
# flow #index set up
@@ -642,8 +667,10 @@
# remove any vlan tags
cmd += ',dl_vlan=%s' % vlan
cmd += ',actions=pop_vlan,output:%s' % switch_outport_nr
- # set up arp replys at the port so the dst nodes know the src
- self.setup_arp_reply_at(current_hop, switch_outport_nr, src_ip, src_mac, cookie=cookie)
+ # set up arp replys at the port so the dst nodes know
+ # the src
+ self.setup_arp_reply_at(
+ current_hop, switch_outport_nr, src_ip, src_mac, cookie=cookie)
# reverse route
cmd_back = 'in_port=%s' % switch_outport_nr
@@ -663,8 +690,10 @@
cmd += ',dl_vlan=%s,actions=IN_PORT' % (vlan)
cmd_back += ',dl_vlan=%s,actions=IN_PORT' % (vlan)
else:
- cmd += ',dl_vlan=%s,actions=output:%s' % (vlan, switch_outport_nr)
- cmd_back += ',dl_vlan=%s,actions=output:%s' % (vlan, switch_inport_nr)
+ cmd += ',dl_vlan=%s,actions=output:%s' % (
+ vlan, switch_outport_nr)
+ cmd_back += ',dl_vlan=%s,actions=output:%s' % (
+ vlan, switch_inport_nr)
# output the packet at the correct outport
else:
cmd = 'in_port=%s' % src_sw_inport_nr
@@ -686,7 +715,8 @@
cmd_back += ',set_field:%s->ip_src' % plus_one
cmd_back += ',output:%s' % src_sw_inport_nr
- self.setup_arp_reply_at(current_hop, switch_outport_nr, src_ip, src_mac, cookie=cookie)
+ self.setup_arp_reply_at(
+ current_hop, switch_outport_nr, src_ip, src_mac, cookie=cookie)
# excecute the command on the target switch
logging.debug(cmd)
@@ -703,7 +733,8 @@
# advance to next destination
index += 1
- # set up the actual load balancing rule as a multipath on the very first switch
+ # set up the actual load balancing rule as a multipath on the very
+ # first switch
cmd = '"in_port=%s' % src_sw_inport_nr
cmd += ',cookie=%s' % (cookie)
cmd += ',ip'
@@ -713,7 +744,8 @@
# load balance modulo n over all dest interfaces
# TODO: in newer openvswitch implementations this should be changed to symmetric_l3l4+udp
# to balance any kind of traffic
- cmd += ',multipath(symmetric_l4,1024,modulo_n,%s,0,NXM_NX_REG1[0..12])' % len(dest_intfs_mapping)
+ cmd += ',multipath(symmetric_l4,1024,modulo_n,%s,0,NXM_NX_REG1[0..12])' % len(
+ dest_intfs_mapping)
# reuse the cookie as table entry as it will be unique
cmd += ',resubmit(, %s)"' % cookie
@@ -758,10 +790,12 @@
link_dict = net.DCNetwork_graph[vnf_name][connected_sw]
for link in link_dict:
if link_dict[link]['src_port_name'] == dest_intfs_mapping[vnf_name]:
- dest_vnf_outport_nrs.append(int(link_dict[link]['dst_port_nr']))
+ dest_vnf_outport_nrs.append(
+ int(link_dict[link]['dst_port_nr']))
if len(dest_vnf_outport_nrs) == 0:
- raise Exception("There are no paths specified for the loadbalancer")
+ raise Exception(
+ "There are no paths specified for the loadbalancer")
src_ip = self.floating_intf.IP()
src_mac = self.floating_intf.MAC()
@@ -769,7 +803,8 @@
index = 0
cookie = self.get_cookie()
main_cmd = "add-flow -OOpenFlow13"
- floating_ip = self.floating_network.get_new_ip_address("floating-ip").split("/")[0]
+ floating_ip = self.floating_network.get_new_ip_address(
+ "floating-ip").split("/")[0]
for dst_vnf_name, dst_vnf_interface in dest_intfs_mapping.items():
path = None
@@ -778,17 +813,20 @@
if custom_paths is not None and dst_vnf_name in custom_paths:
if dst_vnf_interface in custom_paths[dst_vnf_name]:
path = custom_paths[dst_vnf_name][dst_vnf_interface]
- logging.debug("Taking custom path to %s: %s" % (dst_vnf_name, path))
+ logging.debug("Taking custom path to %s: %s" %
+ (dst_vnf_name, path))
else:
if datacenter not in self.floating_links:
self.floating_links[datacenter] = \
net.addLink(self.floating_switch, datacenter)
path = \
- self._get_path(self.floating_root.name, dst_vnf_name, self.floating_intf.name, dst_vnf_interface)[0]
+ self._get_path(self.floating_root.name, dst_vnf_name,
+ self.floating_intf.name, dst_vnf_interface)[0]
if isinstance(path, dict):
self.delete_flow_by_cookie(cookie)
- raise Exception(u"Can not find a valid path. Are you specifying the right interfaces?.")
+ raise Exception(
+ u"Can not find a valid path. Are you specifying the right interfaces?.")
intf = net[dst_vnf_name].nameToIntf[dst_vnf_interface]
target_mac = str(intf.MAC())
@@ -812,16 +850,20 @@
switch_outport_nr = dst_sw_outport_nr
logging.info("end node reached: {0}".format(dst_vnf_name))
elif not isinstance(next_node, OVSSwitch):
- logging.info("Next node: {0} is not a switch".format(next_hop))
+ logging.info(
+ "Next node: {0} is not a switch".format(next_hop))
return "Next node: {0} is not a switch".format(next_hop)
else:
# take first link between switches by default
index_edge_out = 0
switch_outport_nr = net.DCNetwork_graph[current_hop][next_hop][index_edge_out]['src_port_nr']
- # default filters, just overwritten on the first node and last node
- cmd = 'priority=1,in_port=%s,cookie=%s' % (switch_inport_nr, cookie)
- cmd_back = 'priority=1,in_port=%s,cookie=%s' % (switch_outport_nr, cookie)
+ # default filters, just overwritten on the first node and last
+ # node
+ cmd = 'priority=1,in_port=%s,cookie=%s' % (
+ switch_inport_nr, cookie)
+ cmd_back = 'priority=1,in_port=%s,cookie=%s' % (
+ switch_outport_nr, cookie)
if i == 0: # first node
cmd = 'in_port=%s' % src_sw_inport_nr
cmd += ',cookie=%s' % cookie
@@ -842,13 +884,16 @@
# remove any vlan tags
cmd_back += ',dl_vlan=%s' % vlan
cmd_back += ',actions=pop_vlan,output:%s' % switch_inport_nr
- self.setup_arp_reply_at(current_hop, src_sw_inport_nr, floating_ip, target_mac, cookie=cookie)
+ self.setup_arp_reply_at(
+ current_hop, src_sw_inport_nr, floating_ip, target_mac, cookie=cookie)
elif next_hop == dst_vnf_name: # last switch
# remove any vlan tags
cmd += ',dl_vlan=%s' % vlan
cmd += ',actions=pop_vlan,output:%s' % switch_outport_nr
- # set up arp replys at the port so the dst nodes know the src
- self.setup_arp_reply_at(current_hop, switch_outport_nr, src_ip, src_mac, cookie=cookie)
+ # set up arp replys at the port so the dst nodes know the
+ # src
+ self.setup_arp_reply_at(
+ current_hop, switch_outport_nr, src_ip, src_mac, cookie=cookie)
# reverse route
cmd_back = 'in_port=%s' % switch_outport_nr
@@ -861,7 +906,8 @@
cmd_back += ',set_field:%s->eth_src' % src_mac
cmd_back += ',set_field:%s->ip_src' % floating_ip
cmd_back += ',output:%s' % switch_inport_nr
- net.getNodeByName(dst_vnf_name).setHostRoute(src_ip, dst_vnf_interface)
+ net.getNodeByName(dst_vnf_name).setHostRoute(
+ src_ip, dst_vnf_interface)
else: # middle node
# if we have a circle in the path we need to specify this, as openflow will ignore the packet
# if we just output it on the same port as it came in
@@ -869,8 +915,10 @@
cmd += ',dl_vlan=%s,actions=IN_PORT' % (vlan)
cmd_back += ',dl_vlan=%s,actions=IN_PORT' % (vlan)
else:
- cmd += ',dl_vlan=%s,actions=output:%s' % (vlan, switch_outport_nr)
- cmd_back += ',dl_vlan=%s,actions=output:%s' % (vlan, switch_inport_nr)
+ cmd += ',dl_vlan=%s,actions=output:%s' % (
+ vlan, switch_outport_nr)
+ cmd_back += ',dl_vlan=%s,actions=output:%s' % (
+ vlan, switch_inport_nr)
# excecute the command on the target switch
logging.debug(cmd)
@@ -887,7 +935,8 @@
# advance to next destination
index += 1
- # set up the actual load balancing rule as a multipath on the very first switch
+ # set up the actual load balancing rule as a multipath on the very
+ # first switch
cmd = '"in_port=%s' % src_sw_inport_nr
cmd += ',cookie=%s' % (cookie)
cmd += ',ip'
@@ -897,7 +946,8 @@
# load balance modulo n over all dest interfaces
# TODO: in newer openvswitch implementations this should be changed to symmetric_l3l4+udp
# to balance any kind of traffic
- cmd += ',multipath(symmetric_l4,1024,modulo_n,%s,0,NXM_NX_REG1[0..12])' % len(dest_intfs_mapping)
+ cmd += ',multipath(symmetric_l4,1024,modulo_n,%s,0,NXM_NX_REG1[0..12])' % len(
+ dest_intfs_mapping)
# reuse the cookie as table entry as it will be unique
cmd += ',resubmit(, %s)"' % cookie
@@ -909,7 +959,8 @@
return cookie, floating_ip
- def setup_arp_reply_at(self, switch, port_nr, target_ip, target_mac, cookie=None):
+ def setup_arp_reply_at(self, switch, port_nr,
+ target_ip, target_mac, cookie=None):
"""
Sets up a custom ARP reply at a switch.
An ARP request coming in on the `port_nr` for `target_ip` will be answered with target IP/MAC.
@@ -931,7 +982,8 @@
cookie = self.get_cookie()
main_cmd = "add-flow -OOpenFlow13"
- # first set up ARP requests for the source node, so it will always 'find' a partner
+ # first set up ARP requests for the source node, so it will always
+ # 'find' a partner
cmd = '"in_port=%s' % port_nr
cmd += ',cookie=%s' % cookie
cmd += ',arp'
@@ -988,7 +1040,8 @@
self.cookies.remove(cookie)
return True
- def delete_chain_by_intf(self, src_vnf_name, src_vnf_intf, dst_vnf_name, dst_vnf_intf):
+ def delete_chain_by_intf(
+ self, src_vnf_name, src_vnf_intf, dst_vnf_name, dst_vnf_intf):
"""
Removes a flow identified by the vnf_name/vnf_intf pairs
@@ -1003,16 +1056,18 @@
:return: True if successful, else false
:rtype: ``bool``
"""
- logging.debug("Deleting flow for vnf/intf pair %s %s" % (src_vnf_name, src_vnf_intf))
+ logging.debug("Deleting flow for vnf/intf pair %s %s" %
+ (src_vnf_name, src_vnf_intf))
if not self.check_vnf_intf_pair(src_vnf_name, src_vnf_intf):
return False
if not self.check_vnf_intf_pair(dst_vnf_name, dst_vnf_intf):
return False
target_flow = (src_vnf_name, src_vnf_intf, dst_vnf_name, dst_vnf_intf)
- if not target_flow in self.chain_flow_cookies:
+ if target_flow not in self.chain_flow_cookies:
return False
- success = self.delete_flow_by_cookie(self.chain_flow_cookies[target_flow])
+ success = self.delete_flow_by_cookie(
+ self.chain_flow_cookies[target_flow])
if success:
del self.chain_flow_cookies[target_flow]
@@ -1032,7 +1087,8 @@
delete_group = list()
group_id = self.get_flow_group(vnf_src_name, vnf_src_interface)
for node in self.net.switches:
- for cookie in self.lb_flow_cookies[(vnf_src_name, vnf_src_interface)]:
+ for cookie in self.lb_flow_cookies[(
+ vnf_src_name, vnf_src_interface)]:
flow = dict()
flow["dpid"] = int(node.dpid, 16)
flow["cookie"] = cookie
@@ -1053,7 +1109,8 @@
logging.debug("Deleting group with id %s" % group_id)
for switch_del_group in delete_group:
if self.net.controller == RemoteController:
- self.net.ryu_REST("stats/groupentry/delete", data=switch_del_group)
+ self.net.ryu_REST("stats/groupentry/delete",
+ data=switch_del_group)
# unmap groupid from the interface
target_pair = (vnf_src_name, vnf_src_interface)
@@ -1071,7 +1128,8 @@
"""
cookie = int(cookie)
if cookie not in self.floating_cookies:
- raise Exception("Can not delete floating loadbalancer as the flowcookie is not known")
+ raise Exception(
+ "Can not delete floating loadbalancer as the flowcookie is not known")
self.delete_flow_by_cookie(cookie)
floating_ip = self.floating_cookies[cookie]
diff --git a/src/emuvim/api/openstack/openstack_api_endpoint.py b/src/emuvim/api/openstack/openstack_api_endpoint.py
index e340a3a..b6347eb 100755
--- a/src/emuvim/api/openstack/openstack_api_endpoint.py
+++ b/src/emuvim/api/openstack/openstack_api_endpoint.py
@@ -1,36 +1,39 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from manage import OpenstackManage
-from openstack_dummies import *
+
+from openstack_dummies.glance_dummy_api import GlanceDummyApi
+from openstack_dummies.heat_dummy_api import HeatDummyApi
+from openstack_dummies.keystone_dummy_api import KeystoneDummyApi
+from openstack_dummies.neutron_dummy_api import NeutronDummyApi
+from openstack_dummies.nova_dummy_api import NovaDummyApi
+
import logging
import threading
import compute
-import requests
import socket
import time
@@ -47,11 +50,16 @@
self.port = port
self.compute = compute.OpenstackCompute()
self.openstack_endpoints = dict()
- self.openstack_endpoints['keystone'] = KeystoneDummyApi(self.ip, self.port)
- self.openstack_endpoints['neutron'] = NeutronDummyApi(self.ip, self.port + 4696, self.compute)
- self.openstack_endpoints['nova'] = NovaDummyApi(self.ip, self.port + 3774, self.compute)
- self.openstack_endpoints['heat'] = HeatDummyApi(self.ip, self.port + 3004, self.compute)
- self.openstack_endpoints['glance'] = GlanceDummyApi(self.ip, self.port + 4242, self.compute)
+ self.openstack_endpoints['keystone'] = KeystoneDummyApi(
+ self.ip, self.port)
+ self.openstack_endpoints['neutron'] = NeutronDummyApi(
+ self.ip, self.port + 4696, self.compute)
+ self.openstack_endpoints['nova'] = NovaDummyApi(
+ self.ip, self.port + 3774, self.compute)
+ self.openstack_endpoints['heat'] = HeatDummyApi(
+ self.ip, self.port + 3004, self.compute)
+ self.openstack_endpoints['glance'] = GlanceDummyApi(
+ self.ip, self.port + 4242, self.compute)
self.rest_threads = list()
self.manage = OpenstackManage()
@@ -69,8 +77,8 @@
self.compute.dc = dc
for ep in self.openstack_endpoints.values():
ep.manage = self.manage
- logging.info \
- ("Connected DC(%s) to API endpoint %s(%s:%d)" % (dc.label, self.__class__.__name__, self.ip, self.port))
+ logging.info("Connected DC(%s) to API endpoint %s(%s:%d)" %
+ (dc.label, self.__class__.__name__, self.ip, self.port))
def connect_dc_network(self, dc_network):
"""
@@ -97,14 +105,14 @@
c.server_thread.start()
if wait_for_port:
self._wait_for_port(c.ip, c.port)
-
+
def stop(self):
"""
Stop all connected OpenStack endpoints that are connected to this API endpoint.
"""
for c in self.openstack_endpoints.values():
c.stop()
- #for c in self.openstack_endpoints.values():
+ # for c in self.openstack_endpoints.values():
# if c.server_thread:
# print("Waiting for WSGIServers to be stopped ...")
# c.server_thread.join()
@@ -117,5 +125,6 @@
if r == 0:
break # port is open proceed
else:
- logging.warning("Waiting for {}:{} ... ({}/10)".format(ip, port, i + 1))
+ logging.warning(
+ "Waiting for {}:{} ... ({}/10)".format(ip, port, i + 1))
time.sleep(1)
diff --git a/src/emuvim/api/openstack/openstack_dummies/__init__.py b/src/emuvim/api/openstack/openstack_dummies/__init__.py
index ef97752..d888119 100755
--- a/src/emuvim/api/openstack/openstack_dummies/__init__.py
+++ b/src/emuvim/api/openstack/openstack_dummies/__init__.py
@@ -1,32 +1,25 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-from glance_dummy_api import GlanceDummyApi
-from heat_dummy_api import HeatDummyApi
-from keystone_dummy_api import KeystoneDummyApi
-from neutron_dummy_api import NeutronDummyApi
-from nova_dummy_api import NovaDummyApi
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
diff --git a/src/emuvim/api/openstack/openstack_dummies/base_openstack_dummy.py b/src/emuvim/api/openstack/openstack_dummies/base_openstack_dummy.py
index 93ad2bd..d8eeb79 100755
--- a/src/emuvim/api/openstack/openstack_dummies/base_openstack_dummy.py
+++ b/src/emuvim/api/openstack/openstack_dummies/base_openstack_dummy.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask import Flask, request
from flask_restful import Api, Resource
from gevent.pywsgi import WSGIServer
@@ -71,8 +69,9 @@
with self.manage.lock:
with open(self.playbook_file, 'a') as logfile:
if len(request.data) > 0:
- data = "# %s API\n" % str(self.__class__).split('.')[-1].rstrip('\'>')
+ data = "# %s API\n" % str(
+ self.__class__).split('.')[-1].rstrip('\'>')
data += "curl -X {type} -H \"Content-type: application/json\" -d '{data}' {url}".format(type=request.method,
- data=request.data,
- url=request.url)
+ data=request.data,
+ url=request.url)
logfile.write(data + "\n")
diff --git a/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py
index 4ce9e77..6edaa72 100755
--- a/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask_restful import Resource
from flask import Response, request
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
@@ -78,7 +76,8 @@
]
}]
resp['versions'] = versions
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class GlanceSchema(Resource):
@@ -88,7 +87,8 @@
resp['name'] = 'someImageName'
resp['properties'] = dict()
# just an ugly hack to allow the openstack client to work
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class GlanceListImagesApi(Resource):
@@ -97,7 +97,7 @@
def get(self):
LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
- try:
+ try:
resp = dict()
resp['next'] = None
resp['first'] = "/v2/images"
@@ -132,10 +132,12 @@
break
if "marker" in request.args: # ugly hack to fix pageination of openstack client
resp['images'] = None
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
except Exception as ex:
- LOG.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):
@@ -147,20 +149,22 @@
LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
try:
body_data = json.loads(request.data)
- except:
+ except BaseException:
body_data = dict()
# lets see what we should create
img_name = request.headers.get("X-Image-Meta-Name")
img_size = request.headers.get("X-Image-Meta-Size")
img_disk_format = request.headers.get("X-Image-Meta-Disk-Format")
img_is_public = request.headers.get("X-Image-Meta-Is-Public")
- img_container_format = request.headers.get("X-Image-Meta-Container-Format")
+ img_container_format = request.headers.get(
+ "X-Image-Meta-Container-Format")
# try to use body payload if header fields are empty
if img_name is None:
img_name = body_data.get("name")
img_size = 1234
img_disk_format = body_data.get("disk_format")
- img_is_public = True if "public" in body_data.get("visibility") else False
+ img_is_public = True if "public" in body_data.get(
+ "visibility") else False
img_container_format = body_data.get("container_format")
# try to find ID of already existing image (matched by name)
img_id = None
@@ -212,15 +216,19 @@
resp['id'] = image.id
resp['name'] = image.name
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
- response = Response("Image with id or name %s does not exists." % id, status=404)
+ response = Response(
+ "Image with id or name %s does not exists." % id, status=404)
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.exception(u"%s: Could not retrieve image with id %s." % (__name__, id))
- return Response(ex.message, status=500, mimetype='application/json')
+ LOG.exception(
+ u"%s: Could not retrieve image with id %s." % (__name__, id))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
def put(self, id):
LOG.debug("API CALL: %s " % str(self.__class__.__name__))
@@ -241,12 +249,16 @@
resp = dict()
resp['id'] = image.id
resp['name'] = image.name
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
- response = Response("Image with id or name %s does not exists." % id, status=404)
+ response = Response(
+ "Image with id or name %s does not exists." % id, status=404)
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- logging.exception(u"%s: Could not retrieve image with id %s." % (__name__, id))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception(
+ u"%s: Could not retrieve image with id %s." % (__name__, id))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
diff --git a/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
index 9822f22..86fb6c1 100755
--- a/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
@@ -1,33 +1,31 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask import request, Response
from flask_restful import Resource
-from emuvim.api.openstack.resources import Stack
+from emuvim.api.openstack.resources.stack import Stack
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
from emuvim.api.openstack.helper import get_host
from datetime import datetime
@@ -88,7 +86,8 @@
]
}]
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
class HeatCreateStack(Resource):
@@ -116,9 +115,11 @@
stack.stack_name = stack_dict['stack_name']
reader = HeatParser(self.api.compute)
- if isinstance(stack_dict['template'], str) or isinstance(stack_dict['template'], unicode):
+ if isinstance(stack_dict['template'], str) or isinstance(
+ stack_dict['template'], unicode):
stack_dict['template'] = json.loads(stack_dict['template'])
- if not reader.parse_input(stack_dict['template'], stack, self.api.compute.dc.label):
+ if not reader.parse_input(
+ stack_dict['template'], stack, self.api.compute.dc.label):
self.api.compute.clean_broken_stack(stack)
return 'Could not create stack.', 400
@@ -136,7 +137,8 @@
self.api.compute.add_stack(stack)
self.api.compute.deploy_stack(stack.id)
- return Response(json.dumps(return_dict), status=201, mimetype="application/json")
+ return Response(json.dumps(return_dict), status=201,
+ mimetype="application/json")
except Exception as ex:
LOG.exception("Heat: Create Stack exception.")
@@ -168,7 +170,8 @@
"tags": ""
})
- return Response(json.dumps(return_stacks), status=200, mimetype="application/json")
+ return Response(json.dumps(return_stacks),
+ status=200, mimetype="application/json")
except Exception as ex:
LOG.exception("Heat: List Stack exception.")
return ex.message, 500
@@ -225,7 +228,8 @@
"stack_name": stack.stack_name,
"stack_owner": "The owner of the stack.", # add stack owner
"stack_status": stack.status,
- "stack_status_reason": "The reason for the current status of the stack.", # add status reason
+ # add status reason
+ "stack_status_reason": "The reason for the current status of the stack.",
"template_description": "The description of the stack template.",
"stack_user_project_id": "The project UUID of the stack user.",
"timeout_mins": "",
@@ -235,13 +239,14 @@
}
}
- return Response(json.dumps(return_stack), status=200, mimetype="application/json")
+ return Response(json.dumps(return_stack),
+ status=200, mimetype="application/json")
except Exception as ex:
LOG.exception("Heat: Show stack exception.")
return ex.message, 500
-
+
class HeatShowStackTemplate(Resource):
def __init__(self, api):
self.api = api
@@ -253,7 +258,7 @@
:param tenant_id:
:param stack_name_or_id:
:param stack_id:
- :return: Returns a json response which contains the stack's template.
+ :return: Returns a json response which contains the stack's template.
"""
LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
@@ -266,9 +271,10 @@
stack = tmp_stack
if stack is None:
return 'Could not resolve Stack - ID', 404
- #LOG.debug("STACK: {}".format(stack))
- #LOG.debug("TEMPLATE: {}".format(stack.template))
- return Response(json.dumps(stack.template), status=200, mimetype="application/json")
+ # LOG.debug("STACK: {}".format(stack))
+ # LOG.debug("TEMPLATE: {}".format(stack.template))
+ return Response(json.dumps(stack.template),
+ status=200, mimetype="application/json")
except Exception as ex:
LOG.exception("Heat: Show stack template exception.")
@@ -286,7 +292,7 @@
:param tenant_id:
:param stack_name_or_id:
:param stack_id:
- :return: Returns a json response which contains the stack's template.
+ :return: Returns a json response which contains the stack's template.
"""
LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
@@ -302,7 +308,8 @@
response = {"resources": []}
- return Response(json.dumps(response), status=200, mimetype="application/json")
+ return Response(json.dumps(response), status=200,
+ mimetype="application/json")
except Exception as ex:
LOG.exception("Heat: Show stack template exception.")
@@ -320,7 +327,7 @@
def patch(self, tenant_id, stack_name_or_id, stack_id=None):
LOG.debug("API CALL: %s PATCH" % str(self.__class__.__name__))
return self.update_stack(tenant_id, stack_name_or_id, stack_id)
-
+
def update_stack(self, tenant_id, stack_name_or_id, stack_id=None):
"""
Updates an existing stack with a new heat template.
@@ -354,9 +361,11 @@
stack.status = "UPDATE_COMPLETE"
reader = HeatParser(self.api.compute)
- if isinstance(stack_dict['template'], str) or isinstance(stack_dict['template'], unicode):
+ if isinstance(stack_dict['template'], str) or isinstance(
+ stack_dict['template'], unicode):
stack_dict['template'] = json.loads(stack_dict['template'])
- if not reader.parse_input(stack_dict['template'], stack, self.api.compute.dc.label, stack_update=True):
+ if not reader.parse_input(
+ stack_dict['template'], stack, self.api.compute.dc.label, stack_update=True):
return 'Could not create stack.', 400
stack.template = stack_dict['template']
diff --git a/src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
index 1a258df..0741553 100755
--- a/src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask_restful import Resource
from flask import request, Response
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
@@ -39,11 +37,16 @@
def __init__(self, in_ip, in_port):
super(KeystoneDummyApi, self).__init__(in_ip, in_port)
- self.api.add_resource(KeystoneListVersions, "/", resource_class_kwargs={'api': self})
- self.api.add_resource(KeystoneShowAPIv2, "/v2.0", resource_class_kwargs={'api': self})
- self.api.add_resource(KeystoneGetToken, "/v2.0/tokens", resource_class_kwargs={'api': self})
- self.api.add_resource(KeystoneShowAPIv3, "/v3.0", resource_class_kwargs={'api': self})
- self.api.add_resource(KeystoneGetTokenv3, "/v3.0/auth/tokens", resource_class_kwargs={'api': self})
+ self.api.add_resource(KeystoneListVersions, "/",
+ resource_class_kwargs={'api': self})
+ self.api.add_resource(KeystoneShowAPIv2, "/v2.0",
+ resource_class_kwargs={'api': self})
+ self.api.add_resource(KeystoneGetToken, "/v2.0/tokens",
+ resource_class_kwargs={'api': self})
+ self.api.add_resource(KeystoneShowAPIv3, "/v3.0",
+ resource_class_kwargs={'api': self})
+ self.api.add_resource(
+ KeystoneGetTokenv3, "/v3.0/auth/tokens", resource_class_kwargs={'api': self})
class KeystoneListVersions(Resource):
@@ -85,7 +88,8 @@
}]
resp['versions']['values'] = version
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class KeystoneShowAPIv2(Resource):
@@ -106,8 +110,8 @@
"""
LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
- neutron_port = self.api.port + 4696
- heat_port = self.api.port + 3004
+ # neutron_port = self.api.port + 4696
+ # heat_port = self.api.port + 3004
resp = dict()
resp['version'] = {
@@ -127,7 +131,8 @@
]
}
LOG.debug(json.dumps(resp))
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class KeystoneShowAPIv3(Resource):
@@ -148,8 +153,8 @@
"""
LOG.debug("API CALL: %s GET" % str(self.__class__.__name__))
- neutron_port = self.api.port + 4696
- heat_port = self.api.port + 3004
+ # neutron_port = self.api.port + 4696
+ # heat_port = self.api.port + 3004
resp = dict()
resp['version'] = {
@@ -169,7 +174,8 @@
]
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class KeystoneGetToken(Resource):
@@ -208,11 +214,13 @@
token['issued_at'] = "2014-01-30T15:30:58.819Z"
token['expires'] = "2999-01-30T15:30:58.819Z"
- token['id'] = req['auth'].get('token', {'id': 'fc394f2ab2df4114bde39905f800dc57'}).get('id')
+ token['id'] = req['auth'].get(
+ 'token', {'id': 'fc394f2ab2df4114bde39905f800dc57'}).get('id')
token['tenant'] = dict()
token['tenant']['description'] = None
token['tenant']['enabled'] = True
- token['tenant']['id'] = req['auth'].get('tenantId', 'fc394f2ab2df4114bde39905f800dc57')
+ token['tenant']['id'] = req['auth'].get(
+ 'tenantId', 'fc394f2ab2df4114bde39905f800dc57')
token['tenant']['name'] = "tenantName"
ret['access']['user'] = dict()
@@ -220,7 +228,8 @@
user['username'] = req.get('username', "username")
user['name'] = "tenantName"
user['roles_links'] = list()
- user['id'] = token['tenant'].get('id', "fc394f2ab2df4114bde39905f800dc57")
+ user['id'] = token['tenant'].get(
+ 'id', "fc394f2ab2df4114bde39905f800dc57")
user['roles'] = [{'name': 'Member'}]
ret['access']['region_name'] = "RegionOne"
@@ -252,7 +261,7 @@
"endpoints_links": [],
"type": "identity",
"name": "keystone"
- },
+ },
{
"endpoints": [
{
@@ -266,7 +275,7 @@
"endpoints_links": [],
"type": "network",
"name": "neutron"
- },
+ },
{
"endpoints": [
{
@@ -280,7 +289,7 @@
"endpoints_links": [],
"type": "image",
"name": "glance"
- },
+ },
{
"endpoints": [
{
@@ -294,27 +303,29 @@
"endpoints_links": [],
"type": "orchestration",
"name": "heat"
- }
+ }
]
ret['access']["metadata"] = {
- "is_admin": 0,
- "roles": [
- "7598ac3c634d4c3da4b9126a5f67ca2b"
- ]
- },
+ "is_admin": 0,
+ "roles": [
+ "7598ac3c634d4c3da4b9126a5f67ca2b"
+ ]
+ },
ret['access']['trust'] = {
"id": "394998fa61f14736b1f0c1f322882949",
"trustee_user_id": "269348fdd9374b8885da1418e0730af1",
"trustor_user_id": "3ec3164f750146be97f21559ee4d9c51",
"impersonation": False
}
- return Response(json.dumps(ret), status=200, mimetype='application/json')
+ return Response(json.dumps(ret), status=200,
+ mimetype='application/json')
except Exception as ex:
logging.exception("Keystone: Get token failed.")
return ex.message, 500
+
class KeystoneGetTokenv3(Resource):
"""
Returns a static keystone token.
@@ -354,7 +365,8 @@
token['extras'] = dict()
token['user'] = dict()
user = token['user']
- user['id'] = req['auth'].get('token', {'id': 'fc394f2ab2df4114bde39905f800dc57'}).get('id')
+ user['id'] = req['auth'].get(
+ 'token', {'id': 'fc394f2ab2df4114bde39905f800dc57'}).get('id')
user['name'] = "tenantName"
user['password_expires_at'] = None
user['domain'] = {"id": "default", "name": "Default"}
@@ -363,7 +375,7 @@
# project
token['project'] = {
"domain": {
- "id" : "default",
+ "id": "default",
"name": "Default"
},
"id": "8538a3f13f9541b28c2620eb19065e45",
@@ -396,7 +408,7 @@
"id": "2dad48f09e2a447a9bf852bcd93543fc",
"type": "identity",
"name": "keystone"
- },
+ },
{
"endpoints": [
{
@@ -409,7 +421,7 @@
"id": "2dad48f09e2a447a9bf852bcd93548cf",
"type": "network",
"name": "neutron"
- },
+ },
{
"endpoints": [
{
@@ -422,7 +434,7 @@
"id": "2dad48f09e2a447a9bf852bcd93548cf",
"type": "image",
"name": "glance"
- },
+ },
{
"endpoints": [
{
@@ -435,9 +447,10 @@
"id": "2dad48f09e2a447a9bf852bcd93548bf",
"type": "orchestration",
"name": "heat"
- }
+ }
]
- return Response(json.dumps(ret), status=201, mimetype='application/json')
+ return Response(json.dumps(ret), status=201,
+ mimetype='application/json')
except Exception as ex:
logging.exception("Keystone: Get token failed.")
diff --git a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
index 6f6d3dc..154f1ca 100755
--- a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
@@ -1,34 +1,31 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask_restful import Resource
from flask import request, Response
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
-from emuvim.api.openstack.helper import get_host
from datetime import datetime
import neutron_sfc_dummy_api as SFC
import logging
@@ -44,7 +41,8 @@
super(NeutronDummyApi, self).__init__(ip, port)
self.compute = compute
- # create default networks (OSM usually assumes to have these pre-configured)
+ # create default networks (OSM usually assumes to have these
+ # pre-configured)
self.compute.create_network("mgmt")
self.compute.create_network("mgmtnet")
@@ -165,7 +163,8 @@
}]
resp['versions'] = versions
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class NeutronShowAPIv2Details(Resource):
@@ -199,7 +198,7 @@
],
"name": "network",
"collection": "networks"
- },
+ },
{
"links": [
{
@@ -209,10 +208,11 @@
],
"name": "ports",
"collection": "ports"
- }
+ }
]
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
class NeutronListNetworks(Resource):
@@ -232,14 +232,18 @@
try:
if request.args.get('name'):
tmp_network = NeutronShowNetwork(self.api)
- response = tmp_network.get_network(request.args.get('name'), True)
- LOG.debug("{} RESPONSE (1): {}".format(self.__class__.__name__, response))
+ 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)
- response = tmp_network.get_network(request.args.get('id'), True)
- LOG.debug("{} RESPONSE (2): {}".format(self.__class__.__name__, response))
+ response = tmp_network.get_network(
+ request.args.get('id'), True)
+ LOG.debug("{} RESPONSE (2): {}".format(
+ self.__class__.__name__, response))
return response
network_list = list()
@@ -258,12 +262,15 @@
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')
+ 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:
LOG.exception("Neutron: List networks exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronShowNetwork(Resource):
@@ -294,9 +301,11 @@
:rtype: :class:`flask.response`
"""
try:
- net = self.api.compute.find_network_by_name_or_id(network_name_or_id)
+ net = self.api.compute.find_network_by_name_or_id(
+ network_name_or_id)
if net is None:
- return Response(u'Network not found.\n', status=404, mimetype='application/json')
+ return Response(u'Network not found.\n',
+ status=404, mimetype='application/json')
tmp_network_dict = net.create_network_dict()
tmp_dict = dict()
@@ -305,12 +314,13 @@
else:
tmp_dict["network"] = tmp_network_dict
- return Response(json.dumps(tmp_dict), status=200, mimetype='application/json')
-
+ return Response(json.dumps(tmp_dict), status=200,
+ mimetype='application/json')
except Exception as ex:
logging.exception("Neutron: Show network exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronCreateNetwork(Resource):
@@ -332,13 +342,16 @@
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')
+ 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')
+ 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')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronUpdateNetwork(Resource):
@@ -361,7 +374,6 @@
if network_id in self.api.compute.nets:
net = self.api.compute.nets[network_id]
network_dict = json.loads(request.data)
- old_net = copy.copy(net)
if "status" in network_dict["network"]:
net.status = network_dict["network"]["status"]
@@ -372,17 +384,21 @@
if "admin_state_up" in network_dict["network"]:
pass # tmp_network_dict["admin_state_up"] = True
if "tenant_id" in network_dict["network"]:
- pass # tmp_network_dict["tenant_id"] = "c1210485b2424d48804aad5d39c61b8f"
+ # tmp_network_dict["tenant_id"] = "c1210485b2424d48804aad5d39c61b8f"
+ pass
if "shared" in network_dict["network"]:
pass # tmp_network_dict["shared"] = False
- return Response(json.dumps(network_dict), status=200, mimetype='application/json')
+ return Response(json.dumps(network_dict),
+ status=200, mimetype='application/json')
- return Response('Network not found.\n', status=404, mimetype='application/json')
+ return Response('Network not found.\n', status=404,
+ mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Show networks exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronDeleteNetwork(Resource):
@@ -410,7 +426,7 @@
delete_subnet = NeutronDeleteSubnet(self.api)
resp = delete_subnet.delete(net.subnet_id)
- if not '204' in resp.status and not '404' in resp.status:
+ if '204' not in resp.status and '404' not in resp.status:
return resp
self.api.compute.delete_network(network_id)
@@ -418,7 +434,8 @@
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')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronListSubnets(Resource):
@@ -459,11 +476,13 @@
subnet_dict["subnets"] = subnet_list
- return Response(json.dumps(subnet_dict), status=200, mimetype='application/json')
+ return Response(json.dumps(subnet_dict), status=200,
+ mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: List subnets exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronShowSubnet(Resource):
@@ -502,13 +521,16 @@
tmp_dict["subnets"] = [tmp_subnet_dict]
else:
tmp_dict["subnet"] = tmp_subnet_dict
- return Response(json.dumps(tmp_dict), status=200, mimetype='application/json')
+ return Response(json.dumps(tmp_dict),
+ status=200, mimetype='application/json')
- return Response('Subnet not found. (' + subnet_name_or_id + ')\n', status=404, mimetype='application/json')
+ return Response('Subnet not found. (' + subnet_name_or_id +
+ ')\n', status=404, mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Show subnet exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronCreateSubnet(Resource):
@@ -529,15 +551,20 @@
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'])
+ net = self.api.compute.find_network_by_name_or_id(
+ subnet_dict['subnet']['network_id'])
if net is None:
- return Response('Could not find network.\n', status=404, mimetype='application/json')
+ return Response('Could not find network.\n',
+ status=404, mimetype='application/json')
- net.subnet_name = subnet_dict["subnet"].get('name', str(net.name) + '-sub')
+ 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')
+ 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"]:
net.subnet_id = subnet_dict["subnet"]["id"]
@@ -557,11 +584,13 @@
if "enable_dhcp" in subnet_dict["subnet"]:
pass
- return Response(json.dumps({'subnet': net.create_subnet_dict()}), status=201, mimetype='application/json')
+ return Response(json.dumps(
+ {'subnet': net.create_subnet_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')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronUpdateSubnet(Resource):
@@ -606,13 +635,16 @@
net.subnet_update_time = str(datetime.now())
tmp_dict = {'subnet': net.create_subnet_dict()}
- return Response(json.dumps(tmp_dict), status=200, mimetype='application/json')
+ return Response(json.dumps(tmp_dict),
+ status=200, mimetype='application/json')
- return Response('Network not found.\n', status=404, mimetype='application/json')
+ return Response('Network not found.\n', status=404,
+ mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Show networks exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronDeleteSubnet(Resource):
@@ -636,9 +668,11 @@
if net.subnet_id == subnet_id:
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)
+ 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))
+ LOG.warning(
+ "Port search for {} returned None.".format(port_name))
continue
if port.net_name == net.name:
port.ip_address = None
@@ -650,12 +684,15 @@
net.delete_subnet()
- return Response('', status=204, mimetype='application/json')
+ return Response(
+ '', status=204, mimetype='application/json')
- return Response('Could not find subnet.', status=404, mimetype='application/json')
+ return Response('Could not find subnet.',
+ status=404, mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Delete subnet exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronListPorts(Resource):
@@ -695,11 +732,13 @@
port_dict["ports"] = port_list
- return Response(json.dumps(port_dict), status=200, mimetype='application/json')
+ return Response(json.dumps(port_dict), status=200,
+ mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: List ports exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronShowPort(Resource):
@@ -732,17 +771,20 @@
try:
port = self.api.compute.find_port_by_name_or_id(port_name_or_id)
if port is None:
- return Response('Port not found. (' + port_name_or_id + ')\n', status=404, mimetype='application/json')
+ return Response('Port not found. (' + port_name_or_id + ')\n',
+ status=404, mimetype='application/json')
tmp_port_dict = port.create_port_dict(self.api.compute)
tmp_dict = dict()
if as_list:
tmp_dict["ports"] = [tmp_port_dict]
else:
tmp_dict["port"] = tmp_port_dict
- return Response(json.dumps(tmp_dict), status=200, mimetype='application/json')
+ return Response(json.dumps(tmp_dict), status=200,
+ mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Show port exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronCreatePort(Resource):
@@ -764,7 +806,8 @@
net_id = port_dict['port']['network_id']
if net_id not in self.api.compute.nets:
- return Response('Could not find network.\n', status=404, mimetype='application/json')
+ return Response('Could not find network.\n',
+ status=404, mimetype='application/json')
net = self.api.compute.nets[net_id]
if 'name' in port_dict['port']:
@@ -774,7 +817,8 @@
name = "port:cp%s:man:%s" % (num_ports, str(uuid.uuid4()))
if self.api.compute.find_port_by_name_or_id(name):
- return Response("Port with name %s already exists.\n" % name, status=500, mimetype='application/json')
+ return Response("Port with name %s already exists.\n" %
+ name, status=500, mimetype='application/json')
port = self.api.compute.create_port(name)
@@ -796,7 +840,8 @@
if "tenant_id" in port_dict["port"]:
pass
- # add the port to a stack if the specified network is a stack network
+ # add the port to a stack if the specified network is a stack
+ # network
for stack in self.api.compute.stacks.values():
for net in stack.nets.values():
if net.id == net_id:
@@ -806,7 +851,8 @@
mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Show port exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronUpdatePort(Resource):
@@ -829,7 +875,8 @@
port_dict = json.loads(request.data)
port = self.api.compute.find_port_by_name_or_id(port_id)
if port is None:
- return Response("Port with id %s does not exists.\n" % port_id, status=404, mimetype='application/json')
+ return Response("Port with id %s does not exists.\n" %
+ port_id, status=404, mimetype='application/json')
old_port = copy.copy(port)
stack = None
@@ -853,7 +900,8 @@
port.set_name(port_dict["port"]["name"])
if stack is not None:
if port.net_name in stack.nets:
- stack.nets[port.net_name].update_port_name_for_ip_address(port.ip_address, port.name)
+ stack.nets[port.net_name].update_port_name_for_ip_address(
+ port.ip_address, port.name)
stack.ports[port.name] = stack.ports[old_port.name]
del stack.ports[old_port.name]
if "network_id" in port_dict["port"]:
@@ -867,7 +915,8 @@
mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Update port exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronDeletePort(Resource):
@@ -889,7 +938,8 @@
try:
port = self.api.compute.find_port_by_name_or_id(port_id)
if port is None:
- return Response("Port with id %s does not exists.\n" % port_id, status=404)
+ return Response("Port with id %s does not exists.\n" %
+ port_id, status=404)
stack = None
for s in self.api.compute.stacks.values():
for p in s.ports.values():
@@ -897,7 +947,8 @@
stack = s
if stack is not None:
if port.net_name in stack.nets:
- stack.nets[port.net_name].withdraw_ip_address(port.ip_address)
+ stack.nets[port.net_name].withdraw_ip_address(
+ port.ip_address)
for server in stack.servers.values():
try:
server.port_names.remove(port.name)
@@ -911,7 +962,8 @@
except Exception as ex:
LOG.exception("Neutron: Delete port exception.")
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class NeutronAddFloatingIp(Resource):
@@ -944,7 +996,8 @@
ip["floating_ip_address"] = "172.0.0.%d" % i
ip["fixed_ip_address"] = "10.0.0.%d" % i
resp["floatingips"].append(ip)
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
def post(self):
"""
@@ -972,7 +1025,8 @@
status=400, mimetype='application/json')
if port.floating_ip is not None:
- return Response("We allow only one floating ip per port\n", status=400, mimetype='application/json')
+ return Response("We allow only one floating ip per port\n",
+ status=400, mimetype='application/json')
else:
num_ports = len(self.api.compute.ports)
name = "port:cp%s:fl:%s" % (num_ports, str(uuid.uuid4()))
@@ -992,7 +1046,9 @@
resp["floating_ip_address"] = port.floating_ip
resp["fixed_ip_address"] = port.floating_ip
- return Response(json.dumps(response), status=200, mimetype='application/json')
+ return Response(json.dumps(response), status=200,
+ mimetype='application/json')
except Exception as ex:
LOG.exception("Neutron: Create FloatingIP exception %s.", ex)
- return Response(ex.message, status=500, mimetype='application/json')
+ return Response(ex.message, status=500,
+ mimetype='application/json')
diff --git a/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py
index 1494bce..f2ea6bb 100644
--- a/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py
@@ -1,38 +1,32 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask_restful import Resource
from flask import request, Response
import logging
import json
-import uuid
-
-from emuvim.api.openstack.resources.port_chain import PortChain
-from emuvim.api.openstack.helper import get_host
class SFC(Resource):
@@ -52,8 +46,10 @@
request_dict = json.loads(request.data).get("port_pair")
name = request_dict["name"]
- ingress_port = self.api.compute.find_port_by_name_or_id(request_dict["ingress"])
- egress_port = self.api.compute.find_port_by_name_or_id(request_dict["egress"])
+ ingress_port = self.api.compute.find_port_by_name_or_id(
+ request_dict["ingress"])
+ egress_port = self.api.compute.find_port_by_name_or_id(
+ request_dict["egress"])
port_pair = self.api.compute.create_port_pair(name)
port_pair.ingress = ingress_port
@@ -66,10 +62,13 @@
resp = {
"port_pair": port_pair.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=201, mimetype='application/json')
+ return Response(json.dumps(resp), status=201,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairsUpdate(SFC):
@@ -87,10 +86,13 @@
resp = {
"port_pair": port_pair.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairsDelete(SFC):
@@ -102,8 +104,10 @@
return Response("", status=204,
mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairsList(SFC):
@@ -115,10 +119,13 @@
port_pair_list.append(port_pair.create_dict(self.api.compute))
resp = {"port_pairs": port_pair_list}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairsShow(SFC):
@@ -130,10 +137,13 @@
resp = {
"port_pair": port_pair.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
###############################################################################
@@ -147,20 +157,25 @@
try:
request_dict = json.loads(request.data).get("port_pair_group")
- port_pair_group = self.api.compute.create_port_pair_group(request_dict["name"])
+ port_pair_group = self.api.compute.create_port_pair_group(
+ request_dict["name"])
port_pair_group.port_pairs = request_dict["port_pairs"]
if "description" in request_dict:
port_pair_group.description = request_dict["description"]
if "port_pair_group_parameters" in request_dict:
- port_pair_group.port_pair_group_parameters = request_dict["port_pair_group_parameters"]
+ port_pair_group.port_pair_group_parameters = request_dict[
+ "port_pair_group_parameters"]
resp = {
"port_pair_group": port_pair_group.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=201, mimetype='application/json')
+ return Response(json.dumps(resp), status=201,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairGroupUpdate(SFC):
@@ -169,7 +184,8 @@
try:
request_dict = json.loads(request.data).get("port_pair_group")
- port_pair_group = self.api.compute.find_port_pair_group_by_name_or_id(group_id)
+ port_pair_group = self.api.compute.find_port_pair_group_by_name_or_id(
+ group_id)
if "name" in request_dict:
port_pair_group.name = request_dict["name"]
if "description" in request_dict:
@@ -180,10 +196,13 @@
resp = {
"port_pair_group": port_pair_group.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairGroupDelete(SFC):
@@ -195,8 +214,10 @@
return Response("", status=204,
mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairGroupList(SFC):
@@ -205,13 +226,17 @@
try:
port_pair_group_list = []
for port_pair_group in self.api.compute.port_pair_groups.values():
- port_pair_group_list.append(port_pair_group.create_dict(self.api.compute))
+ port_pair_group_list.append(
+ port_pair_group.create_dict(self.api.compute))
resp = {"port_pair_groups": port_pair_group_list}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortPairGroupShow(SFC):
@@ -219,14 +244,18 @@
logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
- port_pair_group = self.api.compute.find_port_pair_group_by_name_or_id(group_id)
+ port_pair_group = self.api.compute.find_port_pair_group_by_name_or_id(
+ group_id)
resp = {
"port_pair_group": port_pair_group.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
###############################################################################
@@ -240,7 +269,8 @@
try:
request_dict = json.loads(request.data).get("flow_classifier")
- flow_classifier = self.api.compute.create_flow_classifier(request_dict["name"])
+ flow_classifier = self.api.compute.create_flow_classifier(
+ request_dict["name"])
if "description" in request_dict:
flow_classifier.description = request_dict["description"]
if "ethertype" in request_dict:
@@ -252,9 +282,11 @@
if "source_port_range_max" in request_dict:
flow_classifier.source_port_range_max = request_dict["source_port_range_max"]
if "destination_port_range_min" in request_dict:
- flow_classifier.destination_port_range_min = request_dict["destination_port_range_min"]
+ flow_classifier.destination_port_range_min = request_dict[
+ "destination_port_range_min"]
if "destination_port_range_max" in request_dict:
- flow_classifier.destination_port_range_max = request_dict["destination_port_range_max"]
+ flow_classifier.destination_port_range_max = request_dict[
+ "destination_port_range_max"]
if "source_ip_prefix" in request_dict:
flow_classifier.source_ip_prefix = request_dict["source_ip_prefix"]
if "destination_ip_prefix" in request_dict:
@@ -269,10 +301,13 @@
resp = {
"flow_classifier": flow_classifier.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=201, mimetype='application/json')
+ return Response(json.dumps(resp), status=201,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class FlowClassifierUpdate(SFC):
@@ -281,7 +316,8 @@
try:
request_dict = json.loads(request.data).get("flow_classifier")
- flow_classifier = self.api.compute.find_flow_classifier_by_name_or_id(flow_classifier_id)
+ flow_classifier = self.api.compute.find_flow_classifier_by_name_or_id(
+ flow_classifier_id)
if "name" in request_dict:
flow_classifier.name = request_dict["name"]
if "description" in request_dict:
@@ -290,10 +326,13 @@
resp = {
"flow_classifier": flow_classifier.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class FlowClassifierDelete(SFC):
@@ -305,8 +344,10 @@
return Response("", status=204,
mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class FlowClassifierList(SFC):
@@ -315,13 +356,17 @@
try:
flow_classifier_list = []
for flow_classifier in self.api.compute.flow_classifiers.values():
- flow_classifier_list.append(flow_classifier.create_dict(self.api.compute))
+ flow_classifier_list.append(
+ flow_classifier.create_dict(self.api.compute))
resp = {"flow_classifiers": flow_classifier_list}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class FlowClassifierShow(SFC):
@@ -329,14 +374,18 @@
logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
- flow_classifier = self.api.compute.find_flow_classifier_by_name_or_id(flow_classifier_id)
+ flow_classifier = self.api.compute.find_flow_classifier_by_name_or_id(
+ flow_classifier_id)
resp = {
"flow_classifier": flow_classifier.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
###############################################################################
@@ -350,7 +399,8 @@
try:
request_dict = json.loads(request.data).get("port_chain")
- port_chain = self.api.compute.create_port_chain(request_dict["name"])
+ port_chain = self.api.compute.create_port_chain(
+ request_dict["name"])
port_chain.port_pair_groups = request_dict["port_pair_groups"]
if "description" in request_dict:
port_chain.description = request_dict["description"]
@@ -364,10 +414,13 @@
resp = {
"port_chain": port_chain.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=201, mimetype='application/json')
+ return Response(json.dumps(resp), status=201,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortChainUpdate(SFC):
@@ -394,10 +447,13 @@
resp = {
"port_chain": port_chain.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortChainDelete(SFC):
@@ -409,8 +465,10 @@
return Response("", status=204,
mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortChainList(SFC):
@@ -419,13 +477,17 @@
try:
port_chain_list = []
for port_chain in self.api.compute.port_chains.values():
- port_chain_list.append(port_chain.create_dict(self.api.compute))
+ port_chain_list.append(
+ port_chain.create_dict(self.api.compute))
resp = {"port_chains": port_chain_list}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
class PortChainShow(SFC):
@@ -433,11 +495,15 @@
logging.debug("API CALL: %s GET" % str(self.__class__.__name__))
try:
- port_chain = self.api.compute.find_port_chain_by_name_or_id(chain_id)
+ port_chain = self.api.compute.find_port_chain_by_name_or_id(
+ chain_id)
resp = {
"port_chain": port_chain.create_dict(self.api.compute)
}
- return Response(json.dumps(resp), status=200, mimetype='application/json')
+ return Response(json.dumps(resp), status=200,
+ mimetype='application/json')
except Exception as ex:
- logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__))
- return Response(ex.message, status=500, mimetype='application/json')
+ logging.exception("Neutron SFC: %s Exception." %
+ str(self.__class__.__name__))
+ return Response(ex.message, status=500,
+ mimetype='application/json')
diff --git a/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py
index 9dcfa48..e12fb05 100755
--- a/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from flask_restful import Resource
from flask import Response, request
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
@@ -202,12 +200,14 @@
resp['servers'].append(s)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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):
@@ -227,12 +227,12 @@
if self.api.compute.find_server_by_name_or_id(name) is not None:
LOG.error("Server with name %s already exists. 409" % name)
- return Response("Server with name %s already exists." % name, status=409)
+ return Response(
+ "Server with name %s already exists." % name, status=409)
# TODO: not finished!
- resp = dict()
-
server = self.api.compute.create_server(name)
- server.full_name = str(self.api.compute.dc.label) + "_" + server_dict["name"]
+ server.full_name = str(
+ self.api.compute.dc.label) + "_" + server_dict["name"]
server.template_name = server_dict["name"]
if "metadata" in server_dict:
server.properties = server_dict["metadata"]
@@ -246,11 +246,13 @@
if networks is not None:
for net in networks:
- port = self.api.compute.find_port_by_name_or_id(net.get('port', ""))
+ port = self.api.compute.find_port_by_name_or_id(
+ net.get('port', ""))
if port is not None:
server.port_names.append(port.name)
else:
- return Response("Currently only networking by port is supported.", status=400)
+ return Response(
+ "Currently only networking by port is supported.", status=400)
self.api.compute._start_compute(server)
@@ -301,12 +303,14 @@
resp['servers'].append(s)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
@@ -363,12 +367,14 @@
resp['servers'].append(s)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
@@ -399,12 +405,14 @@
flavor.id)}]
resp['flavors'].append(f)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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):
@@ -424,7 +432,8 @@
id,
f.id)}]
resp = {"flavor": data}
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
class NovaListFlavorsDetails(Resource):
@@ -463,12 +472,14 @@
f['rxtx_factor'] = 1.0
resp['flavors'].append(f)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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):
@@ -488,7 +499,8 @@
id,
f.id)}]
resp = {"flavor": data}
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
class NovaListFlavorById(Resource):
@@ -522,12 +534,14 @@
self.api.port,
id,
flavor.id)}]
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
def delete(self, id, flavorid):
@@ -565,12 +579,14 @@
id,
image.id)}]
resp['images'].append(f)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
@@ -609,12 +625,14 @@
}
resp['images'].append(f)
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
@@ -642,14 +660,17 @@
i['id'] = image.id
i['name'] = image.name
- return Response(json.dumps(resp), status=200, mimetype="application/json")
+ return Response(json.dumps(resp), status=200,
+ mimetype="application/json")
- response = Response("Image with id or name %s does not exists." % imageid, status=404)
+ response = Response(
+ "Image with id or name %s does not exists." % imageid, status=404)
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
def delete(self, id, imageid):
@@ -680,7 +701,8 @@
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)
+ return Response(
+ "Server with id or name %s does not exists." % serverid, status=404)
s = server.create_server_dict()
s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (get_host(request),
self.api.port,
@@ -714,12 +736,14 @@
]
}
- response = Response(json.dumps({'server': s}), status=200, mimetype="application/json")
+ response = Response(json.dumps(
+ {'server': s}), status=200, mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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):
@@ -737,7 +761,8 @@
try:
server = self.api.compute.find_server_by_name_or_id(serverid)
if server is None:
- return Response('Could not find server.', status=404, mimetype="application/json")
+ return Response('Could not find server.',
+ status=404, mimetype="application/json")
self.api.compute.stop_compute(server)
@@ -769,11 +794,13 @@
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)
+ return Response(
+ "Server with id or name %s does not exists." % serverid, status=404)
if server.emulator_compute is None:
LOG.error("The targeted container does not exist.")
- return Response("The targeted container of %s does not exist." % serverid, status=404)
+ return Response(
+ "The targeted container of %s does not exist." % serverid, status=404)
data = json.loads(request.data).get("interfaceAttachment")
resp = dict()
port = data.get("port_id", None)
@@ -791,7 +818,8 @@
elif net is not None:
network = self.api.compute.find_network_by_name_or_id(net)
if network is None:
- return Response("Network with id or name %s does not exists." % net, status=404)
+ return Response(
+ "Network with id or name %s does not exists." % net, status=404)
port = self.api.compute.create_port("port:cp%s:fl:%s" %
(len(self.api.compute.ports), str(uuid.uuid4())))
@@ -804,10 +832,12 @@
port = self.api.compute.find_port_by_name_or_id(port)
network_dict['id'] = port.intf_name
network_dict['ip'] = port.ip_address
- network = self.api.compute.find_network_by_name_or_id(port.net_name)
+ network = self.api.compute.find_network_by_name_or_id(
+ port.net_name)
network_dict[network_dict['id']] = network.name
else:
- raise Exception("You can only attach interfaces by port or network at the moment")
+ raise Exception(
+ "You can only attach interfaces by port or network at the moment")
if network == self.api.manage.floating_network:
dc.net.addLink(server.emulator_compute, self.api.manage.floating_switch,
@@ -817,19 +847,22 @@
params1=network_dict, cls=Link, intfName1=port.intf_name)
resp["port_state"] = "ACTIVE"
resp["port_id"] = port.id
- resp["net_id"] = self.api.compute.find_network_by_name_or_id(port.net_name).id
+ resp["net_id"] = self.api.compute.find_network_by_name_or_id(
+ port.net_name).id
resp["mac_addr"] = port.mac_address
resp["fixed_ips"] = list()
fixed_ips = dict()
fixed_ips["ip_address"] = port.ip_address
fixed_ips["subnet_id"] = network.subnet_name
resp["fixed_ips"].append(fixed_ips)
- response = Response(json.dumps({"interfaceAttachment": resp}), status=202, mimetype="application/json")
+ response = Response(json.dumps(
+ {"interfaceAttachment": resp}), status=202, mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
@@ -855,14 +888,16 @@
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)
+ return Response(
+ "Server with id or name %s does not exists." % serverid, status=404)
port = self.api.compute.find_port_by_name_or_id(port_id)
if port is None:
- return Response("Port with id or name %s does not exists." % port_id, status=404)
+ return Response(
+ "Port with id or name %s does not exists." % port_id, status=404)
for link in self.api.compute.dc.net.links:
if str(link.intf1) == port.intf_name and \
- str(link.intf1.ip) == port.ip_address.split('/')[0]:
+ str(link.intf1.ip) == port.ip_address.split('/')[0]:
self.api.compute.dc.net.removeLink(link)
break
@@ -871,7 +906,8 @@
return response
except Exception as ex:
- LOG.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
@@ -919,10 +955,12 @@
"rate": []
}
}
- response = Response(json.dumps(resp), status=200, mimetype="application/json")
+ response = Response(json.dumps(resp), status=200,
+ mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
return response
except Exception as ex:
- LOG.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
diff --git a/src/emuvim/api/openstack/resources/__init__.py b/src/emuvim/api/openstack/resources/__init__.py
index e252c1e..d888119 100755
--- a/src/emuvim/api/openstack/resources/__init__.py
+++ b/src/emuvim/api/openstack/resources/__init__.py
@@ -1,41 +1,25 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-from instance_flavor import InstanceFlavor
-from model import Model
-from net import Net
-from port import Port
-from port_pair import PortPair
-from port_pair_group import PortPairGroup
-from flow_classifier import FlowClassifier
-from port_chain import PortChain
-from resource import Resource
-from router import Router
-from server import Server
-from stack import Stack
-from template import Template
-from image import Image
\ No newline at end of file
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
diff --git a/src/emuvim/api/openstack/resources/flow_classifier.py b/src/emuvim/api/openstack/resources/flow_classifier.py
index 5b50c92..284fee8 100644
--- a/src/emuvim/api/openstack/resources/flow_classifier.py
+++ b/src/emuvim/api/openstack/resources/flow_classifier.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
diff --git a/src/emuvim/api/openstack/resources/image.py b/src/emuvim/api/openstack/resources/image.py
index 715d0f9..3d9c66b 100755
--- a/src/emuvim/api/openstack/resources/image.py
+++ b/src/emuvim/api/openstack/resources/image.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
from datetime import datetime
diff --git a/src/emuvim/api/openstack/resources/instance_flavor.py b/src/emuvim/api/openstack/resources/instance_flavor.py
index 90f7fe5..1e7b6f6 100755
--- a/src/emuvim/api/openstack/resources/instance_flavor.py
+++ b/src/emuvim/api/openstack/resources/instance_flavor.py
@@ -1,35 +1,34 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
class InstanceFlavor:
- def __init__(self, name, cpu=None, memory=None, memory_unit=None, storage=None, storage_unit=None):
+ def __init__(self, name, cpu=None, memory=None,
+ memory_unit=None, storage=None, storage_unit=None):
self.id = str(uuid.uuid4())
self.name = name
self.cpu = cpu
diff --git a/src/emuvim/api/openstack/resources/load_balancer.py b/src/emuvim/api/openstack/resources/load_balancer.py
index 39be655..0938203 100755
--- a/src/emuvim/api/openstack/resources/load_balancer.py
+++ b/src/emuvim/api/openstack/resources/load_balancer.py
@@ -1,32 +1,33 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
class LoadBalancer(object):
- def __init__(self, name, id=None, flavor=None, image=None, command=None, nw_list=None):
+ def __init__(self, name, id=None, flavor=None,
+ image=None, command=None, nw_list=None):
self.name = name
self.id = id # not set
self.out_ports = dict()
diff --git a/src/emuvim/api/openstack/resources/model.py b/src/emuvim/api/openstack/resources/model.py
index ea5c054..ae7ceff 100755
--- a/src/emuvim/api/openstack/resources/model.py
+++ b/src/emuvim/api/openstack/resources/model.py
@@ -1,30 +1,30 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
class Model:
def __init__(self, resources=None):
if not resources:
diff --git a/src/emuvim/api/openstack/resources/net.py b/src/emuvim/api/openstack/resources/net.py
index db38348..112cca6 100755
--- a/src/emuvim/api/openstack/resources/net.py
+++ b/src/emuvim/api/openstack/resources/net.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import re
@@ -63,9 +61,11 @@
if self.start_end_dict is None:
return None
- int_start_ip = Net.ip_2_int(self.start_end_dict['start']) + 2 # First address as network address not usable
+ # First address as network address not usable
+ int_start_ip = Net.ip_2_int(self.start_end_dict['start']) + 2
# Second one is for gateways only
- int_end_ip = Net.ip_2_int(self.start_end_dict['end']) - 1 # Last address for broadcasts
+ # Last address for broadcasts
+ int_end_ip = Net.ip_2_int(self.start_end_dict['end']) - 1
while int_start_ip in self._issued_ip_addresses and int_start_ip <= int_end_ip:
int_start_ip += 1
@@ -90,8 +90,10 @@
if int_ip in self._issued_ip_addresses:
return False
- int_start_ip = Net.ip_2_int(self.start_end_dict['start']) + 1 # First address as network address not usable
- int_end_ip = Net.ip_2_int(self.start_end_dict['end']) - 1 # Last address for broadcasts
+ # First address as network address not usable
+ int_start_ip = Net.ip_2_int(self.start_end_dict['start']) + 1
+ # Last address for broadcasts
+ int_end_ip = Net.ip_2_int(self.start_end_dict['end']) - 1
if int_ip < int_start_ip or int_ip > int_end_ip:
return False
@@ -110,7 +112,7 @@
"""
int_ip = Net.cidr_2_int(cidr)
- if not int_ip in self._issued_ip_addresses:
+ if int_ip not in self._issued_ip_addresses:
return False
if self._issued_ip_addresses[int_ip] == port_name:
@@ -285,14 +287,16 @@
:rtype: ``dict``
"""
network_dict = dict()
- network_dict["status"] = "ACTIVE" # TODO do we support inactive networks?
- if self.subnet_id == None:
+ # TODO do we support inactive networks?
+ network_dict["status"] = "ACTIVE"
+ if self.subnet_id is None:
network_dict["subnets"] = []
else:
network_dict["subnets"] = [self.subnet_id]
network_dict["name"] = self.name
network_dict["admin_state_up"] = True # TODO is it always true?
- network_dict["tenant_id"] = "abcdefghijklmnopqrstuvwxyz123456" # TODO what should go in here
+ # TODO what should go in here
+ network_dict["tenant_id"] = "abcdefghijklmnopqrstuvwxyz123456"
network_dict["id"] = self.id
network_dict["shared"] = False # TODO is it always false?
return network_dict
@@ -307,7 +311,8 @@
subnet_dict = dict()
subnet_dict["name"] = self.subnet_name
subnet_dict["network_id"] = self.id
- subnet_dict["tenant_id"] = "abcdefghijklmnopqrstuvwxyz123456" # TODO what should go in here?
+ # TODO what should go in here?
+ subnet_dict["tenant_id"] = "abcdefghijklmnopqrstuvwxyz123456"
subnet_dict["created_at"] = self.subnet_creation_time
subnet_dict["dns_nameservers"] = []
subnet_dict["allocation_pools"] = [self.start_end_dict]
@@ -322,10 +327,10 @@
def __eq__(self, other):
if self.name == other.name and self.subnet_name == other.subnet_name and \
- self.gateway_ip == other.gateway_ip and \
- self.segmentation_id == other.segmentation_id and \
- self._cidr == other._cidr and \
- self.start_end_dict == other.start_end_dict:
+ self.gateway_ip == other.gateway_ip and \
+ self.segmentation_id == other.segmentation_id and \
+ self._cidr == other._cidr and \
+ self.start_end_dict == other.start_end_dict:
return True
return False
diff --git a/src/emuvim/api/openstack/resources/port.py b/src/emuvim/api/openstack/resources/port.py
index 2e4d693..1d82e92 100755
--- a/src/emuvim/api/openstack/resources/port.py
+++ b/src/emuvim/api/openstack/resources/port.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import logging
import threading
import uuid
@@ -34,7 +32,8 @@
class Port:
- def __init__(self, name, ip_address=None, mac_address=None, floating_ip=None):
+ def __init__(self, name, ip_address=None,
+ mac_address=None, floating_ip=None):
self.name = name
self.intf_name = None
self.id = str(uuid.uuid4())
@@ -80,13 +79,13 @@
if len(split_name) >= 3:
if split_name[2] == 'input' or split_name[2] == 'in':
self.intf_name = split_name[0][:4] + '-' + \
- 'in'
+ 'in'
elif split_name[2] == 'output' or split_name[2] == 'out':
self.intf_name = split_name[0][:4] + '-' + \
- 'out'
+ 'out'
else:
self.intf_name = split_name[0][:4] + '-' + \
- split_name[2][:4]
+ split_name[2][:4]
else:
self.intf_name = self.name[:9]
@@ -96,12 +95,14 @@
global intf_names
intf_len = len(self.intf_name)
self.intf_name = self.intf_name + '-' + str(counter)[:4]
- while self.intf_name in intf_names and counter < 999 and not intf_names[self.intf_name][0] == self.id:
+ while self.intf_name in intf_names and counter < 999 and not intf_names[
+ self.intf_name][0] == self.id:
counter += 1
self.intf_name = self.intf_name[:intf_len] + '-' + str(counter)[:4]
if counter >= 1000:
- logging.ERROR("Port %s could not create unique interface name (%s)", self.name, self.intf_name)
+ logging.ERROR(
+ "Port %s could not create unique interface name (%s)", self.name, self.intf_name)
lock.release()
return
@@ -132,7 +133,8 @@
"""
port_dict = dict()
port_dict["admin_state_up"] = True # TODO is it always true?
- port_dict["device_id"] = "257614cc-e178-4c92-9c61-3b28d40eca44" # TODO find real values
+ # TODO find real values
+ port_dict["device_id"] = "257614cc-e178-4c92-9c61-3b28d40eca44"
port_dict["device_owner"] = "" # TODO do we have such things?
net = compute.find_network_by_name_or_id(self.net_name)
port_dict["fixed_ips"] = [
@@ -146,7 +148,8 @@
port_dict["name"] = self.name
port_dict["network_id"] = net.id if net is not None else ""
port_dict["status"] = "ACTIVE" # TODO do we support inactive port?
- port_dict["tenant_id"] = "abcdefghijklmnopqrstuvwxyz123456" # TODO find real tenant_id
+ # TODO find real tenant_id
+ port_dict["tenant_id"] = "abcdefghijklmnopqrstuvwxyz123456"
return port_dict
def compare_attributes(self, other):
@@ -163,7 +166,7 @@
return False
if self.name == other.name and self.floating_ip == other.floating_ip and \
- self.net_name == other.net_name:
+ self.net_name == other.net_name:
return True
return False
@@ -172,9 +175,9 @@
return False
if self.name == other.name and self.ip_address == other.ip_address and \
- self.mac_address == other.mac_address and \
- self.floating_ip == other.floating_ip and \
- self.net_name == other.net_name:
+ self.mac_address == other.mac_address and \
+ self.floating_ip == other.floating_ip and \
+ self.net_name == other.net_name:
return True
return False
diff --git a/src/emuvim/api/openstack/resources/port_chain.py b/src/emuvim/api/openstack/resources/port_chain.py
index d82c9b1..dfdd2d3 100644
--- a/src/emuvim/api/openstack/resources/port_chain.py
+++ b/src/emuvim/api/openstack/resources/port_chain.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import random
import uuid
import logging
@@ -40,7 +38,8 @@
self.flow_classifiers = list()
self.chain_parameters = dict()
- # Cookie for internal identification of installed flows (e.g. to delete them)
+ # Cookie for internal identification of installed flows (e.g. to delete
+ # them)
self.cookie = random.randint(1, 0xffffffff)
def create_dict(self, compute):
@@ -56,13 +55,16 @@
def install(self, compute):
for flow_classifier_id in self.flow_classifiers:
- flow_classifier = compute.find_flow_classifier_by_name_or_id(flow_classifier_id)
+ flow_classifier = compute.find_flow_classifier_by_name_or_id(
+ flow_classifier_id)
if flow_classifier:
pass
- # TODO: for every flow classifier create match and pass it to setChain
+ # TODO: for every flow classifier create match and pass it to
+ # setChain
for group_id in self.port_pair_groups:
- port_pair_group = compute.find_port_pair_group_by_name_or_id(group_id)
+ port_pair_group = compute.find_port_pair_group_by_name_or_id(
+ group_id)
for port_pair_id in port_pair_group.port_pairs:
port_pair = compute.find_port_pair_by_name_or_id(port_pair_id)
@@ -76,10 +78,12 @@
# TODO: Not sure, if this should throw an error
if not server_ingress:
- logging.warn("Neutron SFC: ingress port %s not connected." % str(port_pair.ingress.name))
+ logging.warn("Neutron SFC: ingress port %s not connected." % str(
+ port_pair.ingress.name))
continue
if not server_egress:
- logging.warn("Neutron SFC: egress port %s not connected." % str(port_pair.egress.name))
+ logging.warn("Neutron SFC: egress port %s not connected." % str(
+ port_pair.egress.name))
continue
compute.dc.net.setChain(
diff --git a/src/emuvim/api/openstack/resources/port_pair.py b/src/emuvim/api/openstack/resources/port_pair.py
index 52a4ba0..a2e31bc 100644
--- a/src/emuvim/api/openstack/resources/port_pair.py
+++ b/src/emuvim/api/openstack/resources/port_pair.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
diff --git a/src/emuvim/api/openstack/resources/port_pair_group.py b/src/emuvim/api/openstack/resources/port_pair_group.py
index 75a5d0e..fd97917 100644
--- a/src/emuvim/api/openstack/resources/port_pair_group.py
+++ b/src/emuvim/api/openstack/resources/port_pair_group.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
diff --git a/src/emuvim/api/openstack/resources/resource.py b/src/emuvim/api/openstack/resources/resource.py
index efa33b1..9a33ebf 100755
--- a/src/emuvim/api/openstack/resources/resource.py
+++ b/src/emuvim/api/openstack/resources/resource.py
@@ -1,30 +1,30 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
class Resource:
def __init__(self, name, type=None, properties=None):
self.name = name
diff --git a/src/emuvim/api/openstack/resources/router.py b/src/emuvim/api/openstack/resources/router.py
index 27abf53..3d30e1b 100755
--- a/src/emuvim/api/openstack/resources/router.py
+++ b/src/emuvim/api/openstack/resources/router.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
@@ -39,6 +37,6 @@
def __eq__(self, other):
if self.name == other.name and len(self.subnet_names) == len(other.subnet_names) and \
- set(self.subnet_names) == set(other.subnet_names):
+ set(self.subnet_names) == set(other.subnet_names):
return True
return False
diff --git a/src/emuvim/api/openstack/resources/server.py b/src/emuvim/api/openstack/resources/server.py
index 2224de9..48f1898 100755
--- a/src/emuvim/api/openstack/resources/server.py
+++ b/src/emuvim/api/openstack/resources/server.py
@@ -1,32 +1,33 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
class Server(object):
- def __init__(self, name, id=None, flavor=None, image=None, command=None, nw_list=None):
+ def __init__(self, name, id=None, flavor=None,
+ image=None, command=None, nw_list=None):
self.name = name
self.full_name = None
self.template_name = None
@@ -50,19 +51,19 @@
:rtype: ``bool``
"""
if self.name == other.name and self.full_name == other.full_name and \
- self.flavor == other.flavor and \
- self.image == other.image and \
- self.command == other.command:
+ self.flavor == other.flavor and \
+ self.image == other.image and \
+ self.command == other.command:
return True
return False
def __eq__(self, other):
if self.name == other.name and self.full_name == other.full_name and \
- self.flavor == other.flavor and \
- self.image == other.image and \
- self.command == other.command and \
- len(self.port_names) == len(other.port_names) and \
- set(self.port_names) == set(other.port_names):
+ self.flavor == other.flavor and \
+ self.image == other.image and \
+ self.command == other.command and \
+ len(self.port_names) == len(other.port_names) and \
+ set(self.port_names) == set(other.port_names):
return True
return False
diff --git a/src/emuvim/api/openstack/resources/stack.py b/src/emuvim/api/openstack/resources/stack.py
index 453e20c..cabaffa 100755
--- a/src/emuvim/api/openstack/resources/stack.py
+++ b/src/emuvim/api/openstack/resources/stack.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import uuid
diff --git a/src/emuvim/api/openstack/resources/template.py b/src/emuvim/api/openstack/resources/template.py
index 5b1ebe9..bbb7713 100755
--- a/src/emuvim/api/openstack/resources/template.py
+++ b/src/emuvim/api/openstack/resources/template.py
@@ -1,30 +1,30 @@
-"""
-Copyright (c) 2017 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV, Paderborn University
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
class Template:
def __init__(self, resources=None):
self.version = '2015-04-30'