migration to python3 (#1) sol006
authorRafael Schellenberg <rafael.schellenberg@uni-paderborn.de>
Fri, 6 Dec 2019 14:03:56 +0000 (15:03 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 17 Dec 2019 10:06:11 +0000 (11:06 +0100)
Change-Id: I964b75c1316b7711cde905c6e98ea027a8557047
Signed-off-by: peusterm <manuel.peuster@uni-paderborn.de>
34 files changed:
Dockerfile_py3 [new file with mode: 0644]
ansible/install.yml
ansible/install_py3.yml [new file with mode: 0644]
src/emuvim/api/openstack/chain_api.py
src/emuvim/api/openstack/compute.py
src/emuvim/api/openstack/heat_parser.py
src/emuvim/api/openstack/helper.py
src/emuvim/api/openstack/ip_handler.py
src/emuvim/api/openstack/manage.py
src/emuvim/api/openstack/openstack_api_endpoint.py
src/emuvim/api/openstack/openstack_dummies/glance_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/keystone_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py
src/emuvim/api/openstack/resources/net.py
src/emuvim/api/openstack/resources/port_chain.py
src/emuvim/api/rest/compute.py
src/emuvim/api/rest/network.py
src/emuvim/api/rest/rest_api_endpoint.py
src/emuvim/api/sonata/dummygatekeeper.py
src/emuvim/api/tango/__init__.py
src/emuvim/api/tango/llcm.py
src/emuvim/dcemulator/monitoring.py
src/emuvim/dcemulator/net.py
src/emuvim/dcemulator/node.py
src/emuvim/dcemulator/resourcemodel/__init__.py
src/emuvim/dcemulator/resourcemodel/upb/simple.py
src/emuvim/test/unittests/test_emulator.py
src/emuvim/test/unittests/test_openstack.py
src/emuvim/test/unittests/test_resourcemodel.py
src/emuvim/test/unittests/test_restapi.py
src/emuvim/test/unittests/test_tango_llcm.py

diff --git a/Dockerfile_py3 b/Dockerfile_py3
new file mode 100644 (file)
index 0000000..a44b154
--- /dev/null
@@ -0,0 +1,106 @@
+# 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 ubuntu:xenial
+
+ENV SON_EMU_IN_DOCKER 1
+ENV PIP_DEFAULT_TIMEOUT=100
+
+# install required packages
+RUN apt-get clean
+RUN apt-get update \
+    && apt-get install -y  git \
+    net-tools \
+    aptitude \
+    apt-utils \
+    build-essential \
+    libevent-dev \
+    software-properties-common \
+    ansible \
+    curl \
+    iptables \
+    iputils-ping \
+    sudo \
+    vim \
+    nano \
+    wget
+
+RUN add-apt-repository ppa:jonathonf/python-3.6    
+RUN apt-get update
+RUN apt install -y python3.6
+RUN apt install -y python3.6-dev
+RUN apt install -y python3.6-venv
+RUN wget https://bootstrap.pypa.io/get-pip.py
+RUN python3.6 get-pip.py
+RUN ln -s /usr/bin/python3.6 /usr/local/bin/python3
+
+# install containernet (using its Ansible playbook)
+#RUN git clone https://github.com/containernet/containernet.git && \
+#    (cd containernet && git checkout 6fcee82e192c8c0e6447650d6f512842185529ee)
+RUN git clone https://github.com/RafaelSche/containernet.git
+WORKDIR /containernet/ansible
+RUN ansible-playbook -i "localhost," -c local --skip-tags "notindocker" install_py3.yml
+
+# install emulator (using its Ansible playbook)
+COPY . /son-emu
+WORKDIR /son-emu/ansible
+RUN ansible-playbook -i "localhost," -c local --skip-tags "notindocker" install_py3.yml
+WORKDIR /son-emu
+RUN python3 setup.py develop
+
+# Hotfix: https://github.com/pytest-dev/pytest/issues/4770
+RUN pip3 install "more-itertools<=5.0.0"
+
+# Hotfix: Do not use latest tinyrpc lib, since it breaks Ryu
+RUN pip3 install "tinyrpc==1.0.3"
+
+RUN pip3 install wheel --upgrade
+
+# Important: This entrypoint is required to start the OVS service
+ENTRYPOINT ["/son-emu/utils/docker/entrypoint.sh"]
+CMD ["python3", "examples/default_single_dc_topology.py"]
+
+# open ports for emulator APIs
+# SONATA GK
+EXPOSE 5000
+# EMU REST API
+EXPOSE 5001
+# Monitoring (Prometheus)
+EXPOSE 8081
+# Monitoring (GW)
+EXPOSE 9091
+# OpenStack-fake
+EXPOSE 4000
+# OpenStack-fake
+EXPOSE 10243
+# OpenStack-fake
+EXPOSE 9005
+# OpenStack-fake (Keystone)
+EXPOSE 6001
+# OpenStack-fake
+EXPOSE 9775
+# OpenStack-fake
+EXPOSE 10697
index e303aad..ee5d2c0 100755 (executable)
    - name: install pip
      apt: pkg=python-pip state=installed
 
    - name: install pip
      apt: pkg=python-pip state=installed
 
+   - name: install libevent-dev
+     apt: pkg=libevent-dev state=installed
+
+   - name: install libevent-dev
+     apt: pkg=python-all-dev state=installed
+
+   - name: find pip executable
+     shell: "which pip"
+     register: pip_path
+
    - name: install setuptools
    - name: install setuptools
-     pip: name=setuptools state=latest
+     pip: name=setuptools state=latest executable={{pip_path.stdout}}
 
    - name: install tabulate
 
    - name: install tabulate
-     pip: name=tabulate state=latest
+     pip: name=tabulate state=latest executable={{pip_path.stdout}}
 
    - name: install argparse
 
    - name: install argparse
-     pip: name=argparse state=latest
+     pip: name=argparse state=latest executable={{pip_path.stdout}}
 
    - name: install networkx
 
    - name: install networkx
-     pip: name=networkx version=1.11
+     pip: name=networkx version=1.11 executable={{pip_path.stdout}}
 
    - name: install six
 
    - name: install six
-     pip: name=six state=latest
+     pip: name=six state=latest executable={{pip_path.stdout}}
 
    - name: install tinyrpc (fixed version to not break ryu)
 
    - name: install tinyrpc (fixed version to not break ryu)
-     pip: name=tinyrpc version=1.0.3
+     pip: name=tinyrpc version=1.0.3 executable={{pip_path.stdout}}
 
    - name: install ryu
 
    - name: install ryu
-     pip: name=ryu state=latest
+     pip: name=ryu state=latest executable={{pip_path.stdout}}
      
    - name: install oslo.config
      
    - name: install oslo.config
-     pip: name=oslo.config state=latest
+     pip: name=oslo.config state=latest executable={{pip_path.stdout}}
 
    - name: install pytest
 
    - name: install pytest
-     pip: name=pytest version=4.6.4
+     pip: name=pytest version=4.6.4 executable={{pip_path.stdout}}
 
    - name: install Flask
 
    - name: install Flask
-     pip: name=Flask state=latest
+     pip: name=Flask  executable={{pip_path.stdout}}
 
    - name: install flask_restful
 
    - name: install flask_restful
-     pip: name=flask_restful state=latest
+     pip: name=flask_restful state=latest executable={{pip_path.stdout}}
 
    - name: install requests
 
    - name: install requests
-     pip: name=requests state=latest
+     pip: name=requests state=latest executable={{pip_path.stdout}}
 
    - name: install docker
 
    - name: install docker
-     pip: name=docker version=2.0.2
+     pip: name=docker version=2.0.2 executable={{pip_path.stdout}}
 
    - name: install prometheus_client
 
    - name: install prometheus_client
-     pip: name=prometheus_client state=latest
+     pip: name=prometheus_client state=latest executable={{pip_path.stdout}}
 
    - name: install latest urllib3 (fix error urllib3.connection.match_hostname = match_hostname)
 
    - name: install latest urllib3 (fix error urllib3.connection.match_hostname = match_hostname)
-     pip: name=urllib3 version=1.21.1
+     pip: name=urllib3 version=1.21.1 executable={{pip_path.stdout}}
 
    - name: install iptc
 
    - name: install iptc
-     pip: name=python-iptables state=latest
+     pip: name=python-iptables state=latest executable={{pip_path.stdout}}
 
    - name: install ipaddress
 
    - name: install ipaddress
-     pip: name=ipaddress state=latest
+     pip: name=ipaddress state=latest executable={{pip_path.stdout}}
 
    - name: install gevent
 
    - name: install gevent
-     pip: name=gevent state=latest
-
-   #- name: install urllib
-   #  pip: name=urllib state=latest
-
+     pip: name=gevent executable={{pip_path.stdout}}
 
 
 
 
diff --git a/ansible/install_py3.yml b/ansible/install_py3.yml
new file mode 100644 (file)
index 0000000..e38f747
--- /dev/null
@@ -0,0 +1,110 @@
+# 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).
+
+- hosts: localhost
+  tasks:
+   - name: updates apt
+     apt: update_cache=yes
+     
+   - name: install python3-dev
+     apt: pkg=python3-dev state=installed
+
+   - name: install libffi-dev
+     apt: pkg=libffi-dev state=installed
+
+   - name: install libssl-dev
+     apt: pkg=libssl-dev state=installed
+
+   - name: install pip3
+     apt: pkg=python3-pip state=installed
+
+   - name: install libevent-dev
+     apt: pkg=libevent-dev state=installed
+
+   - name: install libevent-dev
+     apt: pkg=python-all-dev state=installed
+
+   - name: find pip executable
+     shell: "which pip3"
+     register: pip_path
+
+   - name: install setuptools
+     pip: name=setuptools state=latest executable={{pip_path.stdout}}
+
+   - name: install tabulate
+     pip: name=tabulate state=latest executable={{pip_path.stdout}}
+
+   - name: install argparse
+     pip: name=argparse state=latest executable={{pip_path.stdout}}
+
+   - name: install networkx
+     pip: name=networkx version=1.11 executable={{pip_path.stdout}}
+
+   - name: install six
+     pip: name=six state=latest executable={{pip_path.stdout}}
+
+   - name: install tinyrpc (fixed version to not break ryu)
+     pip: name=tinyrpc version=1.0.3 executable={{pip_path.stdout}}
+
+   - name: install ryu
+     pip: name=ryu state=latest executable={{pip_path.stdout}}
+     
+   - name: install oslo.config
+     pip: name=oslo.config state=latest executable={{pip_path.stdout}}
+
+   - name: install pytest
+     pip: name=pytest version=4.6.4 executable={{pip_path.stdout}}
+
+   - name: install Flask
+     pip: name=Flask  executable={{pip_path.stdout}}
+
+   - name: install flask_restful
+     pip: name=flask_restful state=latest executable={{pip_path.stdout}}
+
+   - name: install requests
+     pip: name=requests state=latest executable={{pip_path.stdout}}
+
+   - name: install docker
+     pip: name=docker version=2.0.2 executable={{pip_path.stdout}}
+
+   - name: install prometheus_client
+     pip: name=prometheus_client state=latest executable={{pip_path.stdout}}
+
+   - name: install latest urllib3 (fix error urllib3.connection.match_hostname = match_hostname)
+     pip: name=urllib3 version=1.21.1 executable={{pip_path.stdout}}
+
+   - name: install iptc
+     pip: name=python-iptables state=latest executable={{pip_path.stdout}}
+
+   - name: install ipaddress
+     pip: name=ipaddress state=latest executable={{pip_path.stdout}}
+
+   - name: install gevent
+     pip: name=gevent executable={{pip_path.stdout}}
+
+
+
+
index 21cb65b..7f38a7e 100755 (executable)
@@ -513,7 +513,7 @@ class ChainVnfDcStackInterfaces(Resource):
         # search for related OpenStackAPIs
         api_src = None
         api_dst = None
         # 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
         for api in OpenstackApiEndpoint.dc_apis:
             if api.compute.dc == dc_src:
                 api_src = api
@@ -711,7 +711,7 @@ class BalanceHostDcStack(Resource):
         dc_real = self.api.manage.net.dcs[dc]
         # search for related OpenStackAPIs
         api_real = None
         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
         for api in OpenstackApiEndpoint.dc_apis:
             if api.compute.dc == dc_real:
                 api_real = api
index 9d77a44..4999331 100755 (executable)
 # partner consortium (www.sonata-nfv.eu).
 from mininet.link import Link
 
 # 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
 
 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
 
 
 import hashlib
 
 
@@ -232,8 +232,12 @@ class OpenstackCompute(object):
         for server in self.stacks[stack_id].servers.values():
             self.stop_compute(server)
             self.delete_server(server)
         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)
 
         for port in self.stacks[stack_id].ports.values():
             self.delete_port(port.id)
 
@@ -592,7 +596,7 @@ class OpenstackCompute(object):
         """
         if len(name) > char_limit:
             # construct a short name
         """
         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
             h = h[0:char_limit]
             LOG.debug("Shortened server name '%s' to '%s'" % (name, h))
         return name
@@ -630,6 +634,7 @@ class OpenstackCompute(object):
         """
         if name_or_id in self.nets:
             return self.nets[name_or_id]
         """
         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
         for net in self.nets.values():
             if net.name == name_or_id:
                 return net
@@ -710,10 +715,10 @@ class OpenstackCompute(object):
         if name_or_id in self.ports:
             return self.ports[name_or_id]
         # find by name
         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()
             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]
         matching_ports_count = len(matching_ports)
         if matching_ports_count == 1:
             return matching_ports[0]
