Browse Source

add custom

master
zeus 2 years ago
parent
commit
151d040bab
  1. 2
      dist/index.html
  2. 2
      dist/js/app.36e297d4.js
  3. 1
      dist/js/app.36e297d4.js.map
  4. 2
      dist/js/app.c9fb74d9.js
  5. 1
      dist/js/app.c9fb74d9.js.map
  6. 65
      src-local/llo/new.js
  7. 42
      src-local/swarmlab_backup_src_instanche.sh
  8. 58
      src/components/mynetwork/availablemicroservices.vue
  9. 27
      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.36e297d4.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.36e297d4.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.c9fb74d9.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.c9fb74d9.js"></script></body></html>

2
dist/js/app.36e297d4.js

File diff suppressed because one or more lines are too long

1
dist/js/app.36e297d4.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.c9fb74d9.js

File diff suppressed because one or more lines are too long

1
dist/js/app.c9fb74d9.js.map

File diff suppressed because one or more lines are too long

65
src-local/llo/new.js

@ -2016,6 +2016,71 @@ try {
}); });
app.get('/runbackupinstance', (req, res, next) => {
var RES = new Object();
var mypath = process.cwd()
RES.instance = req.query["instance"]
RES.error = false
RES.error_msg = "ok"
RES.error_msg0 = ""
RES.data = "All_services_are_running";
var showexec = `./swarmlab_backup_src_instanche.sh ${RES.instance}`
console.log('exec tarinstance :', showexec);
var runpath = `${mypath}`
var buildoutdir = `${runpath}/logs/tar-backup-out.log`
var builderrdir = `${runpath}/logs/tar-backup-out.log`
try {
const buildout = fs.openSync(buildoutdir, 'a');
const builderr = fs.openSync(builderrdir, 'a');
console.log('buildout :', buildout);
var buildimage = `echo "EXEC PID: $$"; ${showexec}`
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 = 'Your backup might take a long time, depending on the number of files to back up. '
io.emit('message_out', n);
run_buildimage.on('exit', (data) => {
var n = {}
n.data = 'exit!'
io.emit('message_close', n);
});
run_buildimage.on('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);
});
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('/getbuildstatus', (req, res, next) => { app.get('/getbuildstatus', (req, res, next) => {
var RES = new Object(); var RES = new Object();
RES.instance = req.query["instance"] RES.instance = req.query["instance"]

42
src-local/swarmlab_backup_src_instanche.sh

@ -0,0 +1,42 @@
#!/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)
instanche4backup="instance/${service}"
date=$(date '+%Y-%m-%d-%H-%M')
docker run --rm -v $SFPATH/mybackups:/backup -v $SFPATH/$instanche4backup:/instance alpine /bin/sh -c "mkdir -p /backup/${service}; tar -zcvf /backup/${service}/${service}.${date}.tar.gz /instance;"

58
src/components/mynetwork/availablemicroservices.vue

@ -94,12 +94,36 @@
--> -->
<button class="btn btn-outline-info" <button class="btn btn-outline-info"
v-if="viewhybridoptions && customedit " v-if="viewhybridoptions"
round
type="button"
@click="backup"
>
Backup</button>
<button class="btn btn-outline-dark"
v-if="viewhybridoptions"
round
type="button"
@click="backupview"
>
BackupView</button>
<button class="btn btn-outline-primary"
v-if="viewhybridoptions && customedit && custommenouopen != true"
round round
type="button" type="button"
@click="setcustom" @click="setcustom"
> >
Custom</button> Custom</button>
<button class="btn btn-outline-secondary"
v-if="viewhybridoptions && customedit && custommenouopen === true"
round
disabled
type="button"
@click="setcustom"
>
Custom:</button>
<button class="btn btn-outline-warning" <button class="btn btn-outline-warning"
v-if="viewhybridoptions && customedit && custommenouopen" v-if="viewhybridoptions && customedit && custommenouopen"
round round
@ -107,7 +131,7 @@
@click="setcustomcancel" @click="setcustomcancel"
> >
Cancel</button> Cancel</button>
<button class="btn btn-outline-primary" <button class="btn btn-outline-info"
v-if="viewhybridoptions && customedit && custommenouopen" v-if="viewhybridoptions && customedit && custommenouopen"
round round
type="button" type="button"
@ -912,6 +936,36 @@ export default {
//console.log('chownlog '+ JSON.stringify(log)) //console.log('chownlog '+ JSON.stringify(log))
//console.log('chown extrapackages '+ JSON.stringify(this.custom.os)) //console.log('chown extrapackages '+ JSON.stringify(this.custom.os))
//console.log('chown sh '+ JSON.stringify(this.custom.sh)) //console.log('chown sh '+ JSON.stringify(this.custom.sh))
},
async backup(){
var log = await store.dispatch("pipelineLLO/runbackupinstance",{
token:this.token,
instance: this.hybridoptions.swarmlabname
})
},
async backupview(){
var info=`<h5><b>Backups</b><br>
<br>
`
info +='<p class="text-secondary">'
info +=' <b>Click on hyperlink opens Directory in new tab</b></p>'
info +='<b> <a class="text-info" href="http://127.0.0.1:3383/" target="_blank">View Backups</a></b>'
info +='<br>'
this.$swal({
type: 'Info',
title: 'Info!',
icon:'info',
html: info,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Ok!'
})
}, },
async setHybridoptions(){ async setHybridoptions(){
this.resetcustom() this.resetcustom()

27
src/store/modules/create_pipelineLLO.js

@ -555,6 +555,33 @@ export default {
return R; return R;
} }
} }
},
async runbackupinstance({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+'/runbackupinstance'
var p = await axios.get(sock_server_l,options);
return p
} 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 hybrid_rmimage({commit,rootGetters}, value) { async hybrid_rmimage({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value)) //console.log('value '+JSON.stringify(value))

Loading…
Cancel
Save