From 7f3aabddd49090b5450ffe9cbc68ca5fa10a3def Mon Sep 17 00:00:00 2001 From: zeus Date: Sun, 23 Jan 2022 18:37:45 +0200 Subject: [PATCH] community menou 1 --- .gitignore | 10 +- run.yml | 22 + .../community/config/cse242017102-test.js | 17 - .../config/rootapostolos-ansibletest.js | 17 - .../community/config/rootapostolos-mytest1.js | 17 - src-local/llo/new.js | 135 +++++- src-local/myconfig/default.conf | 44 ++ src-local/myconfig/nginx.conf | 29 ++ src-local/myconfig/sec_bootstrap | 77 ++++ src/components/mynetwork/AdhocView.vue | 1 + .../mynetwork/availablemicroservices.vue | 7 + .../availablemicroservicescustom.vue | 4 +- src/components/mynetwork/dockerservices.vue | 3 +- src/components/mynetwork/mytable.vue | 397 ++++++++++++++---- src/config/index-gui.js | 38 ++ src/store/modules/create_pipelineLLO.js | 64 +++ 16 files changed, 743 insertions(+), 139 deletions(-) delete mode 100644 src-local/community/config/cse242017102-test.js delete mode 100644 src-local/community/config/rootapostolos-ansibletest.js delete mode 100644 src-local/community/config/rootapostolos-mytest1.js create mode 100755 src-local/myconfig/default.conf create mode 100755 src-local/myconfig/nginx.conf create mode 100755 src-local/myconfig/sec_bootstrap diff --git a/.gitignore b/.gitignore index ce5b35d..9cfcd7c 100644 --- a/.gitignore +++ b/.gitignore @@ -18,14 +18,12 @@ viwsession/ testfilemanager/ README-update -!./src-local/community/config/ +!./src-local/community/config/README !./src-local/community/custom/ !./src-local/community/README -./src-local/community/ -src-local/community/rootapostolos@swarmlab.io_mytest1_microservice-ipterm/ -src-local/community/rootapostolos@swarmlab.io_ansibletest_microservice-alpine313/ -src-local/community/cse242017102@uniwa.gr_test_microservice-nodejs/ -src-local/builders/bento-swarmlab/ +src-local/community/* +src-local/community/config/* +src-local/builders/bento-swarmlab/* swarmlabdoc.js swarmlabdoc.asciidoc_config diff --git a/run.yml b/run.yml index b625cf2..6d0fa14 100644 --- a/run.yml +++ b/run.yml @@ -121,6 +121,28 @@ services: - ${nodepath}/src-local/instance:/instance - ${nodepath}/src-local/community:/community + swarmlabsidecarserver: + image: hub.swarmlab.io:5480/hybrid-nginx:latest + user: docker + #privileged: true + container_name: swarmlab-sidecar-agent + entrypoint: ["/usr/bin/sec_bootstrap", "role=masterservice", "sec_master_service_name=masterservice", "sec_worker_service_name=workerservice"] + environment: + - NODENAME={{.Node.Hostname}} + - NODEID={{.Node.ID}} + ports: + - "3384:80" + volumes: + - ${nodepath}/src-local/instance:/data/www/instance + - ${nodepath}/src-local/community:/data/www/community + - ${nodepath}/src-local/myconfig/sec_bootstrap:/usr/bin/sec_bootstrap + - ${nodepath}/src-local/myconfig/nginx.conf:/etc/nginx/nginx.conf + - ${nodepath}/src-local/myconfig/default.conf:/etc/nginx/conf.d/default.conf +# - ${nodepath}/src-local/myconfig/supervisord.conf:/etc/supervisor/supervisord.conf + - /etc/localtime:/etc/localtime:ro + networks: + hybrid-net: + networks: hybrid-net: diff --git a/src-local/community/config/cse242017102-test.js b/src-local/community/config/cse242017102-test.js deleted file mode 100644 index 615725f..0000000 --- a/src-local/community/config/cse242017102-test.js +++ /dev/null @@ -1,17 +0,0 @@ -{ - "servicedata": { - "service": "test", - "baseservice": "microservice-nodejs", - "user": "cse242017102@uniwa.gr", - "port1": "", - "url1": "", - "name1": "", - "port2": "", - "url2": "", - "name2": "", - "port3": "", - "url3": "", - "name3": "" - }, - "baseservicedata": {"name":"microservice-nodejs","custom":"true","customostext":"Base OS: alpine:3.13","customos":"apk add --no-cache net-tools ","customshtext":"It is executed after all the normal builds","customsh":" #!/bin/sh","app":false,"url":"http","port":"80/tcp","ttyd":true,"ttydport":"3787/tcp","ttydurl":"http"} -} \ No newline at end of file diff --git a/src-local/community/config/rootapostolos-ansibletest.js b/src-local/community/config/rootapostolos-ansibletest.js deleted file mode 100644 index e620224..0000000 --- a/src-local/community/config/rootapostolos-ansibletest.js +++ /dev/null @@ -1,17 +0,0 @@ -{ - "servicedata": { - "service": "ansibletest", - "baseservice": "microservice-alpine313", - "user": "rootapostolos@swarmlab.io", - "port1": "", - "url1": "", - "name1": "", - "port2": "", - "url2": "", - "name2": "", - "port3": "", - "url3": "", - "name3": "" - }, - "baseservicedata": {"name":"microservice-alpine313","large":"no","custom":"true","customostext":"Base OS: alpine3.13","customos":"apk add --no-cache net-tools ","customshtext":"It is executed after all the normal builds","customsh":" #!/bin/sh","app":false,"url":"http","port":"80/tcp","ttyd":true,"ttydport":"3787/tcp","ttydurl":"http"} -} \ No newline at end of file diff --git a/src-local/community/config/rootapostolos-mytest1.js b/src-local/community/config/rootapostolos-mytest1.js deleted file mode 100644 index ef570d8..0000000 --- a/src-local/community/config/rootapostolos-mytest1.js +++ /dev/null @@ -1,17 +0,0 @@ -{ - "servicedata": { - "service": "mytest1", - "baseservice": "microservice-ipterm", - "user": "rootapostolos@swarmlab.io", - "port1": "8081", - "url1": "http", - "name1": "n1", - "port2": "8082", - "url2": "http", - "name2": "n2", - "port3": "8083", - "url3": "https", - "name3": "n3" - }, - "baseservicedata": {"name":"microservice-ipterm","custom":"true","customostext":"Base OS: debian:jessie ","customos":"apt-get update && apt-get install -y --no-install-recommends net-tools","customshtext":"It is executed after all the normal builds","customsh":" #!/bin/sh","app":false,"url":"http","port":"80/tcp","ttyd":true,"ttydport":"3787/tcp","ttydurl":"http"} -} \ No newline at end of file diff --git a/src-local/llo/new.js b/src-local/llo/new.js index 01ac7b0..60d3217 100644 --- a/src-local/llo/new.js +++ b/src-local/llo/new.js @@ -1653,9 +1653,6 @@ app.get('/rungui', (req, res, next) => { var runpath = `./instance/${RES.instance}/${RES.instance}` var runpathfile = `./instance/${RES.instance}/${RES.instance}/run-gui.sh` - //console.log(runpath) - //console.log(showexec) - var buildoutdir = `${runpath}/logs/build-out.log` var builderrdir = `${runpath}/logs/build-out.log` //const buildout = fs.openSync(buildoutdir, 'a'); @@ -1726,6 +1723,94 @@ try { }); +app.get('/runguicustom', (req, res, next) => { + var RES = new Object(); + RES.instance = req.query["instance"] + RES.exec = req.query["exec"] + RES.imageid = req.query["id"] + RES.error = false + RES.error_msg = "ok" + RES.error_msg0 = "" + RES.data = "All_services_are_running"; + var showexec = `./run-gui.sh` + //var runpath = `./instance/${RES.instance}/${RES.instance}` + var runpath = `./${RES.instance}` + var runpathfile = `${runpath}/run-gui.sh` + + var buildoutdir = `${runpath}/logs/build-out.log` + var builderrdir = `${runpath}/logs/build-out.log` + //const buildout = fs.openSync(buildoutdir, 'a'); + //const builderr = fs.openSync(builderrdir, 'a'); +try { + const buildout = fs.openSync(buildoutdir, 'a'); + const builderr = fs.openSync(builderrdir, 'a'); + var runexec = `xhost +local:docker + docker exec -e DISPLAY=\$DISPLAY ${RES.imageid} ${RES.exec} + +` + const extrapackagestext = fs.writeFileSync(runpathfile, runexec, {encoding:'utf8'}); + var buildimage = `echo "EXEC PID: $$"; ${showexec}` + //var buildimage = `echo "EXEC PID: $$"; docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix microservice-firefox /bin/sh -c "firefox"` + const run_buildimage = spawn(buildimage, { + detached: true, + shell: true, + stdio: [ 'ignore', buildout, builderr ], + cwd: runpath + }); + + var n = {} + n.pid = run_buildimage.pid + io.emit('build_set_buildpid', n); + + n.data = 'start ...' + io.emit('message_out', n); + + n.data = 'i am trying to automatically start the application' + io.emit('message_out', n); + + n.data = 'If this fails, try:' + io.emit('message_out', n); + + var buildtmpexec = "" + buildtmpexec = fs.readFileSync(runpathfile, {encoding:'utf8', flag:'r'}); + + //var buildtmpexec = `docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix microservice-firefox /bin/sh -c "firefox"` + + n.data = buildtmpexec + io.emit('message_out', n); + + run_buildimage.on('exit', (data) => { + //console.log('exit '+data); + var n = {} + n.data = 'exit!' + io.emit('message_close', n); + }); + run_buildimage.on('close', (data) => { + //console.log('close '+data); + var n = {} + n.data = 'close!' + io.emit('message_close', n); + + n.name = `${RES.instance}` + n.dir = `${runpath}` + io.emit('message_close_build', n); + RES.error = false + RES.error_msg = 'no' + RES.data = 'no' + res.json(RES) + }); + console.log(run_buildimage.pid); + run_buildimage.unref(); +} catch (error) { + console.log('Error:', error); + RES.error = true + RES.error_msg = error + RES.data = 'no' + res.json(RES) +} + +}); + app.get('/runeditor', (req, res, next) => { var RES = new Object(); var mypath1 = process.cwd() @@ -2136,6 +2221,38 @@ app.get('/getcustom', (req, res, next) => { } }); +app.get('/getlog4gui', (req, res, next) => { + var RES = new Object(); + var mypath1 = process.cwd() + var runuser = process.env.USER || "" + RES.instance = req.query["instance"] + RES.error = false + RES.error_msg = "ok" + var instancedir = `${mypath1}/${RES.instance}` + console.log(instancedir) + if (fs.existsSync(instancedir)) { + try { + const log = fs.readFileSync(instancedir, {encoding:'utf8', flag:'r'}); + RES.error = false + RES.error_msg = 'ok' + RES.log = log + res.json(RES) + } catch (error) { + RES.error = true + RES.error_msg = error + RES.data = 'no' + RES.log = 'no' + res.json(RES) + } + }else{ + RES.error = false + RES.error_msg = 'nodir' + RES.data = 'no' + RES.log = 'no' + res.json(RES) + } +}); + app.get('/getcustomuser', (req, res, next) => { var RES = new Object(); var mypath1 = process.cwd() @@ -3832,6 +3949,18 @@ TEST=${value.baseservice} //console.log('value2 '+JSON.stringify(ENV_service_file_os)) var service_up = '/bin/bash ../install/usr/share/swarmlab.io/sec/swarmlab-sec up size='+service_size + + const comment_clearall = /\s\bclear_all\b(?!.*\()/g; + // /\bclear_all\b(?!.*\()/g; + var myservicecustom_buildfile = `./community/${value.user}_${value.service}_${value.baseservice}/install/usr/share/swarmlab.io/sec/swarmlab-sec` + var changeclearall = fs.readFileSync(myservicecustom_buildfile, 'utf8') + if (changeclearall.match(comment_clearall)) { + var changeclearall_tmp = changeclearall.replace(comment_clearall, ' #clear_all\necho ""') + fs.writeFileSync(myservicecustom_buildfile, changeclearall_tmp ,{encoding:'utf8',flag:'w'}); + } + + + child[0] = spawn(service_up, { shell: true, cwd: services_path, diff --git a/src-local/myconfig/default.conf b/src-local/myconfig/default.conf new file mode 100755 index 0000000..1072e80 --- /dev/null +++ b/src-local/myconfig/default.conf @@ -0,0 +1,44 @@ +server { + listen 80; + server_name localhost; + + #charset koi8-r; + #access_log /var/log/nginx/log/host.access.log main; + + location / { + root /data/www; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /data/www; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} diff --git a/src-local/myconfig/nginx.conf b/src-local/myconfig/nginx.conf new file mode 100755 index 0000000..95505c2 --- /dev/null +++ b/src-local/myconfig/nginx.conf @@ -0,0 +1,29 @@ +user www-data; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '[$time_local] $remote_user:$remote_addr "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/src-local/myconfig/sec_bootstrap b/src-local/myconfig/sec_bootstrap new file mode 100755 index 0000000..c37862f --- /dev/null +++ b/src-local/myconfig/sec_bootstrap @@ -0,0 +1,77 @@ +#!/bin/sh + +ROLE="undefined" +MPI_MASTER_SERVICE_NAME="sec_masterservice" +MPI_WORKER_SERVICE_NAME="sec_workerservice" +HOSTNAMES="/etc/nethosts" + +####################### +# ARGUMENTS PARSER + +while [ "$1" != "" ]; +do + PARAM=$(echo "$1" | awk -F= '{print $1}') + VALUE=$(echo "$1" | awk -F= '{print $2}') + + case $PARAM in + role) + [ "$VALUE" ] && ROLE=$VALUE + ;; + + sec_master_service_name) + [ "$VALUE" ] && MPI_MASTER_SERVICE_NAME=$VALUE + ;; + + sec_worker_service_name) + [ "$VALUE" ] && MPI_WORKER_SERVICE_NAME=$VALUE + ;; + *) + echo "ERROR: unknown parameter \"$PARAM\"" + exit 1 + ;; + esac + shift +done + + + +cat > /etc/opt/service_names <<- EOF +MPI_MASTER_SERVICE_NAME=${MPI_MASTER_SERVICE_NAME} +MPI_WORKER_SERVICE_NAME=${MPI_WORKER_SERVICE_NAME} +EOF + +case $ROLE in + "masterservice") + + # Auto update default host file in background and dumb all output + auto_update_hosts "${HOSTNAMES}" > /dev/null 2>&1 & + #/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf + #ttyd -p 3787 bash & + /usr/sbin/nginx + sleep 1 + /usr/sbin/nginx + tail -f /dev/null + # Start ssh server + #/usr/sbin/sshd -D + ;; + + + "workerservice") + + # Start ssh server in background + #/usr/sbin/sshd -D & + + # Keep trying to connect to master node and stay there indefinitely so that master node can see + # the connected hosts that are ready for MPI work + #while sleep 1 + #do + # shellcheck disable=SC2086 + # ssh -T -o "StrictHostKeyChecking no" \ + # -i "${USER_HOME}/.ssh/id_rsa" \ + # ${USER}@${MPI_MASTER_SERVICE_NAME} \ + tail -f /dev/null + #done + ;; + *) + echo 'role argument only accepts "masterservice" or "workerservice"' +esac diff --git a/src/components/mynetwork/AdhocView.vue b/src/components/mynetwork/AdhocView.vue index 61389d5..b6fe7ec 100644 --- a/src/components/mynetwork/AdhocView.vue +++ b/src/components/mynetwork/AdhocView.vue @@ -458,6 +458,7 @@ export default { }) // from runLLO this.$root.$on('hybrid_log_in', (log) => { + console.log(log) //this.code += log.data //this.code += "\n" //console.log(" form socket log "+JSON.stringify(this.code)) diff --git a/src/components/mynetwork/availablemicroservices.vue b/src/components/mynetwork/availablemicroservices.vue index 7fceb4c..83ccd47 100644 --- a/src/components/mynetwork/availablemicroservices.vue +++ b/src/components/mynetwork/availablemicroservices.vue @@ -34,6 +34,13 @@
+ +
+ {{ webinterfacegeneric_text }}
+ + + +
+ + +
+ +
+ {{ webinterfacegeneric_menou2_text }} + + + + + +
+ +
+ {{ webinterfacegeneric_menou3_text }} + + + + + +
+
+ + + -
@@ -387,6 +489,39 @@ export default { localNetworkdefault:'', webinterface: false, webinterfacegeneric: false, + webinterfacegeneric_text: 'openGui', + webinterfacegeneric_menou1_url_target1: '_blank', + webinterfacegeneric_menou1_url_target2: '_blank', + webinterfacegeneric_menou1_url_target3: '_blank', + + webinterfacegeneric_menou_exec: '', + webinterfacegeneric_menou_basedir: '', + swarmlab_services_type: 'swarmlab', + + webinterfacegeneric_menou1: false, + webinterfacegeneric_menou1_text: '', + webinterfacegeneric_menou1_url: '', + webinterfacegeneric_menou1typelog: false, + webinterfacegeneric_menou1typelog_active: false, + webinterfacegeneric_menou1typedir: '', + webinterfacegeneric_menou1typedir_log: '', + + webinterfacegeneric_menou2: false, + webinterfacegeneric_menou2_text: '', + webinterfacegeneric_menou2_url: '', + webinterfacegeneric_menou2typelog: false, + webinterfacegeneric_menou2typelog_active: false, + webinterfacegeneric_menou2typedir: '', + webinterfacegeneric_menou2typedir_log: '', + + webinterfacegeneric_menou3: false, + webinterfacegeneric_menou3_text: '', + webinterfacegeneric_menou3_url: '', + webinterfacegeneric_menou3typelog: false, + webinterfacegeneric_menou3typelog_active: false, + webinterfacegeneric_menou3typedir: '', + webinterfacegeneric_menou3typedir_log: '', + webinterfacegenericedit: false, webinterface_port: '', STATUS:{}, @@ -422,6 +557,7 @@ export default { swarmlabname_git:'', // run on hybridshowdata:{}, + hybridshowdata_user:{}, hybridshowdatashare:{}, issocket:'close', setFilter: {}, @@ -437,85 +573,122 @@ export default { }, mounted() { this.$root.$on('hybrid_show_info', (data) => { - -// -------------- new menou - this.actionrowindex = false - this.actionrowindexselect = true - this.addNetworkMenou = false - this.actionrowindexconsole = false - this.$root.$emit('hybrid_show_instance_images','images') -// -------------- new menou - - - this.webinterface = false - this.webinterfacegeneric = false - this.webinterfacegenericedit = false - this.$nextTick(function () { - this.hybridshowdata = data - - var filterju = `microservice-jupyter` - var grepju = new RegExp(filterju); - + (async () => { + // -------------- new menou + this.actionrowindex = false + this.actionrowindexselect = true + this.addNetworkMenou = false + this.actionrowindexconsole = false + this.$root.$emit('hybrid_show_instance_images','images') + // -------------- new menou + + this.webinterface = false + this.webinterfacegeneric = false + this.webinterfacegenericedit = false + // this.$nextTick(function () { + this.hybridshowdata = data + var filterju = `microservice-jupyter` + var grepju = new RegExp(filterju); if(grepju.test(data.Networks) && grepju.test(data.Names)){ this.webinterface = true this.webinterface_port = data.Ports - //console.log(JSON.stringify(this.webinterface_port)) }else{ this.webinterface = false this.webinterface_port = '' } - var urlgeniGUIEDITOR = this.hybridshowdata.Names.split('_'); - // EDITOR - for(var i = 0; i < ApiConfigEDIT.length; i++) { - var obGUIEDIT = ApiConfigEDIT[i]; - if(obGUIEDIT.name == urlgeniGUIEDITOR[0]){ - this.webinterfacegenericedit = true - } - } + var urlgeniGUIEDITOR = this.hybridshowdata.Names.split('_'); + // EDITOR + for(var i = 0; i < ApiConfigEDIT.length; i++) { + var obGUIEDIT = ApiConfigEDIT[i]; + if(obGUIEDIT.name == urlgeniGUIEDITOR[0]){ + this.webinterfacegenericedit = true + } + } -//EDITORcustom - (async () => { - var strbase = '_masterservice_1' - var sRegExInput1 = new RegExp(strbase, 'g'); - var getcustomnames = this.hybridshowdata.Names.replace(sRegExInput1 ,''); - var logdatacustom = await store.dispatch("pipelineLLO/getinstallcustom",{ - token:this.token, - instance:getcustomnames - }) - //console.log(logdatacustom.data); - if(logdatacustom.data && logdatacustom.data.data){ - //console.log(logdatacustom.data.data); - var urlgeniGUIEDITOR = this.hybridshowdata.Names.split('_'); - this.webinterfacegenericedit = true - } -})(); - var urlgeniGUI = this.hybridshowdata.Names.split('_'); - // GUI firefox - for(var i = 0; i < ApiConfigGUI.length; i++) { - var obGUI = ApiConfigGUI[i]; - if(obGUI.name == urlgeniGUI[0]){ - this.webinterfacegeneric = true - //console.log(obGUI.name); - } - } -/* - var filterjugeneric = `microservice-firefox` - var grepju1 = new RegExp(filterjugeneric); + //EDITORcustom + var strbase = '_masterservice_1' + var sRegExInput1 = new RegExp(strbase, 'g'); + var getcustomnames = this.hybridshowdata.Names.replace(sRegExInput1 ,''); + var logdatacustom = await store.dispatch("pipelineLLO/getinstallcustom",{ + token:this.token, + instance:getcustomnames + }) + //console.log(logdatacustom.data); + if(logdatacustom.data && logdatacustom.data.data){ + this.hybridshowdata_user = JSON.parse(logdatacustom.data.data) + console.log(this.hybridshowdata_user); + var urlgeniGUIEDITOR = this.hybridshowdata.Names.split('_'); + this.webinterfacegenericedit = true + var urlgeniGUI = this.hybridshowdata_user.servicedata.baseservice + this.swarmlab_services_type = 'custom' + }else{ + var urlgeniGUItmp = this.hybridshowdata.Names.split('_'); + var urlgeniGUI = urlgeniGUItmp[0] + this.swarmlab_services_type = 'swarmlab' + } + // GUI firefox + for(var i = 0; i < ApiConfigGUI.length; i++) { + var obGUI = ApiConfigGUI[i]; + if(obGUI.name == urlgeniGUI){ + this.webinterfacegeneric = true + this.webinterfacegeneric_text = obGUI.menou + this.webinterfacegeneric_menou_exec = obGUI.exec + //console.log(obGUI.name); + if(this.hybridshowdata_user.servicedata && this.swarmlab_services_type == 'custom'){ + var baseservicetmp1 = this.hybridshowdata_user.servicedata.user.split('@') + var baseservicecustom = `${baseservicetmp1[0]}-${this.hybridshowdata_user.servicedata.service}` + this.webinterfacegeneric_menou_basedir = `community/${this.hybridshowdata_user.servicedata.user}_${this.hybridshowdata_user.servicedata.service}_${this.hybridshowdata_user.servicedata.baseservice}/${baseservicecustom}` + }else{ + var baseservicetmp1 = this.hybridshowdata.Names.split('_') + this.webinterfacegeneric_menou_basedir = `instance/${baseservicetmp1[0]}/${baseservicetmp1[0]}` + } + + if(obGUI.menou1){ + this.webinterfacegeneric_menou1 = true + this.webinterfacegeneric_menou1_text = obGUI.menou1 + this.webinterfacegeneric_menou1_url = `${obGUI.menou1server}/${this.webinterfacegeneric_menou_basedir}/${obGUI.menou1url}` + this.webinterfacegeneric_menou1_url_target1 = urlgeniGUI+'_1' + if(obGUI.menou1type == 'log'){ + this.webinterfacegeneric_menou1typelog = true + this.webinterfacegeneric_menou1typedir = `${this.webinterfacegeneric_menou_basedir}/${obGUI.menou2url}` + } + + } + if(obGUI.menou2){ + this.webinterfacegeneric_menou2 = true + this.webinterfacegeneric_menou2_text = obGUI.menou2 + this.webinterfacegeneric_menou2_url = `${obGUI.menou2server}/${this.webinterfacegeneric_menou_basedir}/${obGUI.menou2url}` + this.webinterfacegeneric_menou1_url_target2 = urlgeniGUI+'_2' + if(obGUI.menou2type){ + if(obGUI.menou2type == 'log'){ + this.webinterfacegeneric_menou2typelog = true + this.webinterfacegeneric_menou2typedir = `${this.webinterfacegeneric_menou_basedir}/${obGUI.menou2url}` + } + } + } + if(obGUI.menou3){ + this.webinterfacegeneric_menou3 = true + this.webinterfacegeneric_menou3_text = obGUI.menou3 + this.webinterfacegeneric_menou3_url = `${obGUI.menou3server}/${this.webinterfacegeneric_menou_basedir}/${obGUI.menou3url}` + this.webinterfacegeneric_menou1_url_target2 = urlgeniGUI+'_3' + if(obGUI.menou3type == 'log'){ + this.webinterfacegeneric_menou3typelog = true + this.webinterfacegeneric_menou3typedir = `${this.webinterfacegeneric_menou_basedir}/${obGUI.menou2url}` + } + } + } + + } + this.addNetworkMenou = false + this.localNetworks = [] + this.selectedNetworks = [] + this.localNetworkoptions = [] + this.localNetworkdefault = '' + //console.log(JSON.stringify(this.hybridshowdata)) + // }) + })(); + }) - if(grepju1.test(data.Networks) && grepju1.test(data.Names)){ - this.webinterfacegeneric = true - }else{ - this.webinterfacegeneric = false - } -*/ - this.addNetworkMenou = false - this.localNetworks = [] - this.selectedNetworks = [] - this.localNetworkoptions = [] - this.localNetworkdefault = '' - //console.log(JSON.stringify(this.hybridshowdata)) - }) - }) // from available services socket run here this.$root.$on('hybrid_start_instance', (data) => { this.swarmlabname = data.swarmlabname @@ -671,6 +844,57 @@ export default { }, methods: { + async guilogsclose(action){ + this.webinterfacegeneric_menou1typelog_active = false + this.webinterfacegeneric_menou2typelog_active = false + this.webinterfacegeneric_menou3typelog_active = false + this.actionrowindexconsole = false + this.$root.$emit('hybrid_show_instance_images','images') + }, + async guilogs(action){ + var logdatacustom = await store.dispatch("pipelineLLO/getlog4gui",{ + token:this.token, + instance:this.webinterfacegeneric_menou2typedir + }) + if(!logdatacustom.data.error){ + if(logdatacustom.data.log != 'no'){ + if(action == 1){ + this.webinterfacegeneric_menou1typedir_log = logdatacustom.data.log + this.webinterfacegeneric_menou1typelog_active = true + this.actionrowindexconsole = true + this.$root.$emit('hybrid_show_instance_images','console') + var val = {} + val.data = this.webinterfacegeneric_menou1typedir_log + var log = await store.dispatch("pipelineLLO/getlogs",{ + container:this.hybridshowdata.ID + }) + this.$root.$emit('hybrid_log_in',val) + }else if(action == 2){ + this.webinterfacegeneric_menou2typedir_log = logdatacustom.data.log + this.webinterfacegeneric_menou2typelog_active = true + this.actionrowindexconsole = true + this.$root.$emit('hybrid_show_instance_images','console') + var val = {} + val.data = this.webinterfacegeneric_menou2typedir_log + var log = await store.dispatch("pipelineLLO/getlogs",{ + container:this.hybridshowdata.ID + }) + this.$root.$emit('hybrid_log_in',val) + }else if(action == 3){ + this.webinterfacegeneric_menou3typedir_log = logdatacustom.data.log + this.webinterfacegeneric_menou3typelog_active = true + this.actionrowindexconsole = true + this.$root.$emit('hybrid_show_instance_images','console') + var val = {} + val.data = this.webinterfacegeneric_menou3typedir_log + var log = await store.dispatch("pipelineLLO/getlogs",{ + container:this.hybridshowdata.ID + }) + this.$root.$emit('hybrid_log_in',val) + } + } + } + }, async updateNetwork(container,action){ // console.log(JSON.stringify(container)); // console.log(JSON.stringify('selected :' + this.selectedNetworks)); @@ -929,13 +1153,29 @@ info += '