index ffcaa0a..8923d72 100755 (executable)
 # 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).
 # 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
 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")
 
 
 LOG = logging.getLogger("api.openstack.heat.parser")
@@ -130,7 +131,7 @@ class HeatParser:
                         net_name, True)
 
             except Exception as e:
                         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']:
             return
 
         if 'OS::Neutron::Subnet' in resource['type'] and "Net" not in resource['type']:
@@ -151,7 +152,7 @@ class HeatParser:
                 if not stack_update:
                     net.set_cidr(IP.get_new_cidr(net.subnet_id))
             except Exception as e:
                 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']:
             return
 
         if 'OS::Neutron::Port' in resource['type']:
@@ -172,7 +173,7 @@ class HeatParser:
                         port.ip_address = net.get_new_ip_address(port.name)
                         return
             except Exception as e:
                         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
 
             self.bufferResource.append(resource)
             return
 
@@ -210,7 +211,7 @@ class HeatParser:
                     server.port_names.append(port_name)
                 return
             except Exception as e:
                     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']:
             return
 
         if 'OS::Neutron::RouterInterface' in resource['type']:
@@ -246,7 +247,7 @@ class HeatParser:
 
                 stack.ports[port_name].floating_ip = floating_network_id
             except Exception as e:
 
                 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']:
             return
 
         if 'OS::Neutron::Router' in resource['type']:
@@ -255,7 +256,7 @@ class HeatParser:
                 if name not in stack.routers:
                     stack.routers[name] = Router(name)
             except Exception as e:
                 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']:
             return
 
         if 'OS::Heat::ResourceGroup' in resource['type']:
@@ -267,7 +268,7 @@ class HeatParser:
                 self.handle_resource(
                     embedded_resource, stack, dc_label, stack_update)
             except Exception as e:
                 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(
             return
 
         LOG.warning(
index c7ef69b..5f9d573 100644 (file)
 # 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).
 # 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")
 import logging
 
 LOG = logging.getLogger("api.openstack.helper")
index 9138342..070f992 100755 (executable)
@@ -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).
 # 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()
 import threading
 
 lock = threading.Lock()
index a78cb30..1c5c5a5 100755 (executable)
@@ -27,7 +27,7 @@ import logging
 import threading
 import uuid
 import networkx as nx
 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
 import json
 import random
 from emuvim.api.openstack.resources.net import Net
@@ -132,7 +132,7 @@ class OpenstackManage(object):
             port.ip_address = root_ip
             # floating ip network setup
             # wierd way of getting a datacenter object
             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(
             # 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(
index fdfa5e4..34d9906 100755 (executable)
 # 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).
 # 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 logging
-import compute
+import emuvim.api.openstack.compute as compute
 import socket
 import time
 
 import socket
 import time
 
index 1b066f0..8d85974 100755 (executable)
@@ -137,7 +137,7 @@ class GlanceListImagesApi(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
         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):
         """
 
     def post(self):
         """
@@ -226,7 +226,7 @@ class GlanceImageByIdApi(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve image with id %s." % (__name__, id))
         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):
                             mimetype='application/json')
 
     def put(self, id):
@@ -259,5 +259,5 @@ class GlanceImageByDockerNameApi(Resource):
         except Exception as ex:
             logging.exception(
                 u"%s: Could not retrieve image with id %s." % (__name__, id))
         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')
                             mimetype='application/json')
index 86fb6c1..9cd4d5d 100755 (executable)
@@ -116,7 +116,7 @@ class HeatCreateStack(Resource):
 
             reader = HeatParser(self.api.compute)
             if isinstance(stack_dict['template'], str) or isinstance(
 
             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_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 @@ class HeatCreateStack(Resource):
 
         except Exception as ex:
             LOG.exception("Heat: Create Stack exception.")
 
         except Exception as ex:
             LOG.exception("Heat: Create Stack exception.")
-            return ex.message, 500
+            return str(ex), 500
 
     def get(self, tenant_id):
         """
 
     def get(self, tenant_id):
         """
@@ -174,7 +174,7 @@ class HeatCreateStack(Resource):
                             status=200, mimetype="application/json")
         except Exception as ex:
             LOG.exception("Heat: List Stack exception.")
                             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):
 
 
 class HeatShowStack(Resource):
