Unified command execution in Docker containers. 24/7224/1
authorpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 12 Feb 2019 18:58:24 +0000 (19:58 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 12 Feb 2019 18:58:24 +0000 (19:58 +0100)
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 <manuel.peuster@uni-paderborn.de>
Dockerfile
setup.py
src/emuvim/api/openstack/compute.py
src/emuvim/api/rest/compute.py
src/emuvim/api/tango/llcm.py

index 4b8627a..cccecdf 100755 (executable)
@@ -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"]
index 7cc9d6b..7fb1add 100755 (executable)
--- 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'],
       )
index 4d6517e..d7e944b 100755 (executable)
@@ -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):
         """
index 5120b9e..aec010e 100755 (executable)
@@ -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,))
index b3916bb..35cdf4d 100755 (executable)
@@ -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))