From efdda12a005a63a449ea7afb9baab1743b4d04ab Mon Sep 17 00:00:00 2001 From: peusterm Date: Thu, 19 Dec 2019 17:04:46 +0100 Subject: [PATCH] Finalizing Python3 migration With this patch, vim-emu is using Python3 as default installation option. Change-Id: I1238d1d4c96f641c90508ef20b44b88edbbb8222 Signed-off-by: peusterm --- Dockerfile | 36 ++++++----- Dockerfile_py3 | 106 -------------------------------- Jenkinsfile | 2 +- README.md | 113 +++++++++++++++++++++-------------- ansible/install.yml | 12 ++-- ansible/install_py3.yml | 110 ---------------------------------- devops-stages/stage-test.sh | 2 +- pipeline_local.sh | 2 +- setup.py | 2 +- src/emuvim/api/tango/llcm.py | 5 +- utils/vagrant/motd | 43 ------------- 11 files changed, 102 insertions(+), 331 deletions(-) mode change 100755 => 100644 Dockerfile delete mode 100644 Dockerfile_py3 mode change 100755 => 100644 ansible/install.yml delete mode 100644 ansible/install_py3.yml delete mode 100755 utils/vagrant/motd diff --git a/Dockerfile b/Dockerfile old mode 100755 new mode 100644 index 38adc2a..8e1e4e3 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ # acknowledge the contributions of their colleagues of the SONATA # partner consortium (www.sonata-nfv.eu). -FROM ubuntu:xenial +FROM ubuntu:bionic ENV SON_EMU_IN_DOCKER 1 ENV PIP_DEFAULT_TIMEOUT=100 @@ -35,41 +35,47 @@ RUN apt-get update \ && apt-get install -y git \ net-tools \ aptitude \ + apt-utils \ build-essential \ - python-setuptools \ - python-dev \ - python-pip \ + libevent-dev \ software-properties-common \ ansible \ curl \ iptables \ iputils-ping \ sudo \ - vim + wget \ + python \ + python-pip \ + python3 \ + python3-dev \ + python3-venv \ + python3-pip # 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/containernet/containernet.git + WORKDIR /containernet/ansible RUN ansible-playbook -i "localhost," -c local --skip-tags "notindocker" install.yml # install emulator (using its Ansible playbook) -COPY . /son-emu -WORKDIR /son-emu/ansible +COPY . /vim-emu +WORKDIR /vim-emu/ansible RUN ansible-playbook -i "localhost," -c local --skip-tags "notindocker" install.yml -WORKDIR /son-emu -RUN python setup.py develop +WORKDIR /vim-emu +RUN python3 setup.py develop # Hotfix: https://github.com/pytest-dev/pytest/issues/4770 -RUN pip2 install "more-itertools<=5.0.0" +RUN pip3 install "more-itertools<=5.0.0" # Hotfix: Do not use latest tinyrpc lib, since it breaks Ryu -RUN pip2 install "tinyrpc==1.0.3" +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 ["python", "examples/default_single_dc_topology.py"] +ENTRYPOINT ["/vim-emu/utils/docker/entrypoint.sh"] +CMD ["python3", "examples/default_single_dc_topology.py"] # open ports for emulator APIs # SONATA GK diff --git a/Dockerfile_py3 b/Dockerfile_py3 deleted file mode 100644 index a44b154..0000000 --- a/Dockerfile_py3 +++ /dev/null @@ -1,106 +0,0 @@ -# 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 diff --git a/Jenkinsfile b/Jenkinsfile index a110b16..1f12510 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,7 +60,7 @@ node('docker') { // files owned by root that could not be cleaned up. stage("Post-Test") { sh "docker images" - sh "docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock -u 0:0 osm/vim-emu-master pip list" + sh "docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock -u 0:0 osm/vim-emu-master pip3 list" sh "docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock -u 0:0 osm/vim-emu-master pytest -v" sh "docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock -u 0:0 osm/vim-emu-master flake8 --exclude=.eggs,devops,build,examples/charms --ignore=E501,W605,W504 ." sh "echo 'done'" diff --git a/README.md b/README.md index bf8947e..e5479fa 100755 --- a/README.md +++ b/README.md @@ -33,11 +33,12 @@ This emulation platform was created to support network service developers to loc The emulation platform `vim-emu` is developed as part of OSM's DevOps MDG. -### Acknowledgments +--- +## Acknowledgments -This software was originally developed by the [SONATA project](http://www.sonata-nfv.eu), funded by the European Commission under grant number 671517 through the Horizon 2020 and 5G-PPP programs. +This software was originally developed by the [SONATA project](http://www.sonata-nfv.eu) and the [5GTANGO project](https://5gtango.eu/), funded by the European Commission under grant number 671517 and 761493 through the Horizon 2020 and 5G-PPP programs. -### Cite this work +## Cite this work If you use the emulation platform for your research and/or other publications, please cite the following paper to reference our work: @@ -59,19 +60,22 @@ Bibtex: } ``` +--- ## Installation -There are multiple ways to install and use the emulation platform. The easiest way is the automated installation using the OSM installer. The bare-metal installation requires a freshly installed Ubuntu 16.04 LTS and is done by an ansible playbook. Another option is to use a nested Docker environment to run the emulator inside a Docker container. +There are multiple ways to install and use the emulation platform. The easiest way is the automated installation using the OSM installer. The bare-metal installation requires a freshly installed **Ubuntu 18.04 LTS** and is done by an Ansible playbook. Another option is to use a nested Docker environment to run the emulator inside a Docker container. -### Automated installation (recommended) +### Automated OSM installation + +This installation option applies if you want to use vim-emu in combination with OSM. ```sh -./install_osm.sh --lxdimages --vimemu +./install_osm.sh --vimemu ``` -This command will install OSM (as LXC containers) as well as the emulator (as a Docker container) on a local machine. It is recommended to use a machine with Ubuntu 16.04. +This command will install OSM as well as the emulator (as a Docker container) on a local machine. It is recommended to use a machine with Ubuntu 18.04 LTS. More details about this installation option can be found in the [OSM wiki](https://osm.etsi.org/wikipub/index.php/VIM_emulator). -### Manual installation +### Standalone installation #### Option 1: Bare-metal installation @@ -87,7 +91,7 @@ git clone https://github.com/containernet/containernet.git cd ~/containernet/ansible sudo ansible-playbook -i "localhost," -c local install.yml cd .. -sudo python setup.py install +sudo make develop ``` ##### Step 2. vim-emu installation @@ -98,48 +102,69 @@ git clone https://osm.etsi.org/gerrit/osm/vim-emu.git cd ~/vim-emu/ansible sudo ansible-playbook -i "localhost," -c local install.yml cd .. -sudo python setup.py install +sudo python3 setup.py develop ``` #### Option 2: Nested Docker Deployment This option requires a Docker installation on the host machine on which the emulator should be deployed. +Build: ```sh -git clone https://osm.etsi.org/gerrit/osm/vim-emu.git -cd ~/vim-emu +git clone https://osm.etsi.org/gerrit/osm/vim-emu.git +cd ~/vim-emu # build the container: docker build -t vim-emu-img . +``` + +Run: +```sh # run the (interactive) container: docker run --name vim-emu -it --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img /bin/bash ``` - +--- ## Usage ### Example This simple example shows how to start the emulator with a simple topology (terminal 1) and how to start (terminal 2) some empty VNF containers in the emulated datacenters (PoPs) by using the vim-emu CLI. -* First terminal (start the emulation platform): - * `sudo python examples/default_single_dc_topology.py` -* Second terminal (use `docker exec vim-emu ` for nested Docker deployment): - * `vim-emu compute start -d dc1 -n vnf1` - * `vim-emu compute start -d dc1 -n vnf2` - * `vim-emu compute list` -* First terminal: - * `containernet> vnf1 ifconfig` - * `containernet> vnf1 ping -c 2 vnf2` +First terminal: +```sh +# start the emulation platform with a single NFV data center +sudo python3 examples/default_single_dc_topology.py +``` + +Second terminal (use `docker exec vim-emu ` for nested Docker deployment): +```sh +# start two simple VNFs +vim-emu compute start -d dc1 -n vnf1 +vim-emu compute start -d dc1 -n vnf2 +vim-emu compute list +``` + +First terminal: +```sh +# check the connectivity between the two VNFs +# press +containernet> vnf1 ifconfig +containernet> vnf1 ping -c2 vnf2 +``` + A more advanced example that includes OSM can be found in the [official vim-emu documentation in the OSM wiki](https://osm.etsi.org/wikipub/index.php/VIM_emulator). -### Further documentation and useful links +--- +## Documentation +* [Official vim-emu repository mirror on GitHub](https://github.com/containernet/vim-emu) * [Official vim-emu documentation in the OSM wiki](https://osm.etsi.org/wikipub/index.php/VIM_emulator) * [Full vim-emu documentation on GitHub](https://github.com/containernet/vim-emu) * [Mininet](http://mininet.org) * [Containernet](https://containernet.github.io) * [Maxinet](https://maxinet.github.io) +--- ## Development ### How to contribute? @@ -148,28 +173,23 @@ Please check [this OSM wiki page](https://osm.etsi.org/wikipub/index.php/Workflo ### Testing -To run the unit tests do: - -* `cd ~/vim-emu` -* `sudo pytest -v` -* (To force Python2: `sudo python2 -m pytest -v`) - -## Seed code contributors: - -### Lead: - -* Manuel Peuster (https://github.com/mpeuster) -* Steven Van Rossem (https://github.com/stevenvanrossem) +```sh +sudo pytest -v +``` -### Contributors +--- +## Contributors -* Hadi Razzaghi Kouchaksaraei (https://github.com/hadik3r) -* Wouter Tavernier (https://github.com/wtaverni) -* Geoffroy Chollon (https://github.com/cgeoffroy) -* Eduard Maas (https://github.com/edmaas) -* Malte Splietker (https://github.com/splietker) -* Johannes Kampmeyer (https://github.com/xschlef) -* Stefan Schneider (https://github.com/StefanUPB) +* [Manuel Peuster (lead developer)](https://github.com/mpeuster) +* [Hadi Razzaghi Kouchaksaraei](https://github.com/hadik3r) +* [Wouter Tavernier](https://github.com/wtaverni) +* [Geoffroy Chollon](https://github.com/cgeoffroy) +* [Eduard Maas](https://github.com/edmaas) +* [Malte Splietker](https://github.com/splietker) +* [Johannes Kampmeyer](https://github.com/xschlef) +* [Stefan Schneider](https://github.com/StefanUPB) +* [Erik Schilling](https://github.com/Ablu) +* [Rafael Schellenberg](https://github.com/RafaelSche) ## License @@ -177,5 +197,10 @@ The emulation platform is published under Apache 2.0 license. Please see the LIC ## Contact -Manuel Peuster (Paderborn University) +Manuel Peuster +* Mail: +* Twitter: [@ManuelPeuster](https://twitter.com/ManuelPeuster) +* GitHub: [@mpeuster](https://github.com/mpeuster) +* Website: [https://peuster.de](https://peuster.de) + diff --git a/ansible/install.yml b/ansible/install.yml old mode 100755 new mode 100644 index ee5d2c0..e38f747 --- a/ansible/install.yml +++ b/ansible/install.yml @@ -29,8 +29,8 @@ - name: updates apt apt: update_cache=yes - - name: install python-dev - apt: pkg=python-dev state=installed + - name: install python3-dev + apt: pkg=python3-dev state=installed - name: install libffi-dev apt: pkg=libffi-dev state=installed @@ -38,8 +38,8 @@ - name: install libssl-dev apt: pkg=libssl-dev state=installed - - name: install pip - apt: pkg=python-pip state=installed + - name: install pip3 + apt: pkg=python3-pip state=installed - name: install libevent-dev apt: pkg=libevent-dev state=installed @@ -48,7 +48,7 @@ apt: pkg=python-all-dev state=installed - name: find pip executable - shell: "which pip" + shell: "which pip3" register: pip_path - name: install setuptools @@ -106,3 +106,5 @@ pip: name=gevent executable={{pip_path.stdout}} + + diff --git a/ansible/install_py3.yml b/ansible/install_py3.yml deleted file mode 100644 index e38f747..0000000 --- a/ansible/install_py3.yml +++ /dev/null @@ -1,110 +0,0 @@ -# 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}} - - - - diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index 8db3b65..4d5ab12 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -29,7 +29,7 @@ # the vim-emu Docker container by user "root". It requires the container # to be started in privileged mode. # -echo "vim-emu stage archive: Not implemented. See stage-pre-test.sh instead." +echo "vim-emu stage archive: Not implemented. See Post-test stage in Jenkinsfile instead." diff --git a/pipeline_local.sh b/pipeline_local.sh index 68317c4..4116b18 100755 --- a/pipeline_local.sh +++ b/pipeline_local.sh @@ -37,7 +37,7 @@ echo "Running unit tests ..." sudo pytest -v # do everything in Docker, like it is done by Jenkins docker build -t vim-emu-loc-test . -docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-loc-test pip list +docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-loc-test pip3 list docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-loc-test pytest -v docker run --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-loc-test flake8 --exclude=.eggs,devopsi,build,examples/charms --ignore=E501,W605,W504 . echo "done." diff --git a/setup.py b/setup.py index c24498b..347dc16 100755 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ from setuptools import setup, find_packages setup(name='emuvim', - version='6.0', + version='7.0', license='Apache 2.0', description='vim-emu: A NFV multi-PoP emulation platform', url='https://osm.etsi.org/gitweb/?p=osm/vim-emu.git', diff --git a/src/emuvim/api/tango/llcm.py b/src/emuvim/api/tango/llcm.py index 6cbdda8..6e570d0 100755 --- a/src/emuvim/api/tango/llcm.py +++ b/src/emuvim/api/tango/llcm.py @@ -1218,10 +1218,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) - try: - r.append(ipaddress.ip_network(subnet)) - except ValueError: - r.append(ipaddress.ip_network(unicode(subnet))) + r.append(ipaddress.ip_network(subnet)) return r diff --git a/utils/vagrant/motd b/utils/vagrant/motd deleted file mode 100755 index a609795..0000000 --- a/utils/vagrant/motd +++ /dev/null @@ -1,43 +0,0 @@ -# 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). - -************************************************************ -** Welcome to SONATA's son-emu VM ** -** http://sonata-nfv.eu ** -** ** -** To run the emulator with a simple example topology ** -** and its fake-gatekeeper run the following commands. ** -** ** -** Switch to example folder: ** -** - cd son-emu/src/emuvim/examples ** -** ** -** Start the emulator with SONATA's example topology: ** -** - sudo python sonata_y1_demo_topology_1.py ** -** ** -** The emulator will be started and the fake-gatekeeper ** -** API will be accessible on port 5000 from both the ** -** VM and your host machine. ** -************************************************************ \ No newline at end of file -- 2.25.1