diff --git a/src-local/LabLearningObject-hybrid b/src-local/LabLearningObject-hybrid
index 922df49..1f4f01d 160000
--- a/src-local/LabLearningObject-hybrid
+++ b/src-local/LabLearningObject-hybrid
@@ -1 +1 @@
-Subproject commit 922df495bbafc1b8580dc8bbdf019d27ac31f320
+Subproject commit 1f4f01de2f0c87e952dc8f3ea59bde7cd4bbe95c
diff --git a/src-local/llo/new.js b/src-local/llo/new.js
index d5b650d..8ba2bf8 100644
--- a/src-local/llo/new.js
+++ b/src-local/llo/new.js
@@ -675,6 +675,59 @@ app.get('/getservicesstatus', (req, res, next) => {
});
+app.get('/getstoragestatus', (req, res, next) => {
+
+ var RES = new Object();
+ RES.instance = req.query["instance"]
+ var showfile = `./instance/${RES.instance}/swarmlabconfig/instance`
+ //console.log(JSON.stringify(showfile))
+ fs.readFile(showfile, 'utf8', function (err, data) {
+ if (err) {
+ var found = 'no'
+ RES.error = false
+ RES.error_msg = "ok"
+ RES.data = "no sudorun file found";
+ console.log(JSON.stringify(err))
+ res.json(RES)
+ }else{
+
+ data = data.trim();
+
+ var showexec = `docker ps --format '{"Names":"{{ .Names }}", "Status":"{{.Status}}"}' | jq . -s `
+ exec(showexec, (err, stdout, stderr) => {
+ if (err) {
+ return;
+ }
+ if (stdout) {
+ var string = stdout.toString()
+ var datajson = JSON.parse(string);
+ var extenderror = new RegExp(data);
+ var found = 'no';
+ for(var i = 0; i < datajson.length; i++) {
+ var servicename = datajson[i].Names
+ if(extenderror.test(servicename)){
+ found = 'yes';
+ }
+ }
+ RES.error = false
+ RES.error_msg = "ok"
+ RES.test = datajson;
+ RES.data = found;
+ res.json(RES)
+
+ }else{
+ var found = 'no'
+ RES.error = false
+ RES.error_msg = "ok"
+ RES.data = found;
+ res.json(RES)
+ }
+ });
+ }
+ });
+
+});
+
app.get('/rm_swarmlab', (req, res, next) => {
var mypath = process.cwd()
@@ -696,6 +749,28 @@ app.get('/rm_swarmlab', (req, res, next) => {
}
});
+});
+app.get('/rm_swarmlabstorage', (req, res, next) => {
+
+ var mypath = process.cwd()
+ var RES = new Object();
+ RES.instance = req.query["instance"]
+ var services_path = './instance/'+RES.instance
+ fs.rm(services_path, {
+ recursive: true,
+ force: true
+ }, (error) => {
+ if (error) {
+ RES.error = true
+ RES.error_msg = "no"
+ res.json(RES)
+ } else {
+ RES.error = false
+ RES.error_msg = "ok"
+ res.json(RES)
+ }
+ });
+
});
app.get('/get_config', (req, res, next) => {
@@ -1033,6 +1108,60 @@ TEST=${service}
}
});
+ socket.on('start_storage', (value) => {
+ if(value.swarmlabname){
+ var service = value.swarmlabname
+ var services_path = './instance/'+service
+ var ENV_service_file_path = services_path+'/.env'
+ var service_password = ''
+ if(value.password){
+ service_password = value.password
+ }else{
+ service_password = Math.random().toString(36).substring(7);
+ }
+
+ var ENV_service_file = `
+SWARMLAB_STORAGE_PASSWORD=${service_password}
+`
+ fs.writeFileSync(ENV_service_file_path, ENV_service_file ,{encoding:'utf8',flag:'a'});
+
+ var service_up = '/bin/bash ./run.sh'
+
+ child[0] = spawn(service_up, {
+ shell: true,
+ cwd: services_path,
+ //detached: true,
+ detached: false,
+ //stdio: [ 'ignore', logout, logerr ]
+ stdio: 'pipe'
+ });
+
+ ppid = child[0].pid;
+ //console.log(ppid)
+ child[0].stdout.on('data', function (data) {
+ var n = {}
+ n.data = data.toString()
+ io.emit('message_out_storage', n);
+ });
+
+ child[0].stderr.on('data', function (data) {
+ var n = {}
+ n.data = data.toString()
+ io.emit('message_err_storage', n);
+ });
+
+ child[0].on('close', function (code) {
+ var n = {}
+ n.data = code
+ io.emit('message_close_storage', n);
+ });
+ }else{
+ var n = {}
+ n.data = 'NoSwarmlabname'
+ io.emit('message_err_storage', n);
+ }
+ });
+
socket.on('stop', (service) => {
var services_path = './instance/'+service+'/'+service
@@ -1060,6 +1189,33 @@ TEST=${service}
});
});
+ socket.on('stop_storage', (service) => {
+ var services_path = './instance/'+service
+ //console.log(services_path)
+ const stop = spawn('/bin/sh ./stop.sh', {
+ stdio: 'pipe',
+ shell: true,
+ cwd: services_path
+ });
+ stop.stdout.on('data', function (data) {
+ var n = {}
+ n.data = data.toString()
+ io.emit('message_out_storage', n);
+ });
+
+ stop.stderr.on('data', function (data) {
+ var n = {}
+ n.data = data.toString()
+ io.emit('message_err_storage', n);
+ });
+
+ stop.on('close', function (code) {
+ var n = {}
+ n.data = code
+ io.emit('message_close_storage', n);
+ });
+ });
+
socket.on('install', (value) => {
if(value.swarmlabname){
//console.log('install')
@@ -1145,6 +1301,94 @@ SSH_PORT=
}
});
+
+ socket.on('installstorage', (value) => {
+ if(value.swarmlabname){
+ //console.log('install')
+ var service = value.swarmlabname
+ var service_git = value.git
+ var services_path = './instance/'+service
+ var ENV_service_dir = services_path+'/'+service
+ var ENV_service_file_path = services_path+'/'+service+'/'.env
+ var nn = {}
+ nn.data = 'Wait for service(s) to be available before executing a command'
+ io.emit('message_out_storage', nn);
+ if (fs.existsSync(services_path)) {
+ const git = simpleGit(
+ {
+ baseDir: services_path,
+ maxConcurrentProcesses: 10
+ });
+ try {
+ git.pull()
+ .then((status) => {
+ var n = {}
+ n.data = 'Updated'
+ io.emit('message_out_storage', n);
+ n.data = '...'
+ io.emit('message_out_storage', n);
+ n.data = 'ok'
+ io.emit('message_close_storage', n);
+ //create_project_storage(service,service)
+ }).catch((err) => {
+ var n = {}
+ n.data = err.toString()
+ io.emit('message_err_storage', n);
+ console.log('error ' + JSON.stringify(err))
+ });
+ } catch (e) {
+ var n = {}
+ n.data = e.toString()
+ io.emit('message_err_storage', n);
+ }
+ }else{
+ fs.mkdir(services_path, { recursive: true }, (err) => {
+ if (err){
+ console.log('error ' + JSON.stringify(err))
+ }else{
+// var ENV_service_file = `
+//IMAGE_NAME=${service}
+//SSH_PORT=
+//`
+ const git = simpleGit(
+ {
+ baseDir: '.',
+ maxConcurrentProcesses: 10
+ });
+ try {
+ git.clone(service_git, services_path)
+ .then((status) => {
+ var n = {}
+ n.data = 'Installed'
+ io.emit('message_out_storage', n);
+ n.data = '...'
+ io.emit('message_out_storage', n);
+ n.data = 'ok'
+ io.emit('message_close_storage', n);
+ //fs.writeFileSync(ENV_service_file_path, ENV_service_file);
+ //create_project_storage(service,service)
+ }).catch((err) => {
+ var n = {}
+ n.data = err.toString()
+ io.emit('message_err_storage', n);
+ console.log('error ' + JSON.stringify(err))
+ });
+ } catch (e) {
+ var n = {}
+ n.data = e.toString()
+ io.emit('message_err_storage', n);
+ }
+
+ }
+ });
+ }
+ }else{
+ var n = {}
+ n.data = 'no services'
+ io.emit('message_err_storage', n);
+ }
+ });
+
socket.on('container-stop', (service, id) => {
var mypath = process.cwd()
//console.log(mypath);
diff --git a/src/App.vue b/src/App.vue
index b7b26f0..1860aee 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -256,7 +256,8 @@