@@ -244,7 +244,7 @@ class HeatShowStack(Resource):
 
         except Exception as ex:
             LOG.exception("Heat: Show stack exception.")
 
         except Exception as ex:
             LOG.exception("Heat: Show stack exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatShowStackTemplate(Resource):
 
 
 class HeatShowStackTemplate(Resource):
@@ -278,7 +278,7 @@ class HeatShowStackTemplate(Resource):
 
         except Exception as ex:
             LOG.exception("Heat: Show stack template exception.")
 
         except Exception as ex:
             LOG.exception("Heat: Show stack template exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatShowStackResources(Resource):
 
 
 class HeatShowStackResources(Resource):
@@ -313,7 +313,7 @@ class HeatShowStackResources(Resource):
 
         except Exception as ex:
             LOG.exception("Heat: Show stack template exception.")
 
         except Exception as ex:
             LOG.exception("Heat: Show stack template exception.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatUpdateStack(Resource):
 
 
 class HeatUpdateStack(Resource):
@@ -362,7 +362,7 @@ class HeatUpdateStack(Resource):
 
             reader = HeatParser(self.api.compute)
             if isinstance(stack_dict['template'], str) or isinstance(
 
             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):
                 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 @@ class HeatUpdateStack(Resource):
 
         except Exception as ex:
             LOG.exception("Heat: Update Stack exception")
 
         except Exception as ex:
             LOG.exception("Heat: Update Stack exception")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class HeatDeleteStack(Resource):
 
 
 class HeatDeleteStack(Resource):
@@ -408,4 +408,4 @@ class HeatDeleteStack(Resource):
 
         except Exception as ex:
             LOG.exception("Heat: Delete Stack exception")
 
         except Exception as ex:
             LOG.exception("Heat: Delete Stack exception")
-            return ex.message, 500
+            return str(ex), 500
index 0741553..0054ddb 100755 (executable)
@@ -323,7 +323,7 @@ class KeystoneGetToken(Resource):
 
         except Exception as ex:
             logging.exception("Keystone: Get token failed.")
 
         except Exception as ex:
             logging.exception("Keystone: Get token failed.")
-            return ex.message, 500
+            return str(ex), 500
 
 
 class KeystoneGetTokenv3(Resource):
 
 
 class KeystoneGetTokenv3(Resource):
@@ -454,4 +454,4 @@ class KeystoneGetTokenv3(Resource):
 
         except Exception as ex:
             logging.exception("Keystone: Get token failed.")
 
         except Exception as ex:
             logging.exception("Keystone: Get token failed.")
-            return ex.message, 500
+            return str(ex), 500
index e017660..2f11d9f 100755 (executable)
 # partner consortium (www.sonata-nfv.eu).
 from flask_restful import Resource
 from flask import request, Response
 # 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
 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
 import logging
 import json
 import uuid
@@ -269,7 +270,7 @@ class NeutronListNetworks(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: List networks exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -319,7 +320,7 @@ class NeutronShowNetwork(Resource):
 
         except Exception as ex:
             logging.exception("Neutron: Show network exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -350,7 +351,7 @@ class NeutronCreateNetwork(Resource):
                 {"network": net.create_network_dict()}), status=201, mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Create network excepiton.")
                 {"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')
 
 
                             mimetype='application/json')
 
 
@@ -397,7 +398,7 @@ class NeutronUpdateNetwork(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: Show networks exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -434,7 +435,7 @@ class NeutronDeleteNetwork(Resource):
             return Response('', status=204, mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Delete network exception.")
             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')
 
 
                             mimetype='application/json')
 
 
@@ -481,7 +482,7 @@ class NeutronListSubnets(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: List subnets exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -529,7 +530,7 @@ class NeutronShowSubnet(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: Show subnet exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -589,7 +590,7 @@ class NeutronCreateSubnet(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: Create network excepiton.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -643,7 +644,7 @@ class NeutronUpdateSubnet(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: Show networks exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -691,7 +692,7 @@ class NeutronDeleteSubnet(Resource):
                             status=404, mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Delete subnet exception.")
                             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')
 
 
                             mimetype='application/json')
 
 
@@ -739,14 +740,14 @@ class NeutronListPorts(Resource):
                 ), ports)
 
             port_dict = dict()
                 ), 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(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')
 
 
                             mimetype='application/json')
 
 
@@ -792,7 +793,7 @@ class NeutronShowPort(Resource):
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Show port exception.")
                             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')
 
 
                             mimetype='application/json')
 
 
@@ -856,7 +857,7 @@ class NeutronCreatePort(Resource):
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Show port exception.")
                             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')
 
 
                             mimetype='application/json')
 
 
@@ -920,7 +921,7 @@ class NeutronUpdatePort(Resource):
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Update port exception.")
                             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')
 
 
                             mimetype='application/json')
 
 
@@ -967,7 +968,7 @@ class NeutronDeletePort(Resource):
 
         except Exception as ex:
             LOG.exception("Neutron: Delete port exception.")
 
         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')
 
 
                             mimetype='application/json')
 
 
@@ -1048,5 +1049,5 @@ class NeutronAddFloatingIp(Resource):
                             mimetype='application/json')
         except Exception as ex:
             LOG.exception("Neutron: Create FloatingIP exception %s.", ex)
                             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')
                             mimetype='application/json')
