Browse Source

editor

master
zeus 3 years ago
parent
commit
fdf143eb72
  1. 2
      dist/index.html
  2. 2
      dist/js/app.2cff4c14.js
  3. 1
      dist/js/app.2cff4c14.js.map
  4. 2
      dist/js/app.b9ff8af2.js
  5. 1
      dist/js/app.b9ff8af2.js.map
  6. 76
      files/sec_bootstrap
  7. 13
      run.yml
  8. 90
      src-local/llo/new.js
  9. 2
      src-local/swarmlab_backup_service.sh
  10. 4
      src-local/swarmlab_editor_service
  11. 49
      src-local/swarmlab_editor_service.sh
  12. 36
      src/components/mynetwork/mytable.vue
  13. 11
      src/config/index-editor.js
  14. 31
      src/store/modules/create_pipelineLLO.js

2
dist/index.html

@ -1 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="/css/app.25658f84.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.b9ff8af2.js" rel="preload" as="script"><link href="/js/chunk-vendors.d8d18fe6.js" rel="preload" as="script"><link href="/css/chunk-vendors.e469b508.css" rel="stylesheet"><link href="/css/app.25658f84.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.b9ff8af2.js"></script></body></html>
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="/css/app.25658f84.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.2cff4c14.js" rel="preload" as="script"><link href="/js/chunk-vendors.d8d18fe6.js" rel="preload" as="script"><link href="/css/chunk-vendors.e469b508.css" rel="stylesheet"><link href="/css/app.25658f84.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.2cff4c14.js"></script></body></html>

2
dist/js/app.2cff4c14.js

File diff suppressed because one or more lines are too long

1
dist/js/app.2cff4c14.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.b9ff8af2.js

File diff suppressed because one or more lines are too long

1
dist/js/app.b9ff8af2.js.map

File diff suppressed because one or more lines are too long

76
files/sec_bootstrap

@ -0,0 +1,76 @@
#!/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 &
#tail -f /dev/null
ls /
#/root/start-nginx.sh
#python3 -m gns3server --port 8001
# 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} \
ls /
#tail -f /dev/null
#done
;;
*)
echo 'role argument only accepts "masterservice" or "workerservice"'
esac

13
run.yml

@ -87,6 +87,19 @@ services:
networks:
hybrid-net:
swarmlabeditor:
image: hub.swarmlab.io:5480/swarmlab-codeserver:latest
user: root
container_name: swarmlab-editor-agent
entrypoint: ["sec_bootstrap", "role=masterservice", "sec_master_service_name=masterservice", "sec_worker_service_name=workerservice"]
environment:
- NODENAME={{.Node.Hostname}}
- NODEID={{.Node.ID}}
volumes:
- ${nodepath}/files/sec_bootstrap:/usr/local/bin/sec_bootstrap
networks:
hybrid-net:
networks:
hybrid-net:

90
src-local/llo/new.js

@ -1471,12 +1471,92 @@ try {
io.emit('message_out', n);
var buildtmpexec = ""
try {
buildtmpexec = fs.readFileSync(runpathfile, {encoding:'utf8', flag:'r'});
} catch (err) {
console.log(err);
//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();
RES.instance = req.query["instance"]
RES.error = false
RES.error_msg = "ok"
RES.error_msg0 = ""
RES.data = "All_services_are_running";
var showexec = `./swarmlab_editor_service.sh ${RES.instance}`
var runpath = `.`
var runpathfile = `./swarmlab_editor_service.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');
//const builderr = fs.openSync(builderrdir, 'a');
try {
const buildout = fs.openSync(buildoutdir, 'a');
const builderr = fs.openSync(builderrdir, 'a');
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
@ -1497,6 +1577,10 @@ try {
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();

2
src-local/swarmlab_backup_service.sh

@ -42,7 +42,7 @@ service=$1
date=$(date '+%Y-%m-%d-%H-%M')
volume=1
docker inspect --format '{{json .Mounts }}' microservice-xelatexthesis_masterservice_1 | jq -c '.[]' | while IFS=$"\n" read -r line; do
docker inspect --format '{{json .Mounts }}' $service | jq -c '.[]' | while IFS=$"\n" read -r line; do
Local=$(echo "$line" | jq -r '.Source')
Dest=$(echo "$line" | jq -r '.Destination')
if [[ $Local == *"$servicebase"* ]]; then

4
src-local/swarmlab_editor_service

@ -0,0 +1,4 @@
#!/bin/bash
code-server --disable-update-check --bind-addr 0.0.0.0:8080 --user-data-dir /home --auth none &
firefox http://127.0.0.1:8080

49
src-local/swarmlab_editor_service.sh

@ -0,0 +1,49 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
if [[ $# -eq 0 ]] ; then
echo 'no service'
exit 1
fi
if [[ -z "$1" ]] ; then
echo 'no service'
exit 1
fi
service=$1
servicebase=$(echo $service | cut -d'_' -f1)
#code-server --disable-update-check --bind-addr 0.0.0.0:8080 --user-data-dir /home --auth none &
#firefox http://127.0.0.1:8080
xhost +local:docker
docker run --rm --volumes-from $service -e TZ=Europe/Athens -e DISPLAY=$DISPLAY -v $(pwd)/swarmlab_editor_service:/tmp/start -v /tmp/.X11-unix:/tmp/.X11-unix hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "/tmp/start"
#docker run --rm --volumes-from $service -e TZ=Europe/Athens -e DISPLAY=$DISPLAY --mount type=bind,source=$(pwd)/swarmlab_editor_service,target=/tmp/start -v /tmp/.X11-unix:/tmp/.X11-unix hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "/tmp/start"

36
src/components/mynetwork/mytable.vue

@ -13,7 +13,7 @@
<br>
<div class="row">
<div class="col-7">
<div class="col-5">
<div class="input-group input-group-sm sm-3">
<div class="input-group-prepend">
<button
@ -108,6 +108,22 @@
</div>
</div>
</div> <!-- col -->
<div class="col-1">
<div class="input-group input-group-sm sm-3">
<div class="input-group-prepend float-center">
<button
v-if="webinterfacegenericedit"
class="btn btn-outline-success"
round
type="button"
@click="onAction('basedireditor')"
>
Editor</button>
</div>
</div>
</div> <!-- col -->
<div class="col-1">
</div> <!-- col -->
<div class="col-5">
<div class="input-group input-group-sm sm-3">
@ -285,6 +301,7 @@ import card from '@/components/Card.vue'
import {ApiConfig} from "@/config/index";
import {ApiConfigGUI} from "@/config/index-gui";
import {ApiConfigWEB} from "@/config/index-web";
import {ApiConfigEDIT} from "@/config/index-editor";
import { extend } from 'vee-validate';
import { required, alpha_num } from 'vee-validate/dist/rules';
@ -312,6 +329,7 @@ export default {
localNetworkdefault:'',
webinterface: false,
webinterfacegeneric: false,
webinterfacegenericedit: false,
webinterface_port: '',
STATUS:{},
CONFIG:{
@ -354,6 +372,7 @@ export default {
this.$root.$on('hybrid_show_info', (data) => {
this.webinterface = false
this.webinterfacegeneric = false
this.webinterfacegenericedit = false
this.$nextTick(function () {
this.hybridshowdata = data
@ -368,6 +387,14 @@ export default {
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 urlgeniGUI = this.hybridshowdata.Names.split('_');
// GUI firefox
for(var i = 0; i < ApiConfigGUI.length; i++) {
@ -596,6 +623,13 @@ export default {
//console.log('start ' + JSON.stringify(log))
//console.log('startobj ' + JSON.stringify(obj))
////console.log(this.$socket.client.connect())
}else if(action == 'basedireditor'){
var log = await store.dispatch("pipelineLLO/runeditor",{
instance:this.hybridshowdata.Names
})
console.log('start editor ' + JSON.stringify(this.hybridshowdata.Names))
}else if(action == 'basebackupview'){
var info=`<h5><b>Backups</b><br>
<br>

11
src/config/index-editor.js

@ -0,0 +1,11 @@
export const ApiConfigEDIT = [
{
"name": "microservice-xelatexthesis",
"automated": true,
"url": 'http',
"version": 0,
"port": 0
}
];

31
src/store/modules/create_pipelineLLO.js

@ -367,6 +367,37 @@ export default {
return R;
}
}
},
async runeditor({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+'/runeditor'
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 runbackup({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value))

Loading…
Cancel
Save