Skip to content

Commit

Permalink
Non isolation between running FDUs as option deployment of the Plugin…
Browse files Browse the repository at this point in the history
… + 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 <[email protected]>

* Added templates for blocking run fdus and implemented blocking run eval

Signed-off-by: gabrik <[email protected]>

* added evals for log, ls and file

Signed-off-by: gabrik <[email protected]>

* fix typo in get_log_fdu

Signed-off-by: gabrik <[email protected]>

* added start_fdu function for eval starting with env vars, updated run_blocking_fdu with env var parameter

Signed-off-by: gabrik <[email protected]>

* fix return of start_fdu

Signed-off-by: gabrik <[email protected]>

* fix return type of start_fdu

Signed-off-by: gabrik <[email protected]>

* fix in the implementation of start/run/log/ls/get_file evals

Signed-off-by: gabrik <[email protected]>

* reorganisation to merge with native plugin (with isolation)

Signed-off-by: gabrik <[email protected]>

* recopied old files into the rigth path

Signed-off-by: gabrik <[email protected]>

* 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 <[email protected]>

* added start/run/log/ls/get_file eval to isolated native plugin

Signed-off-by: gabrik <[email protected]>

* added utility function for parsing the environment

Signed-off-by: gabrik <[email protected]>

* updated makefile

Signed-off-by: gabrik <[email protected]>

* added missing files

Signed-off-by: gabrik <[email protected]>

* Adding missing service file

Signed-off-by: gabrik <[email protected]>

* typo fixes

Signed-off-by: gabrik <[email protected]>

* Added +x to to_uuid.sh

Signed-off-by: gabrik <[email protected]>

* added missing functions

Signed-off-by: gabrik <[email protected]>

* fixing missing namespace parameter in run and start FDU, in isolation

Signed-off-by: gabrik <[email protected]>

* fixing missing parameters in isolation.py

Signed-off-by: gabrik <[email protected]>

* using -E before to keep same environment variables in isolated binary

Signed-off-by: gabrik <[email protected]>

* updated fos_containerize usage

Signed-off-by: gabrik <[email protected]>
  • Loading branch information
gabrik authored Apr 28, 2020
1 parent 9a72741 commit 5960a67
Show file tree
Hide file tree
Showing 24 changed files with 1,995 additions and 653 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion NativeFDU.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
80 changes: 80 additions & 0 deletions NativeNoIsolationFDU.py
Original file line number Diff line number Diff line change
@@ -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
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,11 +25,12 @@ This plugin allow fog05 to manage native applications
supported operation:
- deploy
- destroy
- {{ pid_file }} parameter in starting native applications

todo:

- configure application with parameters
- isolation
- network attachment
- run (blocking)
- get output
- get files
- list files

---
package dependencies:
Expand All @@ -42,9 +43,3 @@ python dependencies:
- psutil
- jinja2


---

config dependencies:

- update the nodeid (result of `cat /etc/machine-id` ) in native_plugin.json->configuration->nodeid, and in case the yaks server is not in the same machine, also native_plugin.json->configuration->nodeid with the correct ip:port of the yaks server )
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -10,4 +10,4 @@
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors: Gabriele Baldoni, ADLINK Technology Inc. - Ocaml plugins set
# Contributors: Gabriele Baldoni, ADLINK Technology Inc. - Base plugins set
2 changes: 1 addition & 1 deletion containerize.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int main(int argc, char* argv[]){
}

}else{
printf("[Usage] %s <network namespace> <cmd> [command arguments]\n", argv[0]);
printf("[Usage] %s <network namespace> <child pid file> <cmd> [command arguments]\n", argv[0]);
}


Expand Down
Loading

0 comments on commit 5960a67

Please sign in to comment.