index dbfb4b5..e611a87 100644 (file)
@@ -67,7 +67,7 @@ class PortPairsCreate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -91,7 +91,7 @@ class PortPairsUpdate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -106,7 +106,7 @@ class PortPairsDelete(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -118,14 +118,14 @@ class PortPairsList(SFC):
             id = request.args.get('id')
             if id and any(id):
                 port_pairs = filter(lambda port_pair: port_pair.id == id, port_pairs)
             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(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')
 
 
                             mimetype='application/json')
 
 
@@ -143,7 +143,7 @@ class PortPairsShow(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -175,7 +175,7 @@ class PortPairGroupCreate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -202,7 +202,7 @@ class PortPairGroupUpdate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -217,7 +217,7 @@ class PortPairGroupDelete(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -236,7 +236,7 @@ class PortPairGroupList(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -255,7 +255,7 @@ class PortPairGroupShow(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -307,7 +307,7 @@ class FlowClassifierCreate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -332,7 +332,7 @@ class FlowClassifierUpdate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -347,7 +347,7 @@ class FlowClassifierDelete(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -366,7 +366,7 @@ class FlowClassifierList(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -385,7 +385,7 @@ class FlowClassifierShow(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -420,7 +420,7 @@ class PortChainCreate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -453,7 +453,7 @@ class PortChainUpdate(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -468,7 +468,7 @@ class PortChainDelete(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -487,7 +487,7 @@ class PortChainList(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
 
 
                             mimetype='application/json')
 
 
@@ -506,5 +506,5 @@ class PortChainShow(SFC):
         except Exception as ex:
             logging.exception("Neutron SFC: %s Exception." %
                               str(self.__class__.__name__))
         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')
                             mimetype='application/json')
index 12a9cc2..b57b83c 100755 (executable)
@@ -116,7 +116,7 @@ class NovaVersionsList(Resource):
 
         except Exception as ex:
             LOG.exception(u"%s: Could not show list of versions." % __name__)
 
         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):
 
 
 class NovaVersionShow(Resource):
@@ -170,7 +170,7 @@ class NovaVersionShow(Resource):
 
         except Exception as ex:
             LOG.exception(u"%s: Could not show list of versions." % __name__)
 
         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):
 
 
 class NovaListServersApi(Resource):
@@ -208,7 +208,7 @@ class NovaListServersApi(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
         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):
         """
 
     def post(self, id):
         """
@@ -262,7 +262,7 @@ class NovaListServersApi(Resource):
 
         except Exception as ex:
             LOG.exception(u"%s: Could not create the server." % __name__)
 
         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):
 
 
 class NovaListServersAndPortsApi(Resource):
@@ -311,7 +311,7 @@ class NovaListServersAndPortsApi(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
         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):
 
 
 class NovaListServersDetailed(Resource):
@@ -375,7 +375,7 @@ class NovaListServersDetailed(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
         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):
 
 
 class NovaListFlavors(Resource):
@@ -413,7 +413,7 @@ class NovaListFlavors(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
         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__))
 
     def post(self, id):
         LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
@@ -480,7 +480,7 @@ class NovaListFlavorsDetails(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of servers." % __name__)
         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__))
 
     def post(self, id):
         LOG.debug("API CALL: %s POST" % str(self.__class__.__name__))
@@ -542,7 +542,7 @@ class NovaListFlavorById(Resource):
         except Exception as ex:
             LOG.exception(u"%s: Could not retrieve flavor with id %s" %
                           (__name__, flavorid))
         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):
         """
 
     def delete(self, id, flavorid):
         """
@@ -587,7 +587,7 @@ class NovaListImages(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
         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):
 
 
 class NovaListImagesDetails(Resource):
@@ -633,7 +633,7 @@ class NovaListImagesDetails(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
         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):
 
 
 class NovaListImageById(Resource):
@@ -671,7 +671,7 @@ class NovaListImageById(Resource):
         except Exception as ex:
             LOG.exception(u"%s: Could not retrieve image with id %s." %
                           (__name__, imageid))
         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):
         """
 
     def delete(self, id, imageid):
         """
@@ -744,7 +744,7 @@ class NovaShowServerDetails(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the server details." % __name__)
         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):
         """
 
     def delete(self, id, serverid):
         """
@@ -772,7 +772,7 @@ class NovaShowServerDetails(Resource):
 
         except Exception as ex:
             LOG.exception(u"%s: Could not create the server." % __name__)
 
         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):
 
 
 class NovaInterfaceToServer(Resource):
@@ -863,7 +863,7 @@ class NovaInterfaceToServer(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not add interface to the server." % __name__)
         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):
 
 
 class NovaShowAndDeleteInterfaceAtServer(Resource):
@@ -908,7 +908,7 @@ class NovaShowAndDeleteInterfaceAtServer(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not detach interface from the server." % __name__)
         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):
 
 
 class NovaLimits(Resource):
@@ -963,4 +963,4 @@ class NovaLimits(Resource):
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
         except Exception as ex:
             LOG.exception(
                 u"%s: Could not retrieve the list of images." % __name__)
-            return ex.message, 500
+            return str(ex), 500
index 112cca6..42af151 100755 (executable)
@@ -24,6 +24,7 @@
 # acknowledge the contributions of their colleagues of the SONATA
 # partner consortium (www.sonata-nfv.eu).
 import re
 # acknowledge the contributions of their colleagues of the SONATA
 # partner consortium (www.sonata-nfv.eu).
 import re
+from json import dumps
 
 
 class Net:
 
 
 class Net:
@@ -243,7 +244,7 @@ class Net:
         :return: IP address as int.
         :rtype: ``int``
         """
         :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
 
         res = (16777216 * o[0]) + (65536 * o[1]) + (256 * o[2]) + o[3]
         return res
 
@@ -340,4 +341,4 @@ class Net:
                      self.gateway_ip,
                      self.segmentation_id,
                      self._cidr,
                      self.gateway_ip,
                      self.segmentation_id,
                      self._cidr,
-                     self.start_end_dict))
+                     dumps(self.start_end_dict)))
index e1b3cbc..c061a1e 100644 (file)
@@ -63,8 +63,8 @@ class PortChain(object):
 
         port_pair_chain = map(lambda port_pair_group_id: self._get_port_pair(port_pair_group_id, compute),
                               self.port_pair_groups)
 
         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:]
 
         chain_start = ingress_ports[0]
         chain_rest = ingress_ports[1:]
 
@@ -75,7 +75,7 @@ class PortChain(object):
 
             port = compute.find_port_by_name_or_id(flow_classifier.logical_source_port)
 
 
             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
 
             for (egress_port, ingress_port) in chain:
                 server_egress = None
index 62a8f18..baa1830 100755 (executable)
@@ -97,7 +97,9 @@ class Compute(Resource):
                     c.start()
             except Exception as ex:
                 logging.warning("Couldn't run Docker entry point VIM_EMU_CMD")
                     c.start()
             except Exception as ex:
                 logging.warning("Couldn't run Docker entry point VIM_EMU_CMD")
-                logging.exception("Exception:")
+                logging.exception(
+                    "Exception: " + str(ex) + "; " + str(type(ex))
+                )
             # return docker inspect dict
             return c.getStatus(), 200, CORS_HEADER
         except Exception as ex:
             # return docker inspect dict
             return c.getStatus(), 200, CORS_HEADER
         except Exception as ex:
@@ -153,7 +155,7 @@ class ComputeList(Resource):
             if dc_label is None or dc_label == 'None':
                 # return list with all compute nodes in all DCs
                 all_containers = []
             if dc_label is None or dc_label == 'None':
                 # return list with all compute nodes in all DCs
                 all_containers = []
-                for dc in dcs.itervalues():
+                for dc in dcs.values():
                     all_containers += dc.listCompute()
                 container_list = [(c.name, c.getStatus())
                                   for c in all_containers]
                     all_containers += dc.listCompute()
                 container_list = [(c.name, c.getStatus())
                                   for c in all_containers]
@@ -246,7 +248,7 @@ class DatacenterList(Resource):
     def get(self):
         logging.debug("API CALL: datacenter list")
         try:
     def get(self):
         logging.debug("API CALL: datacenter list")
         try:
-            return [d.getStatus() for d in dcs.itervalues()], 200, CORS_HEADER
+            return [d.getStatus() for d in dcs.values()], 200, CORS_HEADER
         except Exception as ex:
             logging.exception("API error.")
             return ex.message, 500, CORS_HEADER
         except Exception as ex:
             logging.exception("API error.")
             return ex.message, 500, CORS_HEADER
index e8c6b9a..a16a84a 100755 (executable)
@@ -115,7 +115,7 @@ class NetworkAction(Resource):
             return str(c), 200, CORS_HEADER
         except Exception as ex:
             logging.exception("API error.")
             return str(c), 200, CORS_HEADER
         except Exception as ex:
             logging.exception("API error.")
-            return ex.message, 500, CORS_HEADER
+            return str(ex), 500, CORS_HEADER
 
 
 class DrawD3jsgraph(Resource):
 
 
 class DrawD3jsgraph(Resource):
index d2abde8..c5154cb 100755 (executable)
@@ -31,15 +31,15 @@ from flask_restful import Api
 from gevent.pywsgi import WSGIServer
 
 # need to import total module to set its global variable dcs
 from gevent.pywsgi import WSGIServer
 
 # need to import total module to set its global variable dcs
-import compute
-from compute import ComputeList, Compute, ComputeResources, DatacenterList, DatacenterStatus
+from emuvim.api.rest import compute
+from emuvim.api.rest.compute import ComputeList, Compute, ComputeResources, DatacenterList, DatacenterStatus
 
 # need to import total module to set its global variable net
 
 # need to import total module to set its global variable net
-import network
-from network import NetworkAction, DrawD3jsgraph
+from emuvim.api.rest import network
+from emuvim.api.rest.network import NetworkAction, DrawD3jsgraph
 
 
-import monitor
-from monitor import MonitorInterfaceAction, MonitorFlowAction, MonitorLinkAction, MonitorSkewAction, MonitorTerminal
+from emuvim.api.rest import monitor
+from emuvim.api.rest.monitor import MonitorInterfaceAction, MonitorFlowAction, MonitorLinkAction, MonitorSkewAction, MonitorTerminal
 
 import pkg_resources
 from os import path
 
 import pkg_resources
 from os import path
index ea9a76e..f9af3b6 100755 (executable)
@@ -87,7 +87,7 @@ def generate_subnets(prefix, base, subnet_size=50, mask=24):
     r = list()
     for net in range(base, base + subnet_size):
         subnet = "{0}.{1}.0/{2}".format(prefix, net, mask)
     r = list()
     for net in range(base, base + subnet_size):
         subnet = "{0}.{1}.0/{2}".format(prefix, net, mask)
-        r.append(ipaddress.ip_network(unicode(subnet)))
+        r.append(ipaddress.ip_network(subnet))
     return r
 
 
     return r
 
 
index e96aa19..0a1f6ae 100755 (executable)
@@ -31,7 +31,7 @@
 # partner consortium (www.5gtango.eu).
 import logging
 import threading
 # partner consortium (www.5gtango.eu).
 import logging
 import threading
-import llcm
+from emuvim.api.tango import llcm
 
 
 LOG = logging.getLogger("5gtango.llcm")
 
 
 LOG = logging.getLogger("5gtango.llcm")
index bd3e1f9..6cbdda8 100755 (executable)
@@ -818,7 +818,7 @@ class Service(object):
         Get all URLs to pre-build docker images in some repo.
         :return:
         """
         Get all URLs to pre-build docker images in some repo.
         :return:
         """
-        for vnf_id, v in self.vnfds.iteritems():
+        for vnf_id, v in list(self.vnfds.items()):
             for vu in v.get("virtual_deployment_units", []):
                 vnf_container_name = get_container_name(vnf_id, vu.get("id"))
                 if vu.get("vm_image_format") == "docker":
             for vu in v.get("virtual_deployment_units", []):
                 vnf_container_name = get_container_name(vnf_id, vu.get("id"))
                 if vu.get("vm_image_format") == "docker":
@@ -848,7 +848,7 @@ class Service(object):
         dc = DockerClient()
         LOG.info("Building %d Docker images (this may take several minutes) ..." % len(
             self.local_docker_files))
         dc = DockerClient()
         LOG.info("Building %d Docker images (this may take several minutes) ..." % len(
             self.local_docker_files))
-        for k, v in self.local_docker_files.iteritems():
+        for k, v in list(self.local_docker_files.items()):
             for line in dc.build(path=v.replace(
                     "Dockerfile", ""), tag=k, rm=False, nocache=False):
                 LOG.debug("DOCKER BUILD: %s" % line)
             for line in dc.build(path=v.replace(
                     "Dockerfile", ""), tag=k, rm=False, nocache=False):
                 LOG.debug("DOCKER BUILD: %s" % line)
@@ -859,7 +859,7 @@ class Service(object):
         If the package contains URLs to pre-build Docker images, we download them with this method.
         """
         dc = DockerClient()
         If the package contains URLs to pre-build Docker images, we download them with this method.
         """
         dc = DockerClient()
-        for url in self.remote_docker_image_urls.itervalues():
+        for url in list(self.remote_docker_image_urls.values()):
             # only pull if not present (speedup for development)
             if not FORCE_PULL:
                 if len(dc.images.list(name=url)) > 0:
             # only pull if not present (speedup for development)
             if not FORCE_PULL:
                 if len(dc.images.list(name=url)) > 0:
@@ -940,7 +940,7 @@ class FirstDcPlacement(object):
     """
 
     def place(self, dcs, vnfd, vnfid, vdu, ssiid, cname):
     """
 
     def place(self, dcs, vnfd, vnfid, vdu, ssiid, cname):
-        return list(dcs.itervalues())[0]
+        return list(dcs.values())[0]
 
 
 class RoundRobinDcPlacement(object):
 
 
 class RoundRobinDcPlacement(object):
@@ -952,7 +952,7 @@ class RoundRobinDcPlacement(object):
         self.count = 0
 
     def place(self, dcs, vnfd, vnfid, vdu, ssiid, cname):
         self.count = 0
 
     def place(self, dcs, vnfd, vnfid, vdu, ssiid, cname):
-        dcs_list = list(dcs.itervalues())
+        dcs_list = list(dcs.values())
         rdc = dcs_list[self.count % len(dcs_list)]
         self.count += 1  # inc. count to use next DC
         return rdc
         rdc = dcs_list[self.count % len(dcs_list)]
         self.count += 1  # inc. count to use next DC
         return rdc
@@ -982,14 +982,14 @@ class StaticConfigPlacement(object):
         if cname not in self.static_placement:
             LOG.error("Coudn't find {} in placement".format(cname))
             LOG.error("Using first DC as fallback!")
         if cname not in self.static_placement:
             LOG.error("Coudn't find {} in placement".format(cname))
             LOG.error("Using first DC as fallback!")
-            return list(dcs.itervalues())[0]
+            return list(dcs.values())[0]
         # lookup
         candidate_dc = self.static_placement.get(cname)
         # check if DC exsits
         if candidate_dc not in dcs:
             LOG.error("Coudn't find DC {}".format(candidate_dc))
             LOG.error("Using first DC as fallback!")
         # lookup
         candidate_dc = self.static_placement.get(cname)
         # check if DC exsits
         if candidate_dc not in dcs:
             LOG.error("Coudn't find DC {}".format(candidate_dc))
             LOG.error("Using first DC as fallback!")
-            return list(dcs.itervalues())[0]
+            return list(dcs.values())[0]
         # return correct DC
         return dcs.get(candidate_dc)
 
         # return correct DC
         return dcs.get(candidate_dc)
 
@@ -1023,10 +1023,13 @@ class Packages(fr.Resource):
                         "error": "upload failed. file not found."}, 500
             # generate a uuid to reference this package
             service_uuid = str(uuid.uuid4())
                         "error": "upload failed. file not found."}, 500
             # generate a uuid to reference this package
             service_uuid = str(uuid.uuid4())
-            file_hash = hashlib.sha1(str(son_file)).hexdigest()
+            file_hash = str(son_file)
+            file_hash = hashlib.sha1(file_hash.encode())
+            file_hash = file_hash.hexdigest()
             # ensure that upload folder exists
             ensure_dir(UPLOAD_FOLDER)
             # ensure that upload folder exists
             ensure_dir(UPLOAD_FOLDER)
-            upload_path = os.path.join(UPLOAD_FOLDER, "%s.tgo" % service_uuid)
+            upload_path = os.path.\
+                join(UPLOAD_FOLDER, "%s.tgo" % service_uuid)
             # store *.son file to disk
             if is_file_object:
                 son_file.save(upload_path)
             # store *.son file to disk
             if is_file_object:
                 son_file.save(upload_path)
@@ -1075,7 +1078,7 @@ class Packages(fr.Resource):
         """
         LOG.info("GET /packages")
         result = list()
         """
         LOG.info("GET /packages")
         result = list()
-        for suuid, sobj in GK.services.iteritems():
+        for suuid, sobj in GK.services.items():
             pkg = dict()
             pkg["pd"] = dict()
             pkg["uuid"] = suuid
             pkg = dict()
             pkg["pd"] = dict()
             pkg["uuid"] = suuid
@@ -1097,7 +1100,7 @@ class Services(fr.Resource):
         """
         LOG.info("GET /services")
         result = list()
         """
         LOG.info("GET /services")
         result = list()
-        for suuid, sobj in GK.services.iteritems():
+        for suuid, sobj in GK.services.items():
             service = dict()
             service["nsd"] = dict()
             service["uuid"] = suuid
             service = dict()
             service["nsd"] = dict()
             service["uuid"] = suuid
@@ -1126,7 +1129,7 @@ class Instantiations(fr.Resource):
             service_name = service_uuid
         # first try to find by service_name
         if service_name is not None:
             service_name = service_uuid
         # first try to find by service_name
         if service_name is not None:
-            for s_uuid, s in GK.services.iteritems():
+            for s_uuid, s in GK.services.items():
                 if s.manifest.get("name") == service_name:
                     LOG.info("Searched for: {}. Found service w. UUID: {}"
                              .format(service_name, s_uuid))
                 if s.manifest.get("name") == service_name:
                     LOG.info("Searched for: {}. Found service w. UUID: {}"
                              .format(service_name, s_uuid))
@@ -1136,7 +1139,7 @@ class Instantiations(fr.Resource):
                 "latest") and len(GK.services) > 0:
             # if we don't get a service uuid, we simple start the first service
             # in the list
                 "latest") and len(GK.services) > 0:
             # if we don't get a service uuid, we simple start the first service
             # in the list
-            service_uuid = list(GK.services.iterkeys())[0]
+            service_uuid = list(GK.services.keys())[0]
         if service_uuid in GK.services:
             # ok, we have a service uuid, lets start the service
             service_instance_uuid = GK.services.get(
         if service_uuid in GK.services:
             # ok, we have a service uuid, lets start the service
             service_instance_uuid = GK.services.get(
@@ -1154,10 +1157,10 @@ class Instantiations(fr.Resource):
         """
         LOG.debug("GET /instantiations or /api/v3/records/services")
         # return {"service_instantiations_list": [
         """
         LOG.debug("GET /instantiations or /api/v3/records/services")
         # return {"service_instantiations_list": [
-        #    list(s.instances.iterkeys()) for s in GK.services.itervalues()]}
+        #    list(s.instances.keys()) for s in GK.services.values()]}
         result = list()
         result = list()
-        for suuid, sobj in GK.services.iteritems():
-            for iuuid, iobj in sobj.instances.iteritems():
+        for suuid, sobj in GK.services.items():
+            for iuuid, iobj in sobj.instances.items():
                 inst = dict()
                 inst["uuid"] = iobj.get("uuid")
                 inst["instance_name"] = "{}-inst.{}".format(
                 inst = dict()
                 inst["uuid"] = iobj.get("uuid")
                 inst["instance_name"] = "{}-inst.{}".format(
@@ -1180,7 +1183,7 @@ class Instantiations(fr.Resource):
         # try to be fuzzy
         if service_uuid_input is None:
             # if we don't get a service uuid we stop all services
         # try to be fuzzy
         if service_uuid_input is None:
             # if we don't get a service uuid we stop all services
-            service_uuid_list = list(GK.services.iterkeys())
+            service_uuid_list = list(GK.services.keys())
             LOG.info("No service_uuid given, stopping all.")
         else:
             service_uuid_list = [service_uuid_input]
             LOG.info("No service_uuid given, stopping all.")
         else:
             service_uuid_list = [service_uuid_input]
@@ -1188,7 +1191,7 @@ class Instantiations(fr.Resource):
         for service_uuid in service_uuid_list:
             if instance_uuid_input is None:
                 instance_uuid_list = list(
         for service_uuid in service_uuid_list:
             if instance_uuid_input is None:
                 instance_uuid_list = list(
-                    GK.services[service_uuid].instances.iterkeys())
+                    GK.services[service_uuid].instances.keys())
             else:
                 instance_uuid_list = [instance_uuid_input]
             # for all service instances
             else:
                 instance_uuid_list = [instance_uuid_input]
             # for all service instances
@@ -1215,7 +1218,10 @@ def generate_subnets(prefix, base, subnet_size=50, mask=24):
     r = list()
     for net in range(base, base + subnet_size):
         subnet = "{0}.{1}.0/{2}".format(prefix, net, mask)
     r = list()
     for net in range(base, base + subnet_size):
         subnet = "{0}.{1}.0/{2}".format(prefix, net, mask)
-        r.append(ipaddress.ip_network(unicode(subnet)))
+        try:
+            r.append(ipaddress.ip_network(subnet))
+        except ValueError:
+            r.append(ipaddress.ip_network(unicode(subnet)))
     return r
 
 
     return r
 
 
@@ -1300,7 +1306,7 @@ def get_dc_network():
     :return:
     """
     assert (len(GK.dcs) > 0)
     :return:
     """
     assert (len(GK.dcs) > 0)
-    return GK.dcs.values()[0].net
+    return list(GK.dcs.values())[0].net
 
 
 def parse_interface(interface_name):
 
 
 def parse_interface(interface_name):
@@ -1339,7 +1345,7 @@ def update_port_mapping_multi_instance(ssiid, port_bindings):
     def _offset(p):
         return p + MULTI_INSTANCE_PORT_OFFSET * ssiid
 
     def _offset(p):
         return p + MULTI_INSTANCE_PORT_OFFSET * ssiid
 
-    port_bindings = {k: _offset(v) for k, v in port_bindings.iteritems()}
+    port_bindings = {k: _offset(v) for k, v in port_bindings.items()}
     return port_bindings
 
 
     return port_bindings
 
 
index f8280c3..34b3bab 100755 (executable)
@@ -359,7 +359,7 @@ class DCNetworkMonitor():
                     'stats/flow', dpid=flow_dict['switch_dpid'], data=data)\r
                 if isinstance(ret, dict):\r
                     flow_stat_dict = ret\r
                     'stats/flow', dpid=flow_dict['switch_dpid'], data=data)\r
                 if isinstance(ret, dict):\r
                     flow_stat_dict = ret\r
-                elif isinstance(ret, basestring):\r
+                elif isinstance(ret, str):\r
                     flow_stat_dict = ast.literal_eval(ret.rstrip())\r
                 else:\r
                     flow_stat_dict = None\r
                     flow_stat_dict = ast.literal_eval(ret.rstrip())\r
                 else:\r
                     flow_stat_dict = None\r
@@ -395,7 +395,7 @@ class DCNetworkMonitor():
                 ret = self.net.ryu_REST('stats/port', dpid=dpid)\r
                 if isinstance(ret, dict):\r
                     port_stat_dict = ret\r
                 ret = self.net.ryu_REST('stats/port', dpid=dpid)\r
                 if isinstance(ret, dict):\r
                     port_stat_dict = ret\r
-                elif isinstance(ret, basestring):\r
+                elif isinstance(ret, str):\r
                     port_stat_dict = ast.literal_eval(ret.rstrip())\r
                 else:\r
                     port_stat_dict = None\r
                     port_stat_dict = ast.literal_eval(ret.rstrip())\r
                 else:\r
                     port_stat_dict = None\r
index 8b2c445..9e8c9be 100755 (executable)
@@ -117,7 +117,7 @@ class DCNetwork(Containernet):
         self.DCNetwork_graph = nx.MultiDiGraph()
 
         # initialize pool of vlan tags to setup the SDN paths
         self.DCNetwork_graph = nx.MultiDiGraph()
 
         # initialize pool of vlan tags to setup the SDN paths
-        self.vlans = range(1, 4095)[::-1]
+        self.vlans = list(range(1, 4095))[::-1]
 
         # link to Ryu REST_API
         ryu_ip = 'localhost'
 
         # link to Ryu REST_API
         ryu_ip = 'localhost'
@@ -159,13 +159,13 @@ class DCNetwork(Containernet):
         assert node2 is not None
 
         # ensure type of node1
         assert node2 is not None
 
         # ensure type of node1
-        if isinstance(node1, basestring):
+        if isinstance(node1, str):
             if node1 in self.dcs:
                 node1 = self.dcs[node1].switch
         if isinstance(node1, Datacenter):
             node1 = node1.switch
         # ensure type of node2
             if node1 in self.dcs:
                 node1 = self.dcs[node1].switch
         if isinstance(node1, Datacenter):
             node1 = node1.switch
         # ensure type of node2
-        if isinstance(node2, basestring):
+        if isinstance(node2, str):
             if node2 in self.dcs:
                 node2 = self.dcs[node2].switch
         if isinstance(node2, Datacenter):
             if node2 in self.dcs:
                 node2 = self.dcs[node2].switch
         if isinstance(node2, Datacenter):
@@ -226,7 +226,7 @@ class DCNetwork(Containernet):
                       'dst_port_name': node2_port_name}
         attr_dict2.update(attr_dict)
         self.DCNetwork_graph.add_edge(
                       'dst_port_name': node2_port_name}
         attr_dict2.update(attr_dict)
         self.DCNetwork_graph.add_edge(
-            node1.name, node2.name, attr_dict=attr_dict2)
+            node1.name, node2.name, **attr_dict2)
 
         attr_dict2 = {'src_port_id': node2_port_id, 'src_port_nr': node2.ports[link.intf2],
                       'src_port_name': node2_port_name,
 
         attr_dict2 = {'src_port_id': node2_port_id, 'src_port_nr': node2.ports[link.intf2],
                       'src_port_name': node2_port_name,
@@ -234,7 +234,7 @@ class DCNetwork(Containernet):
                       'dst_port_name': node1_port_name}
         attr_dict2.update(attr_dict)
         self.DCNetwork_graph.add_edge(
                       'dst_port_name': node1_port_name}
         attr_dict2.update(attr_dict)
         self.DCNetwork_graph.add_edge(
-            node2.name, node1.name, attr_dict=attr_dict2)
+            node2.name, node1.name, **attr_dict2)
 
         LOG.debug("addLink: n1={0} intf1={1} -- n2={2} intf2={3}".format(
             str(node1), node1_port_name, str(node2), node2_port_name))
 
         LOG.debug("addLink: n1={0} intf1={1} -- n2={2} intf2={3}".format(
             str(node1), node1_port_name, str(node2), node2_port_name))
@@ -320,13 +320,13 @@ class DCNetwork(Containernet):
         Returns a list with all containers within all data centers.
         """
         all_containers = []
         Returns a list with all containers within all data centers.
         """
         all_containers = []
-        for dc in self.dcs.itervalues():
+        for dc in self.dcs.values():
             all_containers += dc.listCompute()
         return all_containers
 
     def start(self):
         # start
             all_containers += dc.listCompute()
         return all_containers
 
     def start(self):
         # start
-        for dc in self.dcs.itervalues():
+        for dc in self.dcs.values():
             dc.start()
         Containernet.start(self)
 
             dc.start()
         Containernet.start(self)
 
@@ -629,7 +629,7 @@ class DCNetwork(Containernet):
         # check if port is specified (vnf:port)
         if vnf_src_interface is None:
             # take first interface by default
         # check if port is specified (vnf:port)
         if vnf_src_interface is None:
             # take first interface by default
-            connected_sw = self.DCNetwork_graph.neighbors(vnf_src_name)[0]
+            connected_sw = list(self.DCNetwork_graph.neighbors(vnf_src_name))[0]
             link_dict = self.DCNetwork_graph[vnf_src_name][connected_sw]
             vnf_src_interface = link_dict[0]['src_port_id']
 
             link_dict = self.DCNetwork_graph[vnf_src_name][connected_sw]
             vnf_src_interface = link_dict[0]['src_port_id']
 
@@ -646,7 +646,7 @@ class DCNetwork(Containernet):
 
         if vnf_dst_interface is None:
             # take first interface by default
 
         if vnf_dst_interface is None:
             # take first interface by default
-            connected_sw = self.DCNetwork_graph.neighbors(vnf_dst_name)[0]
+            connected_sw = list(self.DCNetwork_graph.neighbors(vnf_dst_name))[0]
             link_dict = self.DCNetwork_graph[connected_sw][vnf_dst_name]
             vnf_dst_interface = link_dict[0]['dst_port_id']
 
             link_dict = self.DCNetwork_graph[connected_sw][vnf_dst_name]
             vnf_dst_interface = link_dict[0]['dst_port_id']
 
index 87085d8..01abb6e 100755 (executable)
@@ -354,14 +354,14 @@ class Datacenter(object):
         Return a list of all running containers assigned to this
         data center.
         """
         Return a list of all running containers assigned to this
         data center.
         """
-        return list(self.containers.itervalues())
+        return list(self.containers.values())
 
     def listExtSAPs(self):
         """
         Return a list of all external SAPs assigned to this
         data center.
         """
 
     def listExtSAPs(self):
         """
         Return a list of all external SAPs assigned to this
         data center.
         """
-        return list(self.extSAPs.itervalues())
+        return list(self.extSAPs.values())
 
     def getStatus(self):
         """
 
     def getStatus(self):
         """
index de100f7..54cc69e 100755 (executable)
@@ -62,7 +62,7 @@ class ResourceModelRegistrar(object):
         List of registered resource models
         :return:
         """
         List of registered resource models
         :return:
         """
-        return list(self._resource_models.itervalues())
+        return list(self._resource_models.values())
 
     @property
     def num_dcs_with_rms(self):
 
     @property
     def num_dcs_with_rms(self):
@@ -71,7 +71,7 @@ class ResourceModelRegistrar(object):
         :return:
         """
         return sum([len(rm.dcs)
         :return:
         """
         return sum([len(rm.dcs)
-                    for rm in list(self._resource_models.itervalues())])
+                    for rm in list(self._resource_models.values())])
 
 
 class ResourceFlavor(object):
 
 
 class ResourceFlavor(object):
index 01231fd..bc81f25 100755 (executable)
@@ -141,7 +141,7 @@ class UpbSimpleCloudDcRM(BaseResourceModel):
         We have to recalculate for all containers to allow e.g. over provisioning models.
         :return:
         """
         We have to recalculate for all containers to allow e.g. over provisioning models.
         :return:
         """
-        for d in self._allocated_compute_instances.itervalues():
+        for d in self._allocated_compute_instances.values():
             if not self.deactivate_cpu_limit:
                 self._apply_cpu_limits(d)
             if not self.deactivate_mem_limit:
             if not self.deactivate_cpu_limit:
                 self._apply_cpu_limits(d)
             if not self.deactivate_mem_limit:
index fc06a69..ace24c1 100755 (executable)
@@ -138,14 +138,14 @@ class testEmulatorNetworking(SimpleTestTopology):
         # check status
         # check get status
         s1 = self.dc[0].containers.get("vnf1").getStatus()
         # check status
         # check get status
         s1 = self.dc[0].containers.get("vnf1").getStatus()
-        print s1
+        print(s1)
         self.assertTrue(s1["name"] == "vnf1")
         self.assertTrue(s1["state"]["Running"])
         self.assertTrue(s1["network"][0]['intf_name'] == 'intf1')
         self.assertTrue(s1["network"][0]['ip'] == '10.0.10.1/24')
 
         s2 = self.dc[1].containers.get("vnf2").getStatus()
         self.assertTrue(s1["name"] == "vnf1")
         self.assertTrue(s1["state"]["Running"])
         self.assertTrue(s1["network"][0]['intf_name'] == 'intf1')
         self.assertTrue(s1["network"][0]['ip'] == '10.0.10.1/24')
 
         s2 = self.dc[1].containers.get("vnf2").getStatus()
-        print s2
+        print(s2)
         self.assertTrue(s2["name"] == "vnf2")
         self.assertTrue(s2["state"]["Running"])
         self.assertTrue(s2["network"][0]['intf_name'] == 'intf2')
         self.assertTrue(s2["name"] == "vnf2")
         self.assertTrue(s2["state"]["Running"])
         self.assertTrue(s2["network"][0]['intf_name'] == 'intf2')
@@ -192,14 +192,14 @@ class testEmulatorNetworking(SimpleTestTopology):
         # check status
         # check get status
         s1 = self.dc[0].containers.get("vnf1").getStatus()
         # check status
         # check get status
         s1 = self.dc[0].containers.get("vnf1").getStatus()
-        print s1
+        print(s1)
         self.assertTrue(s1["name"] == "vnf1")
         self.assertTrue(s1["state"]["Running"])
         self.assertTrue(s1["network"][0]['intf_name'] == 'intf1')
         self.assertTrue(s1["network"][0]['ip'] == '10.0.10.1/24')
 
         s2 = self.dc[1].containers.get("vnf2").getStatus()
         self.assertTrue(s1["name"] == "vnf1")
         self.assertTrue(s1["state"]["Running"])
         self.assertTrue(s1["network"][0]['intf_name'] == 'intf1')
         self.assertTrue(s1["network"][0]['ip'] == '10.0.10.1/24')
 
         s2 = self.dc[1].containers.get("vnf2").getStatus()
-        print s2
+        print(s2)
         self.assertTrue(s2["name"] == "vnf2")
         self.assertTrue(s2["state"]["Running"])
         self.assertTrue(s2["network"][0]['intf_name'] == 'intf2')
         self.assertTrue(s2["name"] == "vnf2")
         self.assertTrue(s2["state"]["Running"])
         self.assertTrue(s2["network"][0]['intf_name'] == 'intf2')
index 787d398..9eb6a6d 100755 (executable)
@@ -884,26 +884,26 @@ class testRestApi(ApiBaseOpenStack):
         self.assertEqual(network_resp.status_code, 200)
         network_id = json.loads(network_resp.content)["networks"][0]["id"]
 
         self.assertEqual(network_resp.status_code, 200)
         network_id = json.loads(network_resp.content)["networks"][0]["id"]
 
-        port_responses = map(lambda name: requests.post("http://0.0.0.0:19696/v2.0/ports",
-                                                        data='{"port": {"name": "%s", "network_id": "%s"}}' %
-                                                             (name, network_id),
-                                                        headers=headers),
-                             ["p1", "p2", "p3", "p4", "p5", "p6"])
+        port_responses = list(map(lambda name: requests.post("http://0.0.0.0:19696/v2.0/ports",
+                                                             data='{"port": {"name": "%s", "network_id": "%s"}}' %
+                                                                  (name, network_id),
+                                                             headers=headers),
+                                  ["p1", "p2", "p3", "p4", "p5", "p6"]))
 
         for port in port_responses:
             self.assertEqual(port.status_code, 201)
 
 
         for port in port_responses:
             self.assertEqual(port.status_code, 201)
 
-        port_ids = map(lambda response: json.loads(response.content)["port"]["id"], port_responses)
+        port_ids = list(map(lambda response: json.loads(response.content)["port"]["id"], port_responses))
 
         listflavorsresponse = requests.get("http://0.0.0.0:18774/v2.1/id_bla/flavors", headers=headers)
         self.assertEqual(listflavorsresponse.status_code, 200)
         flavors = json.loads(listflavorsresponse.content)["flavors"]
 
         listflavorsresponse = requests.get("http://0.0.0.0:18774/v2.1/id_bla/flavors", headers=headers)
         self.assertEqual(listflavorsresponse.status_code, 200)
         flavors = json.loads(listflavorsresponse.content)["flavors"]
-        m1_tiny_flavor = filter(lambda flavor: flavor["name"] == "m1.tiny", flavors)[0]
+        m1_tiny_flavor = list(filter(lambda flavor: flavor["name"] == "m1.tiny", flavors))[0]
 
         listimagesdetailsresponse = requests.get("http://0.0.0.0:18774/v2.1/id_bla/images/detail", headers=headers)
         self.assertEqual(listimagesdetailsresponse.status_code, 200)
         images = json.loads(listimagesdetailsresponse.content)["images"]
 
         listimagesdetailsresponse = requests.get("http://0.0.0.0:18774/v2.1/id_bla/images/detail", headers=headers)
         self.assertEqual(listimagesdetailsresponse.status_code, 200)
         images = json.loads(listimagesdetailsresponse.content)["images"]
-        ubuntu_image = filter(lambda image: image["name"] == "ubuntu:trusty", images)[0]
+        ubuntu_image = list(filter(lambda image: image["name"] == "ubuntu:trusty", images))[0]
 
         server_url = "http://0.0.0.0:18774/v2.1/id_bla/servers"
         server_template = \
 
         server_url = "http://0.0.0.0:18774/v2.1/id_bla/servers"
         server_template = \
index c0cf0c4..8ce8b13 100755 (executable)
@@ -211,7 +211,7 @@ class testUpbSimpleCloudDcRM(SimpleTestTopology):
             rm.allocate(c8)  # calculate allocation
             rm.allocate(c9)  # calculate allocation
         except NotEnoughResourcesAvailable as e:
             rm.allocate(c8)  # calculate allocation
             rm.allocate(c9)  # calculate allocation
         except NotEnoughResourcesAvailable as e:
-            self.assertIn("Not enough compute", e.message)
+            self.assertIn("Not enough compute", str(e))
             exception = True
         self.assertTrue(exception)
 
             exception = True
         self.assertTrue(exception)
 
@@ -241,7 +241,7 @@ class testUpbSimpleCloudDcRM(SimpleTestTopology):
             rm.allocate(c7)  # calculate allocation
             rm.allocate(c8)  # calculate allocation
         except NotEnoughResourcesAvailable as e:
             rm.allocate(c7)  # calculate allocation
             rm.allocate(c8)  # calculate allocation
         except NotEnoughResourcesAvailable as e:
-            self.assertIn("Not enough memory", e.message)
+            self.assertIn("Not enough memory", str(e))
             exception = True
         self.assertTrue(exception)
 
             exception = True
         self.assertTrue(exception)
 
index ef157e5..e63cb24 100755 (executable)
@@ -66,22 +66,24 @@ class testRestApi(SimpleTestTopology):
         print('->>>>>>> checking running nodes, compute list, and connectivity >>>>>>>>>>')
 
         # check number of running nodes
         print('->>>>>>> checking running nodes, compute list, and connectivity >>>>>>>>>>')
 
         # check number of running nodes
-        self.assertTrue(len(self.getContainernetContainers()) == 3)
-        self.assertTrue(len(self.net.hosts) == 5)
-        self.assertTrue(len(self.net.switches) == 2)
+        self.assertEqual(len(self.getContainernetContainers()), 3)
+        self.assertEqual(len(self.net.hosts), 5)
+        self.assertEqual(len(self.net.switches), 2)
 
         # check compute list result
 
         # check compute list result
-        self.assertTrue(len(self.dc[0].listCompute()) == 2)
-        self.assertTrue(len(self.dc[1].listCompute()) == 1)
+        self.assertEqual(len(self.dc[0].listCompute()), 2)
+        self.assertEqual(len(self.dc[1].listCompute()), 1)
         self.assertTrue(isinstance(
             self.dc[0].listCompute()[0], EmulatorCompute))
         self.assertTrue(isinstance(
             self.dc[0].listCompute()[1], EmulatorCompute))
         self.assertTrue(isinstance(
             self.dc[1].listCompute()[0], EmulatorCompute))
         self.assertTrue(isinstance(
             self.dc[0].listCompute()[0], EmulatorCompute))
         self.assertTrue(isinstance(
             self.dc[0].listCompute()[1], EmulatorCompute))
         self.assertTrue(isinstance(
             self.dc[1].listCompute()[0], EmulatorCompute))
-        self.assertTrue(self.dc[0].listCompute()[1].name == "vnf1")
-        self.assertTrue(self.dc[0].listCompute()[0].name == "vnf2")
-        self.assertTrue(self.dc[1].listCompute()[0].name == "vnf3")
+        print("dc1: ", self.dc[0].listCompute())
+        print("dc2: ", self.dc[1].listCompute())
+        self.assertIn("vnf1", list(map(lambda x: x.name, self.dc[0].listCompute())))
+        self.assertIn("vnf2", list(map(lambda x: x.name, self.dc[0].listCompute())))
+        self.assertIn("vnf3", list(map(lambda x: x.name, self.dc[1].listCompute())))
 
         # check connectivity by using ping
         self.assertTrue(self.net.ping(
 
         # check connectivity by using ping
         self.assertTrue(self.net.ping(
@@ -95,15 +97,17 @@ class testRestApi(SimpleTestTopology):
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu network add -src vnf1 -dst vnf2 -b -c 10", shell=True)
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu network add -src vnf1 -dst vnf2 -b -c 10", shell=True)
-        self.assertTrue("add-flow" in output)
-        self.assertTrue("success" in output)
+        print("output: ", output)
+        print("type: ", type(output))
+        self.assertIn("add-flow", output.decode())
+        self.assertIn("success", output.decode())
 
         print('network remove vnf1 vnf2->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu network remove -src vnf1 -dst vnf2 -b", shell=True)
 
         print('network remove vnf1 vnf2->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu network remove -src vnf1 -dst vnf2 -b", shell=True)
-        self.assertTrue("del-flows" in output)
-        self.assertTrue("success" in output)
+        self.assertIn("del-flows", output.decode())
+        self.assertIn("success", output.decode())
 
         print('>>>>> checking --> vim-emu compute stop -d datacenter0 -n vnf2 ->>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
 
         print('>>>>> checking --> vim-emu compute stop -d datacenter0 -n vnf2 ->>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
@@ -111,42 +115,42 @@ class testRestApi(SimpleTestTopology):
             "vim-emu compute stop -d datacenter0 -n vnf2", shell=True)
 
         # check number of running nodes
             "vim-emu compute stop -d datacenter0 -n vnf2", shell=True)
 
         # check number of running nodes
-        self.assertTrue(len(self.getContainernetContainers()) == 2)
-        self.assertTrue(len(self.net.hosts) == 4)
-        self.assertTrue(len(self.net.switches) == 2)
+        self.assertEqual(len(self.getContainernetContainers()), 2)
+        self.assertEqual(len(self.net.hosts), 4)
+        self.assertEqual(len(self.net.switches), 2)
         # check compute list result
         # check compute list result
-        self.assertTrue(len(self.dc[0].listCompute()) == 1)
-        self.assertTrue(len(self.dc[1].listCompute()) == 1)
+        self.assertEqual(len(self.dc[0].listCompute()), 1)
+        self.assertEqual(len(self.dc[1].listCompute()), 1)
 
         print('>>>>> checking --> vim-emu compute list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output("vim-emu compute list", shell=True)
 
         # check datacenter list result
 
         print('>>>>> checking --> vim-emu compute list ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output("vim-emu compute list", shell=True)
 
         # check datacenter list result
-        self.assertTrue("datacenter0" in output)
+        self.assertIn("datacenter0", output.decode())
 
         print('>>>>> checking --> vim-emu compute status -d datacenter0 -n vnf1 ->>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu compute status -d datacenter0 -n vnf1", shell=True)
 
         print('>>>>> checking --> vim-emu compute status -d datacenter0 -n vnf1 ->>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu compute status -d datacenter0 -n vnf1", shell=True)
-        output = ast.literal_eval(output)
+        output = ast.literal_eval(output.decode())
 
         # check compute status result
 
         # check compute status result
-        self.assertTrue(output["name"] == "vnf1")
+        self.assertEqual(output["name"], "vnf1")
         self.assertTrue(output["state"]["Running"])
 
         print('>>>>> checking --> vim-emu datacenter list ->>>>>>>>>>>>>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output("vim-emu datacenter list", shell=True)
         # check datacenter list result
         self.assertTrue(output["state"]["Running"])
 
         print('>>>>> checking --> vim-emu datacenter list ->>>>>>>>>>>>>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output("vim-emu datacenter list", shell=True)
         # check datacenter list result
-        self.assertTrue("datacenter0" in output)
+        self.assertIn("datacenter0", output.decode())
 
         print('->>>>> checking --> vim-emu datacenter status -d datacenter0 ->>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu datacenter status -d datacenter0", shell=True)
         # check datacenter status result
 
         print('->>>>> checking --> vim-emu datacenter status -d datacenter0 ->>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         output = subprocess.check_output(
             "vim-emu datacenter status -d datacenter0", shell=True)
         # check datacenter status result
-        self.assertTrue("datacenter0" in output)
+        self.assertIn("datacenter0", output.decode())
         self.stopApi()
         self.stopNet()
 
         self.stopApi()
         self.stopNet()
 
index fc426f5..439a741 100644 (file)
@@ -37,6 +37,7 @@ from emuvim.api.tango import TangoLLCMEndpoint
 from emuvim.api.tango.llcm import initialize_GK, parse_interface
 from ipaddress import ip_network
 
 from emuvim.api.tango.llcm import initialize_GK, parse_interface
 from ipaddress import ip_network
 
+
 PACKAGE_PATH = "misc/eu.5gtango.emulator-example-service.0.1.tgo"
 
 
 PACKAGE_PATH = "misc/eu.5gtango.emulator-example-service.0.1.tgo"
 
 
@@ -98,7 +99,7 @@ class testTangoLLCM(SimpleTestTopology):
         for link in self.net.deployed_elines:
             vnf_src, intf_src = parse_interface(
                 link['connection_points_reference'][0])
         for link in self.net.deployed_elines:
             vnf_src, intf_src = parse_interface(
                 link['connection_points_reference'][0])
-            print vnf_src, intf_src
+            print(vnf_src, intf_src)
             src = self.net.getNodeByName(vnf_src)
             if not src:
                 continue
             src = self.net.getNodeByName(vnf_src)
             if not src:
                 continue
@@ -119,10 +120,10 @@ class testTangoLLCM(SimpleTestTopology):
             dst_mask = [intf['netmask']
                         for intf in network_list if intf['intf_name'] == intf_dst][0]
 
             dst_mask = [intf['netmask']
                         for intf in network_list if intf['intf_name'] == intf_dst][0]
 
-            print "src = {0}:{1} ip={2} ".format(
-                vnf_src, intf_src, src_ip, src_mask)
-            print "dst = {0}:{1} ip={2} ".format(
-                vnf_dst, intf_dst, dst_ip, dst_mask)
+            print("src = {0}:{1} ip={2} ".format(
+                vnf_src, intf_src, src_ip, src_mask))
+            print("dst = {0}:{1} ip={2} ".format(
+                vnf_dst, intf_dst, dst_ip, dst_mask))
 
             # check if the E-Line IP's are in the same subnet
             ret = ip_network(u'{0}'.format(src_ip, src_mask), strict=False)\
 
             # check if the E-Line IP's are in the same subnet
             ret = ip_network(u'{0}'.format(src_ip, src_mask), strict=False)\
@@ -137,7 +138,7 @@ class testTangoLLCM(SimpleTestTopology):
             self.assertTrue(len(mgmt_ip) > 0)
             ip_address = mgmt_ip[0]
             ELAN_list.append(ip_address)
             self.assertTrue(len(mgmt_ip) > 0)
             ip_address = mgmt_ip[0]
             ELAN_list.append(ip_address)
-            print ip_address
+            print(ip_address)
 
         # check ELAN connection by ping over the mgmt network (needs to be
         # configured as ELAN in the test service)
 
         # check ELAN connection by ping over the mgmt network (needs to be
         # configured as ELAN in the test service)
@@ -147,14 +148,14 @@ class testTangoLLCM(SimpleTestTopology):
                        for intf in network_list if intf['intf_name'] == 'mgmt']
             self.assertTrue(len(mgmt_ip) > 0)
             ip_address = mgmt_ip[0]
                        for intf in network_list if intf['intf_name'] == 'mgmt']
             self.assertTrue(len(mgmt_ip) > 0)
             ip_address = mgmt_ip[0]
-            print ELAN_list
-            print ip_address
+            print(ELAN_list)
+            print(ip_address)
             test_ip_list = list(ELAN_list)
             test_ip_list.remove(ip_address)
             for ip in test_ip_list:
                 # only take ip address, without netmask
                 p = self.net.ping([vnf], manualdestip=ip.split('/')[0])
             test_ip_list = list(ELAN_list)
             test_ip_list.remove(ip_address)
             for ip in test_ip_list:
                 # only take ip address, without netmask
                 p = self.net.ping([vnf], manualdestip=ip.split('/')[0])
-                print p
+                print(p)
                 self.assertTrue(p <= 0.0)
 
         # stop Mininet network
                 self.assertTrue(p <= 0.0)
 
         # stop Mininet network
@@ -181,7 +182,7 @@ class testTangoLLCM(SimpleTestTopology):
         self.startNet()
         time.sleep(3)
 
         self.startNet()
         time.sleep(3)
 
-        print "starting tests"
+        print("starting tests")
         # board package
         files = {"package": open(PACKAGE_PATH, "rb")}
         r = requests.post("http://127.0.0.1:56001/packages", files=files)
         # board package
         files = {"package": open(PACKAGE_PATH, "rb")}
         r = requests.post("http://127.0.0.1:56001/packages", files=files)