From 5960a6737ef19203587bcfd1e468e3a44aaad240 Mon Sep 17 00:00:00 2001 From: Gabriele Baldoni Date: Tue, 28 Apr 2020 10:38:41 +0200 Subject: [PATCH] Non isolation between running FDUs as option deployment of the Plugin + Environment variable as parameters in run/start (#7) * Implementing non isolation as configurable parameter for the Native Plugin (#1) * added callback function for blocking run Signed-off-by: gabrik * Added templates for blocking run fdus and implemented blocking run eval Signed-off-by: gabrik * added evals for log, ls and file Signed-off-by: gabrik * fix typo in get_log_fdu Signed-off-by: gabrik * added start_fdu function for eval starting with env vars, updated run_blocking_fdu with env var parameter Signed-off-by: gabrik * fix return of start_fdu Signed-off-by: gabrik * fix return type of start_fdu Signed-off-by: gabrik * fix in the implementation of start/run/log/ls/get_file evals Signed-off-by: gabrik * reorganisation to merge with native plugin (with isolation) Signed-off-by: gabrik * recopied old files into the rigth path Signed-off-by: gabrik * moved current isolated Native inside isolation.py and updated the native_plugin to start the correct one depending on the configuration, updated copyright years Signed-off-by: gabrik * added start/run/log/ls/get_file eval to isolated native plugin Signed-off-by: gabrik * added utility function for parsing the environment Signed-off-by: gabrik * updated makefile Signed-off-by: gabrik * added missing files Signed-off-by: gabrik * Adding missing service file Signed-off-by: gabrik * typo fixes Signed-off-by: gabrik * Added +x to to_uuid.sh Signed-off-by: gabrik * added missing functions Signed-off-by: gabrik * fixing missing namespace parameter in run and start FDU, in isolation Signed-off-by: gabrik * fixing missing parameters in isolation.py Signed-off-by: gabrik * using -E before to keep same environment variables in isolated binary Signed-off-by: gabrik * updated fos_containerize usage Signed-off-by: gabrik --- Makefile | 8 + NativeFDU.py | 2 +- NativeNoIsolationFDU.py | 80 ++ README.md | 19 +- __init__.py | 4 +- containerize.c | 2 +- isolation.py | 909 ++++++++++++++++++ native_plugin | 636 +----------- native_plugin.json | 1 + no_isolation.py | 806 ++++++++++++++++ templates/blocking_run_native_unix.sh | 20 + templates/blocking_run_native_unix2.sh | 17 + templates/run_native_custom_unix.sh | 4 +- templates/run_native_unix.sh | 4 +- templates/run_native_unix2.sh | 4 +- templates/run_native_windows.ps1 | 6 +- templates/run_native_windows_args.ps1 | 2 +- .../blocking_run_native_unix.sh | 20 + .../blocking_run_native_unix2.sh | 17 + .../run_native_custom_unix.sh | 19 + templates_no_isolation/run_native_unix.sh | 20 + templates_no_isolation/run_native_unix2.sh | 17 + templates_no_isolation/run_native_windows.ps1 | 16 + .../run_native_windows_args.ps1 | 15 + 24 files changed, 1995 insertions(+), 653 deletions(-) create mode 100644 NativeNoIsolationFDU.py create mode 100644 isolation.py create mode 100755 no_isolation.py create mode 100644 templates/blocking_run_native_unix.sh create mode 100644 templates/blocking_run_native_unix2.sh create mode 100644 templates_no_isolation/blocking_run_native_unix.sh create mode 100644 templates_no_isolation/blocking_run_native_unix2.sh create mode 100644 templates_no_isolation/run_native_custom_unix.sh create mode 100644 templates_no_isolation/run_native_unix.sh create mode 100644 templates_no_isolation/run_native_unix2.sh create mode 100644 templates_no_isolation/run_native_windows.ps1 create mode 100644 templates_no_isolation/run_native_windows_args.ps1 diff --git a/Makefile b/Makefile index ab81d8d..e696e44 100644 --- a/Makefile +++ b/Makefile @@ -20,18 +20,26 @@ install: ifeq "$(wildcard $(NATIVE_PLUGIN_DIR))" "" mkdir -p $(NATIVE_PLUGIN_DIR) sudo cp -r ./templates $(NATIVE_PLUGIN_DIR) + sudo cp -r ./templates_no_isolation $(NATIVE_PLUGIN_DIR) sudo cp -r ./utils $(NATIVE_PLUGIN_DIR) sudo cp ./__init__.py $(NATIVE_PLUGIN_DIR) + sudo cp ./isolation.py $(NATIVE_PLUGIN_DIR) + sudo cp ./no_isolation.py $(NATIVE_PLUGIN_DIR) sudo cp ./native_plugin $(NATIVE_PLUGIN_DIR) sudo cp ./NativeFDU.py $(NATIVE_PLUGIN_DIR) + sudo cp ./NativeNoIsolationFDU.py $(NATIVE_PLUGIN_DIR) sudo cp ./README.md $(NATIVE_PLUGIN_DIR) sudo cp ./native_plugin.json $(PLUGIN_CONF) else sudo cp -r ./templates $(NATIVE_PLUGIN_DIR) + sudo cp -r ./templates_no_isolation $(NATIVE_PLUGIN_DIR) sudo cp -r ./utils $(NATIVE_PLUGIN_DIR) sudo cp ./__init__.py $(NATIVE_PLUGIN_DIR) + sudo cp ./isolation.py $(NATIVE_PLUGIN_DIR) + sudo cp ./no_isolation.py $(NATIVE_PLUGIN_DIR) sudo cp ./native_plugin $(NATIVE_PLUGIN_DIR) sudo cp ./NativeFDU.py $(NATIVE_PLUGIN_DIR) + sudo cp ./NativeNoIsolationFDU.py $(NATIVE_PLUGIN_DIR) sudo cp ./README.md $(NATIVE_PLUGIN_DIR) endif sudo chmod +x $(NATIVE_PLUGIN_DIR)/utils/containerize diff --git a/NativeFDU.py b/NativeFDU.py index e6701f5..c046315 100644 --- a/NativeFDU.py +++ b/NativeFDU.py @@ -1,4 +1,4 @@ -# Copyright (c) 2014,2018 ADLINK Technology Inc. +# Copyright (c) 2014,2020 ADLINK Technology Inc. # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. diff --git a/NativeNoIsolationFDU.py b/NativeNoIsolationFDU.py new file mode 100644 index 0000000..f8eb692 --- /dev/null +++ b/NativeNoIsolationFDU.py @@ -0,0 +1,80 @@ +# Copyright (c) 2014,2020 ADLINK Technology Inc. +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License 2.0 which is available at +# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +# which is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +# +# Contributors: Gabriele Baldoni, ADLINK Technology Inc. - Base plugins set + +import sys +import os +from fog05_sdk.interfaces.States import State +from fog05_sdk.interfaces.InfraFDU import InfraFDU + +class NativeNoIsolationFDU(InfraFDU): + def __init__(self, data): + super(NativeNoIsolationFDU, self).__init__(data) + + self.name = 'n{}'.format(self.uuid) + self.cmd = None + self.args = None + + if self.command is not None: + self.cmd = self.command.get('binary') + self.args = self.command.get('args') + + self.outfile = None + self.pid = -1 + self.process = None + self.source = '' + # self.outfile = '' + + def set_cmd(self, command): + self.command = command + if command is not None: + self.cmd = command.get('binary') + self.args = command.get('args') + + def on_defined(self): + self.set_status(State.DEFINED) + + def on_configured(self, configuration): + self.conf = configuration + self.set_status(State.CONFIGURED) + + def on_clean(self): + self.set_status(State.DEFINED) + + def on_start(self, pid, process): + self.pid = pid + self.process = process + self.set_status(State.RUNNING) + + def on_stop(self): + self.pid = -1 + self.process = None + self.set_status(State.CONFIGURED) + + def on_pause(self): + self.set_status(State.PAUSED) + + def on_resume(self): + self.set_status(State.RUNNING) + + def before_migrate(self): + pass + + def after_migrate(self): + pass + + def __str__(self): + s = 'UUID {} Name {} Command {} ARGS {} OUTFILE {} PID {}' \ + ' SOURCE {}'.format(self.uuid, self.name, self.command, + self.args, self.outfile, self.pid, self.image) + return s diff --git a/README.md b/README.md index e99b50e..03a25ae 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -