From 5b8ac4faded6386d8e32751b689876c12800924b Mon Sep 17 00:00:00 2001 From: peusterm Date: Tue, 12 Feb 2019 19:58:24 +0100 Subject: [PATCH] Unified command execution in Docker containers. Also adds a hotfix for a broken test execution based on an issue with a used library: https://github.com/pytest-dev/pytest/issues/4770 Change-Id: I54aade1eda31cb2584641b95226fbf39d9d298f4 Signed-off-by: peusterm --- Dockerfile | 3 +++ setup.py | 6 ++++-- src/emuvim/api/openstack/compute.py | 9 +++++---- src/emuvim/api/rest/compute.py | 4 ++-- src/emuvim/api/tango/llcm.py | 1 - 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b8627a..cccecdf 100755 --- a/Dockerfile +++ b/Dockerfile @@ -58,6 +58,9 @@ RUN ansible-playbook -i "localhost," -c local --skip-tags "notindocker" install. WORKDIR /son-emu RUN python setup.py develop +# Hotfix: https://github.com/pytest-dev/pytest/issues/4770 +RUN pip2 install "more-itertools<=5.0.0" + # 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"] diff --git a/setup.py b/setup.py index 7cc9d6b..7fb1add 100755 --- a/setup.py +++ b/setup.py @@ -57,7 +57,9 @@ setup(name='emuvim', 'ipaddress', 'simplejson', 'gevent', - 'flake8' + 'flake8', + # fixes: https://github.com/pytest-dev/pytest/issues/4770 + 'more-itertools<=5.0.0' ], zip_safe=False, entry_points={ @@ -66,5 +68,5 @@ setup(name='emuvim', ], }, setup_requires=['pytest-runner'], - tests_require=['pytest'], + tests_require=['pytest', 'more-itertools<=5.0.0'], ) diff --git a/src/emuvim/api/openstack/compute.py b/src/emuvim/api/openstack/compute.py index 4d6517e..d7e944b 100755 --- a/src/emuvim/api/openstack/compute.py +++ b/src/emuvim/api/openstack/compute.py @@ -491,18 +491,19 @@ class OpenstackCompute(object): port.assigned_container = c # Start the real emulator command now as specified in the dockerfile - # ENV SON_EMU_CMD config = c.dcinfo.get("Config", dict()) env = config.get("Env", list()) for env_var in env: - if "SON_EMU_CMD=" in env_var: - cmd = str(env_var.split("=")[1]) - server.son_emu_command = cmd + var, cmd = map(str.strip, map(str, env_var.split('=', 1))) + if var == "SON_EMU_CMD" or var == "VIM_EMU_CMD": + LOG.info("Executing script in '{}': {}={}" + .format(server.name, var, cmd)) # execute command in new thread to ensure that GK is not # blocked by VNF t = threading.Thread(target=c.cmdPrint, args=(cmd,)) t.daemon = True t.start() + break # only execute one command def stop_compute(self, server): """ diff --git a/src/emuvim/api/rest/compute.py b/src/emuvim/api/rest/compute.py index 5120b9e..aec010e 100755 --- a/src/emuvim/api/rest/compute.py +++ b/src/emuvim/api/rest/compute.py @@ -83,8 +83,8 @@ class Compute(Resource): var, cmd = map(str.strip, map(str, env_var.split('=', 1))) logging.debug("%r = %r" % (var, cmd)) if var == "SON_EMU_CMD" or var == "VIM_EMU_CMD": - logging.info( - "Executing entry point script in %r: %r" % (c.name, cmd)) + logging.info("Executing script in '{}': {}={}" + .format(compute_name, var, cmd)) # execute command in new thread to ensure that API is # not blocked by VNF t = threading.Thread(target=c.cmdPrint, args=(cmd,)) diff --git a/src/emuvim/api/tango/llcm.py b/src/emuvim/api/tango/llcm.py index b3916bb..35cdf4d 100755 --- a/src/emuvim/api/tango/llcm.py +++ b/src/emuvim/api/tango/llcm.py @@ -423,7 +423,6 @@ class Service(object): env = config.get("Env", list()) for env_var in env: var, cmd = map(str.strip, map(str, env_var.split('=', 1))) - # LOG.debug("%r = %r" % (var, cmd)) if var == "SON_EMU_CMD" or var == "VIM_EMU_CMD": LOG.info("Executing script in '{}': {}={}" .format(vnfi.name, var, cmd)) -- 2.25.1