migration to python3 (#1)

Change-Id: I964b75c1316b7711cde905c6e98ea027a8557047
Signed-off-by: peusterm <manuel.peuster@uni-paderborn.de>
diff --git a/src/emuvim/api/openstack/chain_api.py b/src/emuvim/api/openstack/chain_api.py
index 21cb65b..7f38a7e 100755
--- a/src/emuvim/api/openstack/chain_api.py
+++ b/src/emuvim/api/openstack/chain_api.py
@@ -513,7 +513,7 @@
         # search for related OpenStackAPIs
         api_src = None
         api_dst = None
-        from openstack_api_endpoint import OpenstackApiEndpoint
+        from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
         for api in OpenstackApiEndpoint.dc_apis:
             if api.compute.dc == dc_src:
                 api_src = api
@@ -711,7 +711,7 @@
         dc_real = self.api.manage.net.dcs[dc]
         # search for related OpenStackAPIs
         api_real = None
-        from openstack_api_endpoint import OpenstackApiEndpoint
+        from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
         for api in OpenstackApiEndpoint.dc_apis:
             if api.compute.dc == dc_real:
                 api_real = api
diff --git a/src/emuvim/api/openstack/compute.py b/src/emuvim/api/openstack/compute.py
index 9d77a44..4999331 100755
--- a/src/emuvim/api/openstack/compute.py
+++ b/src/emuvim/api/openstack/compute.py
@@ -25,22 +25,22 @@
 # partner consortium (www.sonata-nfv.eu).
 from mininet.link import Link
 
-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 emuvim.api.openstack.resources.instance_flavor import InstanceFlavor
+from emuvim.api.openstack.resources.net import Net
+from emuvim.api.openstack.resources.port import Port
+from emuvim.api.openstack.resources.port_pair import PortPair
+from emuvim.api.openstack.resources.port_pair_group import PortPairGroup
+from emuvim.api.openstack.resources.flow_classifier import FlowClassifier
+from emuvim.api.openstack.resources.port_chain import PortChain
+from emuvim.api.openstack.resources.server import Server
+from emuvim.api.openstack.resources.image import Image
 
 from docker import DockerClient
 import logging
 import threading
 import uuid
 import time
-import ip_handler as IP
+import emuvim.api.openstack.ip_handler as IP
 import hashlib
 
 
@@ -232,8 +232,12 @@
         for server in self.stacks[stack_id].servers.values():
             self.stop_compute(server)
             self.delete_server(server)
-        for net in self.stacks[stack_id].nets.values():
-            self.delete_network(net.id)
+        stack = list(self.stacks[stack_id].nets.values())
+        while stack:
+            id = stack.pop().id
+            self.delete_network(id)
+        # for net in self.stacks[stack_id].nets.values():
+        # self.delete_network(net.id)
         for port in self.stacks[stack_id].ports.values():
             self.delete_port(port.id)
 
@@ -592,7 +596,7 @@
         """
         if len(name) > char_limit:
             # construct a short name
-            h = hashlib.sha224(name).hexdigest()
+            h = hashlib.sha224(name.encode()).hexdigest()
             h = h[0:char_limit]
             LOG.debug("Shortened server name '%s' to '%s'" % (name, h))
         return name
@@ -630,6 +634,7 @@
         """
         if name_or_id in self.nets:
             return self.nets[name_or_id]
+        print("name_or_id: ", name_or_id)
         for net in self.nets.values():
             if net.name == name_or_id:
                 return net
@@ -710,10 +715,10 @@
         if name_or_id in self.ports:
             return self.ports[name_or_id]
         # find by name
-        matching_ports = filter(
+        matching_ports = list(filter(
             lambda port: port.name == name_or_id or port.template_name == name_or_id,
             self.ports.values()
-        )
+        ))
         matching_ports_count = len(matching_ports)
         if matching_ports_count == 1:
             return matching_ports[0]
diff --git a/src/emuvim/api/openstack/heat_parser.py b/src/emuvim/api/openstack/heat_parser.py
index ffcaa0a..8923d72 100755
--- a/src/emuvim/api/openstack/heat_parser.py
+++ b/src/emuvim/api/openstack/heat_parser.py
@@ -23,14 +23,15 @@
 # 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.router import Router
+# TODO remove when print is no longer needed for debugging
+from __future__ import print_function
+from emuvim.api.openstack.resources.router import Router
 from datetime import datetime
 import re
 import sys
 import uuid
 import logging
-import ip_handler as IP
+import emuvim.api.openstack.ip_handler as IP
 
 
 LOG = logging.getLogger("api.openstack.heat.parser")
@@ -130,7 +131,7 @@
                         net_name, True)
 
             except Exception as e:
-                LOG.warning('Could not create Net: ' + e.message)
+                LOG.warning('Could not create Net: ' + str(e))
             return
 
         if 'OS::Neutron::Subnet' in resource['type'] and "Net" not in resource['type']:
@@ -151,7 +152,7 @@
                 if not stack_update:
                     net.set_cidr(IP.get_new_cidr(net.subnet_id))
             except Exception as e:
-                LOG.warning('Could not create Subnet: ' + e.message)
+                LOG.warning('Could not create Subnet: ' + str(e))
             return
 
         if 'OS::Neutron::Port' in resource['type']:
@@ -172,7 +173,7 @@
                         port.ip_address = net.get_new_ip_address(port.name)
                         return
             except Exception as e:
-                LOG.warning('Could not create Port: ' + e.message)
+                LOG.warning('Could not create Port: ' + str(e))
             self.bufferResource.append(resource)
             return
 
@@ -210,7 +211,7 @@
                     server.port_names.append(port_name)
                 return
             except Exception as e:
-                LOG.warning('Could not create Server: ' + e.message)
+                LOG.warning('Could not create Server: ' + str(e))
             return
 
         if 'OS::Neutron::RouterInterface' in resource['type']:
@@ -246,7 +247,7 @@
 
                 stack.ports[port_name].floating_ip = floating_network_id
             except Exception as e:
-                LOG.warning('Could not create FloatingIP: ' + e.message)
+                LOG.warning('Could not create FloatingIP: ' + str(e))
             return
 
         if 'OS::Neutron::Router' in resource['type']:
@@ -255,7 +256,7 @@
                 if name not in stack.routers:
                     stack.routers[name] = Router(name)
             except Exception as e:
-                print('Could not create Router: ' + e.message)
+                print('Could not create Router: ' + str(e))
             return
 
         if 'OS::Heat::ResourceGroup' in resource['type']:
@@ -267,7 +268,7 @@
                 self.handle_resource(
                     embedded_resource, stack, dc_label, stack_update)
             except Exception as e:
-                print('Could not create Router: ' + e.message)
+                print('Could not create Router: ' + str(e))
             return
 
         LOG.warning(
diff --git a/src/emuvim/api/openstack/helper.py b/src/emuvim/api/openstack/helper.py
index c7ef69b..5f9d573 100644
--- a/src/emuvim/api/openstack/helper.py
+++ b/src/emuvim/api/openstack/helper.py
@@ -23,7 +23,10 @@
 # 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
+try:
+    from urllib.parse import urlparse
+except ImportError:
+    from urlparse import urlparse
 import logging
 
 LOG = logging.getLogger("api.openstack.helper")
diff --git a/src/emuvim/api/openstack/ip_handler.py b/src/emuvim/api/openstack/ip_handler.py
index 9138342..070f992 100755
--- a/src/emuvim/api/openstack/ip_handler.py
+++ b/src/emuvim/api/openstack/ip_handler.py
@@ -23,7 +23,7 @@
 # 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
+from emuvim.api.openstack.resources.net import Net
 import threading
 
 lock = threading.Lock()
diff --git a/src/emuvim/api/openstack/manage.py b/src/emuvim/api/openstack/manage.py
index a78cb30..1c5c5a5 100755
--- a/src/emuvim/api/openstack/manage.py
+++ b/src/emuvim/api/openstack/manage.py
@@ -27,7 +27,7 @@
 import threading
 import uuid
 import networkx as nx
-import chain_api
+import emuvim.api.openstack.chain_api as chain_api
 import json
 import random
 from emuvim.api.openstack.resources.net import Net
@@ -132,7 +132,7 @@
             port.ip_address = root_ip
             # floating ip network setup
             # wierd way of getting a datacenter object
-            first_dc = self.net.dcs.values()[0]
+            first_dc = list(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(
diff --git a/src/emuvim/api/openstack/openstack_api_endpoint.py b/src/emuvim/api/openstack/openstack_api_endpoint.py
index fdfa5e4..34d9906 100755
--- a/src/emuvim/api/openstack/openstack_api_endpoint.py
+++ b/src/emuvim/api/openstack/openstack_api_endpoint.py
@@ -23,16 +23,21 @@
 # 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 emuvim.api.openstack.manage import OpenstackManage
 
-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
+from emuvim.api.openstack.openstack_dummies.glance_dummy_api import \
+    GlanceDummyApi
+from emuvim.api.openstack.openstack_dummies.heat_dummy_api import \
+    HeatDummyApi
+from emuvim.api.openstack.openstack_dummies.keystone_dummy_api import \
+    KeystoneDummyApi
+from emuvim.api.openstack.openstack_dummies.neutron_dummy_api import \
+    NeutronDummyApi
+from emuvim.api.openstack.openstack_dummies.nova_dummy_api import \
+    NovaDummyApi
 
 import logging
-import compute
+import emuvim.api.openstack.compute as compute
 import socket
 import time
 
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 1b066f0..8d85974 100755
--- a/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py
@@ -137,7 +137,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
     def post(self):
         """
@@ -226,7 +226,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve image with id %s." % (__name__, id))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
     def put(self, id):
@@ -259,5 +259,5 @@
         except Exception as ex:
             logging.exception(
                 u"%s: Could not retrieve image with id %s." % (__name__, id))
-            return Response(ex.message, status=500,
+            return Response(str(ex), 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 86fb6c1..9cd4d5d 100755
--- a/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
@@ -116,7 +116,7 @@
 
             reader = HeatParser(self.api.compute)
             if isinstance(stack_dict['template'], str) or isinstance(
-                    stack_dict['template'], unicode):
+                    stack_dict['template'], bytes):
                 stack_dict['template'] = json.loads(stack_dict['template'])
             if not reader.parse_input(
                     stack_dict['template'], stack, self.api.compute.dc.label):
@@ -142,7 +142,7 @@
 
         except Exception as ex:
             LOG.exception("Heat: Create Stack exception.")
-            return ex.message, 500
+            return str(ex), 500
 
     def get(self, tenant_id):
         """
@@ -174,7 +174,7 @@
                             status=200, mimetype="application/json")
         except Exception as ex:
             LOG.exception("Heat: List Stack exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatShowStack(Resource):
@@ -244,7 +244,7 @@
 
         except Exception as ex:
             LOG.exception("Heat: Show stack exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatShowStackTemplate(Resource):
@@ -278,7 +278,7 @@
 
         except Exception as ex:
             LOG.exception("Heat: Show stack template exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatShowStackResources(Resource):
@@ -313,7 +313,7 @@
 
         except Exception as ex:
             LOG.exception("Heat: Show stack template exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatUpdateStack(Resource):
@@ -362,7 +362,7 @@
 
             reader = HeatParser(self.api.compute)
             if isinstance(stack_dict['template'], str) or isinstance(
-                    stack_dict['template'], unicode):
+                    stack_dict['template'], bytes):
                 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):
@@ -376,7 +376,7 @@
 
         except Exception as ex:
             LOG.exception("Heat: Update Stack exception")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatDeleteStack(Resource):
@@ -408,4 +408,4 @@
 
         except Exception as ex:
             LOG.exception("Heat: Delete Stack exception")
-            return ex.message, 500
+            return str(ex), 500
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 0741553..0054ddb 100755
--- a/src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
@@ -323,7 +323,7 @@
 
         except Exception as ex:
             logging.exception("Keystone: Get token failed.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class KeystoneGetTokenv3(Resource):
@@ -454,4 +454,4 @@
 
         except Exception as ex:
             logging.exception("Keystone: Get token failed.")
-            return ex.message, 500
+            return str(ex), 500
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 e017660..2f11d9f 100755
--- a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
@@ -25,9 +25,10 @@
 # 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.openstack_dummies.base_openstack_dummy import \
+    BaseOpenstackDummy
 from datetime import datetime
-import neutron_sfc_dummy_api as SFC
+import emuvim.api.openstack.openstack_dummies.neutron_sfc_dummy_api as SFC
 import logging
 import json
 import uuid
@@ -269,7 +270,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: List networks exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -319,7 +320,7 @@
 
         except Exception as ex:
             logging.exception("Neutron: Show network exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -350,7 +351,7 @@
                 {"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,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -397,7 +398,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: Show networks exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -434,7 +435,7 @@
             return Response('', status=204, mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Delete network exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -481,7 +482,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: List subnets exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -529,7 +530,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: Show subnet exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -589,7 +590,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: Create network excepiton.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -643,7 +644,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: Show networks exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -691,7 +692,7 @@
                             status=404, mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Delete subnet exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -739,14 +740,14 @@
                 ), ports)
 
             port_dict = dict()
-            port_dict["ports"] = map(lambda x: x.create_port_dict(self.api.compute), ports)
+            port_dict["ports"] = list(map(lambda x: x.create_port_dict(self.api.compute), ports))
 
             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,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -792,7 +793,7 @@
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Show port exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -856,7 +857,7 @@
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Show port exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -920,7 +921,7 @@
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Update port exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -967,7 +968,7 @@
 
         except Exception as ex:
             LOG.exception("Neutron: Delete port exception.")
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -1048,5 +1049,5 @@
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Create FloatingIP exception %s.", ex)
-            return Response(ex.message, status=500,
+            return Response(str(ex), 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 dbfb4b5..e611a87 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
@@ -67,7 +67,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -91,7 +91,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -106,7 +106,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -118,14 +118,14 @@
             id = request.args.get('id')
             if id and any(id):
                 port_pairs = filter(lambda port_pair: port_pair.id == id, port_pairs)
-            resp = {"port_pairs": map(lambda port_pair: port_pair.create_dict(self.api.compute), port_pairs)}
+            resp = {"port_pairs": list(map(lambda port_pair: port_pair.create_dict(self.api.compute), port_pairs))}
 
             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,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -143,7 +143,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -175,7 +175,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -202,7 +202,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -217,7 +217,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -236,7 +236,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -255,7 +255,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -307,7 +307,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -332,7 +332,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -347,7 +347,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -366,7 +366,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -385,7 +385,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -420,7 +420,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -453,7 +453,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -468,7 +468,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -487,7 +487,7 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), status=500,
                             mimetype='application/json')
 
 
@@ -506,5 +506,5 @@
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
-            return Response(ex.message, status=500,
+            return Response(str(ex), 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 12a9cc2..b57b83c 100755
--- a/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py
+++ b/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py
@@ -116,7 +116,7 @@
 
         except Exception as ex:
             LOG.exception(u"%s: Could not show list of versions." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaVersionShow(Resource):
@@ -170,7 +170,7 @@
 
         except Exception as ex:
             LOG.exception(u"%s: Could not show list of versions." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaListServersApi(Resource):
@@ -208,7 +208,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
     def post(self, id):
         """
@@ -262,7 +262,7 @@
 
         except Exception as ex:
             LOG.exception(u"%s: Could not create the server." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaListServersAndPortsApi(Resource):
@@ -311,7 +311,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaListServersDetailed(Resource):
@@ -375,7 +375,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaListFlavors(Resource):
@@ -413,7 +413,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
     def post(self, id):
         LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
@@ -480,7 +480,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
     def post(self, id):
         LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
@@ -542,7 +542,7 @@
         except Exception as ex:
             LOG.exception(u"%s: Could not retrieve flavor with id %s" %
                           (__name__, flavorid))
-            return ex.message, 500
+            return str(ex), 500
 
     def delete(self, id, flavorid):
         """
@@ -587,7 +587,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaListImagesDetails(Resource):
@@ -633,7 +633,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaListImageById(Resource):
@@ -671,7 +671,7 @@
         except Exception as ex:
             LOG.exception(u"%s: Could not retrieve image with id %s." %
                           (__name__, imageid))
-            return ex.message, 500
+            return str(ex), 500
 
     def delete(self, id, imageid):
         """
@@ -744,7 +744,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the server details." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
     def delete(self, id, serverid):
         """
@@ -772,7 +772,7 @@
 
         except Exception as ex:
             LOG.exception(u"%s: Could not create the server." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaInterfaceToServer(Resource):
@@ -863,7 +863,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not add interface to the server." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaShowAndDeleteInterfaceAtServer(Resource):
@@ -908,7 +908,7 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not detach interface from the server." % __name__)
-            return ex.message, 500
+            return str(ex), 500
 
 
 class NovaLimits(Resource):
@@ -963,4 +963,4 @@
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
-            return ex.message, 500
+            return str(ex), 500
diff --git a/src/emuvim/api/openstack/resources/net.py b/src/emuvim/api/openstack/resources/net.py
index 112cca6..42af151 100755
--- a/src/emuvim/api/openstack/resources/net.py
+++ b/src/emuvim/api/openstack/resources/net.py
@@ -24,6 +24,7 @@
 # acknowledge the contributions of their colleagues of the SONATA
 # partner consortium (www.sonata-nfv.eu).
 import re
+from json import dumps
 
 
 class Net:
@@ -243,7 +244,7 @@
         :return: IP address as int.
         :rtype: ``int``
         """
-        o = map(int, ip.split('.'))
+        o = list(map(int, ip.split('.')))
         res = (16777216 * o[0]) + (65536 * o[1]) + (256 * o[2]) + o[3]
         return res
 
@@ -340,4 +341,4 @@
                      self.gateway_ip,
                      self.segmentation_id,
                      self._cidr,
-                     self.start_end_dict))
+                     dumps(self.start_end_dict)))
diff --git a/src/emuvim/api/openstack/resources/port_chain.py b/src/emuvim/api/openstack/resources/port_chain.py
index e1b3cbc..c061a1e 100644
--- a/src/emuvim/api/openstack/resources/port_chain.py
+++ b/src/emuvim/api/openstack/resources/port_chain.py
@@ -63,8 +63,8 @@
 
         port_pair_chain = map(lambda port_pair_group_id: self._get_port_pair(port_pair_group_id, compute),
                               self.port_pair_groups)
-        ingress_ports = map(lambda port_pair: port_pair.ingress, port_pair_chain)
-        egress_ports = map(lambda port_pair: port_pair.ingress, port_pair_chain)
+        ingress_ports = list(map(lambda port_pair: port_pair.ingress, port_pair_chain))
+        egress_ports = list(map(lambda port_pair: port_pair.ingress, port_pair_chain))
         chain_start = ingress_ports[0]
         chain_rest = ingress_ports[1:]
 
@@ -75,7 +75,7 @@
 
             port = compute.find_port_by_name_or_id(flow_classifier.logical_source_port)
 
-            chain = [(port, chain_start)] + zip(egress_ports, chain_rest)
+            chain = [(port, chain_start)] + list(zip(egress_ports, chain_rest))
 
             for (egress_port, ingress_port) in chain:
                 server_egress = None