' }else if(action == 'container-logsclose'){ this.actionrowindexconsole = false this.$root.$emit('hybrid_show_instance_images','images') + this.webinterfacegeneric_menou1typelog_active = false + this.webinterfacegeneric_menou2typelog_active = false + this.webinterfacegeneric_menou3typelog_active = false }else if(action == 'startwebgeneric'){ + this.$wait.start('myRunInstanceeditor'); var urlgen = this.hybridshowdata.Names.split('_'); //console.log('logs---------- ' + JSON.stringify(this.hybridshowdata)) //console.log('logs---------- ' + JSON.stringify(urlgen[0])) - var log = await store.dispatch("pipelineLLO/rungui",{ - instance:urlgen[0] + if(this.swarmlab_services_type == 'swarmlab'){ + var log = await store.dispatch("pipelineLLO/rungui",{ + instance:urlgen[0] }) + } else if(this.swarmlab_services_type == 'custom'){ + var baseservicetmp1as = this.hybridshowdata_user.servicedata.user.split('@') + var baseservicecustomas = `${baseservicetmp1as[0]}-${this.hybridshowdata_user.servicedata.service}` + var guicustom = `community/${this.hybridshowdata_user.servicedata.user}_${this.hybridshowdata_user.servicedata.service}_${this.hybridshowdata_user.servicedata.baseservice}/${baseservicecustomas}` + var log = await store.dispatch("pipelineLLO/runguicustom",{ + instance:guicustom, + exec:this.webinterfacegeneric_menou_exec, + id:baseservicecustomas + }) + } + this.$wait.end('myRunInstanceeditor'); }else if(action == 'startweb'){ var log = await store.dispatch("pipelineLLO/getjupyterinfo",{ instance:this.hybridshowdata.Names @@ -1175,13 +1415,16 @@ if(pocurlcodeserver != 'no'){ token:this.token, instance:getcustomnames }) - console.log('---------------------') - console.log(logdatacustom.data) + //console.log('---------------------') + //console.log(logdatacustom.data) if(logdatacustom.data && logdatacustom.data.data){ // EDITORcustom var logdatacustomres = JSON.parse(logdatacustom.data.data) + // console.log(JSON.parse(logdatacustom.data.data)) + //console.log('------111111111111111---------------') + var swarmlabinstance1cda1 = new RegExp("(->)"); if(swarmlabinstance1cda1.test(this.hybridshowdata.Ports)){ var splitcda1split = this.hybridshowdata.Ports.split(',') diff --git a/src/config/index-gui.js b/src/config/index-gui.js index f2276ad..14cda19 100644 --- a/src/config/index-gui.js +++ b/src/config/index-gui.js @@ -1,26 +1,64 @@ export const ApiConfigGUI = [ + { + "name": "justtemplate", + "automated": true, + "version": 0, + + "menou": "xeLatex", + + "menou1": "ViewPDF", + "menou1url": "docs/main.pdf", + "menou1server": "http://localhost:3384", + + "menou2": "View2", + "menou2url": "docs2/main.pdf", + "menou2type": "log", + "menou2server": "http://localhost:3384", + + "menou3": "Compile", + "menou3url": "docs/main111111111111.pdf", + "menou3server": "http://localhost:3384", + + "port": 0 + }, { "name": "microservice-firefox", "automated": true, + "menou": "openGui", "version": 0, "port": 0 }, { "name": "microservice-xelatexthesis", "automated": true, + "exec": '/bin/sh -c "latex-all"', "version": 0, + + "menou": "Compile", + + "menou1": "View-PDF", + "menou1url": "docs/main.pdf", + "menou1server": "http://localhost:3384", + + "menou2": "xeLatex-LOG", + "menou2type": "log", + "menou2url": "docs/main.log", + "menou2server": "http://localhost:3394", + "port": 0 }, { "name": "microservice-wireshark", "automated": true, + "menou": "openGui", "version": 0, "port": 0 }, { "name": "microservice-oletools", "automated": true, + "menou": "openGui", "version": 0, "port": 0 } diff --git a/src/store/modules/create_pipelineLLO.js b/src/store/modules/create_pipelineLLO.js index 18d705d..bb986f4 100644 --- a/src/store/modules/create_pipelineLLO.js +++ b/src/store/modules/create_pipelineLLO.js @@ -494,6 +494,39 @@ export default { return R; } } + }, + async runguicustom({commit,rootGetters}, value) { + //console.log('value '+JSON.stringify(value)) + try { + var token = value.token + var params = { + instance: value.instance, + exec: value.exec, + id: value.id + } + var options = { + params: params, + headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` }, + }; + var sock_server_l = ApiConfig.url_80+'/runguicustom' + var p = await axios.get(sock_server_l,options); + //var p = await axios.get('https://localhost:3000/getservicesinfo',options); + return p + //console.log(JSON.stringify(p)) + //console.log(value.token) + //console.log(value.swarmlabname) + } catch (e) { + if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){ + //console.log('error '+JSON.stringify(e)) + window.location.href = 'https://api-login.swarmlab.io:8089'; + }else{ + var R = { + ERROR_str: e, + ERROR: 'yes' + } + return R; + } + } }, async getcustom({commit,rootGetters}, value) { //console.log('value '+JSON.stringify(value)) @@ -777,6 +810,37 @@ export default { return R; } } + }, + async getlog4gui({commit,rootGetters}, value) { + //console.log('value '+JSON.stringify(value)) + try { + var token = value.token + var params = { + instance: value.instance + } + var options = { + params: params, + headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` }, + }; + var sock_server_l = ApiConfig.url_80+'/getlog4gui' + var p = await axios.get(sock_server_l,options); + //var p = await axios.get('https://localhost:3000/getservicesinfo',options); + return p + //console.log(JSON.stringify(p)) + //console.log(value.token) + //console.log(value.swarmlabname) + } catch (e) { + if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){ + //console.log('error '+JSON.stringify(e)) + window.location.href = 'https://api-login.swarmlab.io:8089'; + }else{ + var R = { + ERROR_str: e, + ERROR: 'yes' + } + return R; + } + } }, async chowncustom({commit,rootGetters}, value) { //console.log('value '+JSON.stringify(value))