Browse Source

add custom

master
zeus 2 weeks ago
parent
commit
812588e67d
  1. 2
      .gitignore
  2. 1
      run.yml
  3. 0
      src-local/community/README
  4. 0
      src-local/community/config/README
  5. 17
      src-local/community/config/rootapostolos-mytest1.js
  6. 56
      src-local/community/custom/create-docker-compose.sh
  7. 0
      src-local/community/custom/custom.sh
  8. 0
      src-local/community/custom/extrapackages
  9. 31
      src-local/community/custom/setup.sh
  10. 0
      src-local/community/custom/user.env
  11. 1
      src-local/community/rootapostolos@swarmlab.io_mytest1_microservice-ipterm
  12. 704
      src-local/llo/new.js
  13. 27
      src/App.vue
  14. 26
      src/components/mybuild.vue
  15. 69
      src/components/mymicroservicescustom.vue
  16. 1336
      src/components/mynetwork/\
  17. 1181
      src/components/mynetwork/availablemicroservicescustom.vue
  18. 472
      src/components/mynetwork/buildermyservices.vue
  19. 562
      src/components/mynetwork/builderservices-backup.vue
  20. 402
      src/components/mynetwork/builderservices.vue
  21. 821
      src/components/mynetwork/customservices.vue
  22. 308
      src/components/mynetwork/mytable.vue
  23. 63
      src/config/index-editor.js
  24. 205
      src/config/index-web.js
  25. 244
      src/store/modules/create_pipelineLLO.js

2
.gitignore

@ -18,6 +18,8 @@ viwsession/
testfilemanager/
README-update
src-local/community/rootapostolos@swarmlab.io_mytest1_microservice-ipterm
swarmlabdoc.js
swarmlabdoc.asciidoc_config
package-lock.json

1
run.yml

@ -119,6 +119,7 @@ services:
volumes:
- /lib/modules:/lib/modules
- ${nodepath}/src-local/instance:/instance
- ${nodepath}/src-local/community:/community
networks:
hybrid-net:

0
src-local/community/README

0
src-local/community/config/README

17
src-local/community/config/rootapostolos-mytest1.js

@ -0,0 +1,17 @@
{
"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"}
}

56
src-local/community/custom/create-docker-compose.sh

@ -0,0 +1,56 @@
#!/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
#echo $cwdir
#echo $wdir
cd $wdir
. ./user.env
sed -i '/${U_PORT5}:${S_PORT5}/d' ../docker-compose.yml
sed -i '/${U_PORT4}:${S_PORT4}/d' ../docker-compose.yml
sed -i '/${U_PORT3}:${S_PORT3}/d' ../docker-compose.yml
sed -i '/${U_PORT2}:${S_PORT2}/d' ../docker-compose.yml
sed -i '/${U_PORT1}:${S_PORT1}/d' ../docker-compose.yml
if [ ! -z "$S_PORT5" ]; then
sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT5}:${S_PORT5}"' ../docker-compose.yml
fi
if [ ! -z "$S_PORT4" ]; then
sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT4}:${S_PORT4}"' ../docker-compose.yml
fi
if [ ! -z "$S_PORT3" ]; then
sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT3}:${S_PORT3}"' ../docker-compose.yml
fi
if [ ! -z "$S_PORT2" ]; then
sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT2}:${S_PORT2}"' ../docker-compose.yml
fi
if [ ! -z "$S_PORT1" ]; then
sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT1}:${S_PORT1}"' ../docker-compose.yml
fi
cd $cwdir

0
src-local/community/custom/custom.sh

0
src-local/community/custom/extrapackages

31
src-local/community/custom/setup.sh

@ -0,0 +1,31 @@
#!/bin/sh
mkdir -p /tmp/logs
echo "==> extra packages"
extrap=/tmp/bin/extrapackages
if [ -f $extrap ]; then
sh $extrap 2>&1 | tee /tmp/logs/extrapackages.log
fi
echo "==> exec custom"
extrashell=/tmp/bin/custom.sh
if [ -f $extrashell ]; then
sh $extrashell 2>&1 | tee /tmp/logs/custom1.log
fi
echo "==> extra add"
extrap1=/tmp/bin/extrapackages1
if [ -f $extrap1 ]; then
sh $extrap1 2>&1 | tee /tmp/logs/extrapackages1.log
fi
echo "==> exec sh 2"
extrashell1=/tmp/bin/custom1.sh
if [ -f $extrashell1 ]; then
sh $extrashell1 2>&1 | tee /tmp/logs/custom2.log
fi

0
src-local/community/custom/user.env

1
src-local/community/rootapostolos@swarmlab.io_mytest1_microservice-ipterm

@ -0,0 +1 @@
Subproject commit 73dd22c502c6de2b258627b883ece5806a82053f

704
src-local/llo/new.js

@ -1044,6 +1044,23 @@ fs.readdir(servicepath, { withFileTypes: true }, (error, files) => {
res.json(RES)
});
});
app.get('/getservicesinfoallcustom', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]
var servicepath = './community/'
fs.readdir(servicepath, { withFileTypes: true }, (error, files) => {
const directoriesInDIrectory = files
.filter((item) => item.isDirectory())
.map((item) => item.name);
//console.log(directoriesInDIrectory);
RES.error = false
RES.error_msg = "ok"
RES.data = directoriesInDIrectory;
res.json(RES)
});
});
@ -1509,6 +1526,66 @@ app.get('/stopservice', (req, res, next) => {
});
});
app.get('/stopservicecustom', (req, res, next) => {
var RES = new Object();
var obj = JSON.parse(req.query["instance"])
RES.service = obj.service
RES.baseservice = obj.baseservice
RES.user = obj.user
//var baseservicedata = JSON.stringify(value.baseservicedata)
//var customservice = value.service
var baseservicetmp1 = RES.user.split('@')
var baseservice = `${baseservicetmp1[0]}-${RES.service}`
var myservice = `${RES.user}_${RES.service}_${RES.baseservice}/${baseservice}`
console.log(myservice)
//var myservicefiles = `./community/${value.user}_${value.service}_${value.baseservice}/${baseservice}`
//var myservicecustom = `./community/${value.user}_${value.service}_${value.baseservice}`
var services_path = './community/'+myservice
var services_pathexec = process.cwd()
var stopeditexec = `/bin/bash ./stop-sidecar-edit-service.sh ${baseservice}`
const stopedit = spawn(stopeditexec, {
stdio: 'pipe',
shell: true,
cwd: services_pathexec
});
stopedit.on('close', function (code) {
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', n);
});
stop.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
});
stop.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
RES.error = false
RES.error_msg = "ok"
RES.data = 'ok';
res.json(RES)
});
});
});
app.get('/rmbuildstatus', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]
@ -1824,6 +1901,60 @@ app.get('/chown', (req, res, next) => {
}
});
app.get('/chowncustom', (req, res, next) => {
var RES = new Object();
var mypath1 = process.cwd()
var runuser = process.env.USER || ""
RES.user = req.query["user"]
RES.swarmlabname = req.query["baseservice"]
RES.service = req.query["service"]
var myservicedir = `${RES.user}_${RES.service}_${RES.swarmlabname}`
RES.error = false
RES.error_msg = "ok"
var showexec = `docker exec swarmlabadmin /bin/bash -c "chown -R ${runuser}:${runuser} /community/${myservicedir}"`
//var showexec = `docker exec swarmlabadmin /bin/bash -c "chown -R root:root /instance/${RES.instance}/${RES.instance}"`
//console.log(showexec)
try {
log = spawn(showexec, {
shell: true,
//cwd: services_path,
detached: false,
stdio: 'pipe'
});
log.stdout.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_out', n);
});
log.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
});
log.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
n.start = `${RES.instance}`
RES.error = false
RES.error_msg = 'ok'
RES.data = n.data
res.json(RES)
});
} catch (error) {
console.log('Error:', error);
RES.error = true
RES.error_msg = error
RES.data = 'no'
res.json(RES)
}
});
app.get('/checkowner', (req, res, next) => {
var RES = new Object();
var mypath1 = process.cwd()
@ -1879,6 +2010,63 @@ app.get('/checkowner', (req, res, next) => {
}
});
app.get('/checkownercustom', (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 = `./community/${RES.instance}/${RES.instance}`
if (fs.existsSync(instancedir)) {
var showexec = `docker exec swarmlabadmin /bin/bash -c "chown -R ${runuser}:${runuser} /instance/${RES.instance}/${RES.instance}"`
try {
log = spawn(showexec, {
shell: true,
//cwd: services_path,
detached: false,
stdio: 'pipe'
});
log.stdout.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_out', n);
});
log.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
});
log.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
n.start = `${RES.instance}`
RES.error = false
RES.error_msg = 'ok'
RES.data = n.data
res.json(RES)
});
} catch (error) {
console.log('Error:', error);
RES.error = true
RES.error_msg = error
RES.data = 'no'
res.json(RES)
}
}else{
RES.error = false
RES.error_msg = 'nodir'
RES.data = 'no'
res.json(RES)
}
});
app.get('/getcustom', (req, res, next) => {
var RES = new Object();
var mypath1 = process.cwd()
@ -1959,7 +2147,7 @@ app.get('/runbackup', (req, res, next) => {
RES.error_msg0 = ""
RES.data = "All_services_are_running";
var showexec = `./swarmlab_backup_service.sh ${RES.instance}`
console.log('exec tar :', showexec);
//console.log('exec tar :', showexec);
var runpath = `${mypath}`
var runpathfile = `${mypath}/swarmlab_backup_service.sh`
@ -1968,7 +2156,7 @@ app.get('/runbackup', (req, res, next) => {
try {
const buildout = fs.openSync(buildoutdir, 'a');
const builderr = fs.openSync(builderrdir, 'a');
console.log('buildout :', buildout);
//console.log('buildout :', buildout);
var buildimage = `echo "EXEC PID: $$"; ${showexec}`
@ -2025,7 +2213,7 @@ app.get('/runbackupinstance', (req, res, next) => {
RES.error_msg0 = ""
RES.data = "All_services_are_running";
var showexec = `./swarmlab_backup_src_instanche.sh ${RES.instance}`
console.log('exec tarinstance :', showexec);
//console.log('exec tarinstance :', showexec);
var runpath = `${mypath}`
var buildoutdir = `${runpath}/logs/tar-backup-out.log`
@ -2033,7 +2221,7 @@ app.get('/runbackupinstance', (req, res, next) => {
try {
const buildout = fs.openSync(buildoutdir, 'a');
const builderr = fs.openSync(builderrdir, 'a');
console.log('buildout :', buildout);
//console.log('buildout :', buildout);
var buildimage = `echo "EXEC PID: $$"; ${showexec}`
@ -2109,7 +2297,7 @@ app.get('/getstoragestatus', (req, res, next) => {
RES.error = false
RES.error_msg = "ok"
RES.data = "no instance file found";
console.log(JSON.stringify(err))
//console.log(JSON.stringify(err))
res.json(RES)
}else{
data = data.trim();
@ -2266,7 +2454,7 @@ app.get('/getshareinfo', (req, res, next) => {
var RES = new Object();
var container = req.query["instance"]
console.log(container)
//console.log(container)
var showexec = `docker inspect ${container} --format '{"network":"{{ .HostConfig.NetworkMode }}","container":"{{ .Id }}"}' | jq . -s`
exec(showexec, (err, stdout, stderr) => {
if (err) {
@ -2295,7 +2483,7 @@ app.get('/getshareinfo', (req, res, next) => {
}
}
}
console.log(datajson1)
//console.log(datajson1)
RES.error = false
RES.error_msg = "ok"
RES.container = datajson;
@ -2619,6 +2807,32 @@ app.get('/get_config', (req, res, next) => {
*/
});
app.get('/getinstallcustom', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]
//console.log(RES.instance)
var runpath = `./community/config`
var runpathfile = `./community/config/${RES.instance}.js`
var found = ''
if (fs.existsSync(runpathfile)) {
found = 'yes'
RES.error = false
RES.error_msg = "ok"
RES.test = found;
RES.data = fs.readFileSync(runpathfile, 'utf8')
res.json(RES)
}else{
found = 'no'
RES.error = false
RES.error_msg = "no"
RES.test = found;
RES.data = false;
res.json(RES)
}
});
app.get('/create_config', (req, res, next) => {
var RES = new Object();
@ -2816,10 +3030,47 @@ function create_project(swarmlabname,project){
});
}
function create_project_custom(swarmlabname,project){
var services_path = './community/'+swarmlabname+'/'+project
fs.mkdir(services_path, { recursive: true }, (err) => {
var service_up = '/bin/bash ../install/usr/share/swarmlab.io/sec/swarmlab-sec create'
create = spawn(service_up, {
shell: true,
cwd: services_path,
//detached: true,
detached: false,
//stdio: [ 'ignore', logout, logerr ]
stdio: 'pipe'
});
create.stdout.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_out', n);
});
create.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err', n);
});
create.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
});
});
}
function docker_image_rm(swarmlabname,project){
var services_path = swarmlabname
var service_rm = 'docker rmi $(docker images --format "{{.Repository}}#{{ .ID }}" | grep "/'+project+'#" | cut -d"#" -f2)'
console.log('docker rmi '+service_rm)
//console.log('docker rmi '+service_rm)
remove = spawn(service_rm, {
shell: true,
cwd: services_path,
@ -3000,6 +3251,325 @@ TEST=${service}
}
});
socket.on('startcustom', (value) => {
//console.log(value)
//console.log('value '+JSON.stringify(value))
if(value.service){
try {
const reg = new RegExp('^[0-9]+$');
const reg1 = new RegExp('^[0-9/tcpud]+$');
if (!value.port1){
value.port1=''
}else{
if(reg.test(value.port1)){
value.port1 = value.port1.replace(/\s+/g, '')
}else if(reg1.test(value.port1)){
value.port1 = value.port1.replace(/\s+/g, '')
}else{
value.port1 = ''
}
}
if (!value.port2){
value.port2=''
}else{
if(reg.test(value.port2)){
value.port2 = value.port2.replace(/\s+/g, '')
}else if(reg1.test(value.port2)){
value.port2 = value.port2.replace(/\s+/g, '')
}else{
value.port2 = ''
}
}
if (!value.port3){
value.port3=''
}else{
if(reg.test(value.port3)){
value.port3 = value.port3.replace(/\s+/g, '')
}else if(reg1.test(value.port3)){
value.port3 = value.port3.replace(/\s+/g, '')
}else{
value.port3 = ''
}
}
if (!value.port4){
value.port4=''
}else{
if(reg.test(value.port4)){
value.port4 = value.port4.replace(/\s+/g, '')
}else if(reg1.test(value.port4)){
value.port4 = value.port4.replace(/\s+/g, '')
}else{
value.port4 = ''
}
}
if (!value.port5){
value.port5=''
}else{
if(reg.test(value.port5)){
value.port5 = value.port5.replace(/\s+/g, '')
}else if(reg1.test(value.port5)){
value.port5 = value.port5.replace(/\s+/g, '')
}else{
value.port5 = ''
}
}
var baseservicedata = JSON.stringify(value.baseservicedata)
var customservice = value.service
var baseservicetmp1 = value.user.split('@')
var baseservice = `${baseservicetmp1[0]}-${value.service}`
var myservice = `${value.user}_${value.service}_${value.baseservice}/${baseservice}`
var myservicefiles = `./community/${value.user}_${value.service}_${value.baseservice}/${baseservice}`
var myservicecustom = `./community/${value.user}_${value.service}_${value.baseservice}`
//var services_path = './community/'+service+'/'+service
var services_path = './community/'+myservice
var ENV_service_file_path_sh_dir = `${myservicecustom}/install/usr/share/swarmlab.io/sec/custom`
var ENV_service_file_path_sh = `${myservicecustom}/install/usr/share/swarmlab.io/sec/custom/custom.sh`
var ENV_service_file_sh = `${value.sh}`
var ENV_service_file_path_os = `${myservicecustom}/install/usr/share/swarmlab.io/sec/custom/extrapackages`
var ENV_service_file_os = `${value.packages}`
// -----------------------------------------------------------
var ENV_service_file_path_sh_dir1 = `${myservicefiles}/custom`
var ENV_service_file_path_sh1 = `${myservicefiles}/custom/custom.sh`
var ENV_service_file_path_os1 = `${myservicefiles}/custom/extrapackages`
var ENV_service_file_path_rc1 = `${myservicefiles}/custom/rclocal`
var ENV_service_file_rc = `${value.rclocal}`
var ENV_service_file_path_config1 = `${myservicecustom}/install/usr/share/swarmlab.io/sec/custom/index-setup.js`
var ENV_service_file_path_config_community = `./community/config/${baseservice}.js`
var ENV_service_file_path_config = `${myservicefiles}/custom/index-setup.js`
var ENV_service_file_config = `
export const ApiConfigWEBuser = [
{
"service": "${customservice}",
"baseservice": "${value.baseservice}",
"user": "${value.user}",
"port1": "${value.port1}",
"url1": "${value.url1}",
"name1": "${value.name1}",
"port2": "${value.port2}",
"url2": "${value.url2}",
"name2": "${value.name2}",
"port3": "${value.port3}",
"url3": "${value.url3}",
"name3": "${value.name3}",
"baseservicedata": ${baseservicedata}
}
]
`
var ENV_service_file_config_community = `{
"servicedata": {
"service": "${customservice}",
"baseservice": "${value.baseservice}",
"user": "${value.user}",
"port1": "${value.port1}",
"url1": "${value.url1}",
"name1": "${value.name1}",
"port2": "${value.port2}",
"url2": "${value.url2}",
"name2": "${value.name2}",
"port3": "${value.port3}",
"url3": "${value.url3}",
"name3": "${value.name3}"
},
"baseservicedata": ${baseservicedata}
}`
var execadddirport = `${myservicefiles}/custom/create-docker-compose.sh`
var ENV_service_file_path_config_bash = `${myservicefiles}/custom/user.env`
var ENV_service_file_config_bash = `S_PORT1=${value.port1}
S_PORT2=${value.port2}
S_PORT3=${value.port3}
S_PORT4=${value.port4}
S_PORT5=${value.port5}
`
var ENV_service_file_path = services_path+'/.env'
var service_port = ''
if(value.swarmlabname_size){
var service_size = value.swarmlabname_size
}else{
var service_size = 3
}
const apptest = require('express')();
const servertest = apptest.listen(0, () => {
var newport = servertest.address().port
servertest.close();
if(value.swarmlabname_port){
service_port = value.swarmlabname_port
}else{
service_port = newport
}
var newport1 = ''
const servertest1 = apptest.listen(0, () => {
servertest1.close();
})
newport1 = servertest1.address().port
var newport2 = ''
const servertest2 = apptest.listen(0, () => {
servertest2.close();
})
newport2 = servertest2.address().port
var newport3 = ''
const servertest3 = apptest.listen(0, () => {
servertest3.close();
})
newport3 = servertest3.address().port
var newport4 = ''
const servertest4 = apptest.listen(0, () => {
servertest4.close();
})
newport4 = servertest4.address().port
var newport5 = ''
const servertest5 = apptest.listen(0, () => {
servertest5.close();
})
newport5 = servertest5.address().port
var newport21 = ''
const servertest21 = apptest.listen(0, () => {
servertest21.close();
})
newport21 = servertest21.address().port
var newport22 = ''
const servertest22 = apptest.listen(0, () => {
servertest22.close();
})
newport22 = servertest22.address().port
var newport23 = ''
const servertest23 = apptest.listen(0, () => {
servertest23.close();
})
newport23 = servertest23.address().port
var newport24 = ''
const servertest24 = apptest.listen(0, () => {
servertest24.close();
})
newport24 = servertest24.address().port
var newport25 = ''
const servertest25 = apptest.listen(0, () => {
servertest25.close();
})
newport25 = servertest25.address().port
var ENV_service_file = `
REGISTRY_ADDR=localhost
REGISTRY_PORT=5000
IMAGE_NAME=${value.baseservice}
SSH_PORT=${service_port}
R_PORT1=${newport1}
R_PORT2=${newport2}
R_PORT3=${newport3}
R_PORT4=${newport4}
R_PORT5=${newport5}
U_PORT1=${newport21}
U_PORT2=${newport22}
U_PORT3=${newport23}
U_PORT4=${newport24}
U_PORT5=${newport25}
S_PORT1=${value.port1}
S_PORT2=${value.port2}
S_PORT3=${value.port3}
S_PORT4=${value.port4}
S_PORT5=${value.port5}
TEST=${value.baseservice}
`
//console.log('value1 '+JSON.stringify(ENV_service_file_path))
//console.log('value2 '+JSON.stringify(ENV_service_file))
fs.writeFileSync(ENV_service_file_path, ENV_service_file ,{encoding:'utf8',flag:'w'});
if (fs.existsSync(ENV_service_file_path_sh_dir)) {
fs.writeFileSync(ENV_service_file_path_sh, ENV_service_file_sh ,{encoding:'utf8',flag:'w'});
fs.writeFileSync(ENV_service_file_path_os, ENV_service_file_os ,{encoding:'utf8',flag:'w'});
fs.writeFileSync(ENV_service_file_path_config1, ENV_service_file_config ,{encoding:'utf8',flag:'w'});
}
var execadddir = `./community/custom`
var execadd = `cp -rf ${execadddir} ${services_path}`
execSync(execadd);
fs.writeFileSync(ENV_service_file_path_config_community, ENV_service_file_config_community ,{encoding:'utf8',flag:'w'});
if (fs.existsSync(ENV_service_file_path_sh_dir1)) {
fs.writeFileSync(ENV_service_file_path_sh1, ENV_service_file_sh ,{encoding:'utf8',flag:'w'});
fs.writeFileSync(ENV_service_file_path_os1, ENV_service_file_os ,{encoding:'utf8',flag:'w'});
fs.writeFileSync(ENV_service_file_path_rc1, ENV_service_file_rc ,{encoding:'utf8',flag:'w'});
fs.writeFileSync(ENV_service_file_path_config, ENV_service_file_config ,{encoding:'utf8',flag:'w'});
fs.writeFileSync(ENV_service_file_path_config_bash, ENV_service_file_config_bash ,{encoding:'utf8',flag:'w'});
var execaddport = `bash ${execadddirport}`
execSync(execaddport);
//console.log('value1 file '+JSON.stringify(ENV_service_file_path_os1))
//console.log('value1 config '+JSON.stringify(ENV_service_file_path_config))
}
//console.log('value1 '+JSON.stringify(ENV_service_file_sh))
//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
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()
n.cwdpath = process.cwd()
n.service = value.baseservice
n.customservice = customservice
io.emit('message_out', n);
});
child[0].stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
n.cwdpath = process.cwd()
n.service = value.baseservice
n.customservice = customservice
io.emit('message_err', n);
});
child[0].on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close', n);
});
});
} catch (error) {
console.log('Error:', error);
}
}else{
var n = {}
n.data = 'NoSwarmlabname'
io.emit('message_err', n);
}
});
socket.on('start_storage', (value) => {
if(value.swarmlabname){
try {
@ -3305,6 +3875,104 @@ SSH_PORT=
});
socket.on('installcustom', (value) => {
//console.log(value)
if(value.swarmlabname){
try {
//console.log('install')
//var service = value.swarmlabname
var baseservicetmp1 = value.user.split('@')
var service = `${baseservicetmp1[0]}-${value.service}`
var myservice = `${value.user}_${value.service}_${value.swarmlabname}`
var service_git = value.git
var services_path = './community/'+myservice
var ENV_service_dir = services_path+'/'+service
var ENV_service_file_path = services_path+'/'+service+'/.env'
var ENV_service_file_path_div = services_path+'/'+service
var nn = {}
nn.data = 'Wait for service(s) to be available before executing a command'
io.emit('message_out', 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', n);
n.data = '...'
io.emit('message_close', n);
create_project_custom(myservice,service)
}).catch((err) => {
var n = {}
n.data = err.toString()
io.emit('message_err', n);
console.log('error ' + JSON.stringify(err))
});
} catch (e) {
var n = {}
n.data = e.toString()
io.emit('message_err', n);
}
}else{
fs.mkdir(services_path, { recursive: true }, (err) => {
if (err){
console.log('error ' + JSON.stringify(err))
}else{
var ENV_service_file = `
REGISTRY_ADDR=localhost
REGISTRY_PORT=5000
IMAGE_NAME=${value.swarmlabname}
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', n);
n.data = '...'
io.emit('message_out', n);
create_project_custom(myservice,service)
if (fs.existsSync(ENV_service_file_path_div)) {
fs.writeFileSync(ENV_service_file_path, ENV_service_file);
}
}).catch((err) => {
var n = {}
n.data = err.toString()
io.emit('message_err', n);
console.log('error ' + JSON.stringify(err))
});
} catch (e) {
var n = {}
n.data = e.toString()
io.emit('message_err', n);
}
}
});
}
} catch (error) {
console.log('Error:', error);
}
}else{
var n = {}
n.data = 'no services'
io.emit('message_err', n);
}
});
socket.on('installstorage', (value) => {
if(value.swarmlabname){
try {
@ -3430,8 +4098,8 @@ SSH_PORT=
// ----------------- build buildimage build_image command
// ------------------------------------
socket.on('build_image', (option) => {
console.log("run_buildimage")
console.log(JSON.stringify(option))
//console.log("run_buildimage")
//console.log(JSON.stringify(option))
var mypath = process.cwd()
var buildoutdir = `${mypath}/logs/build-out.log`
var builderrdir = `${mypath}/logs/build-out.log`
@ -3471,7 +4139,7 @@ try {
io.emit('message_out', n);
run_buildimage.on('exit', (data) => {
console.log('exit '+data);
//console.log('exit '+data);
//set pid on server for later use e.g. kill
//var n = {}
//n.pid = line.substr(10).trim()
@ -3482,7 +4150,7 @@ try {
io.emit('message_close', n);
});
run_buildimage.on('close', (data) => {
console.log('close '+data);
//console.log('close '+data);
//set pid on server for later use e.g. kill
//var n = {}
//n.pid = line.substr(10).trim()
@ -3565,26 +4233,26 @@ try {
// ----------------- ssh connect and run command
// ------------------------------------
socket.on('build_vmlist', (option) => {
console.log("list")
//console.log("list")
var mypath = process.cwd()
sshconnect.on('connect', function() {
console.log('Connection :: connect');
});
sshconnect.on('ready', function() {
console.log('Connection :: ready');
//console.log('Connection :: ready');
sshconnect.exec('echo "EXEC PID: $$";/mytools/test-ping.sh', (err, stream) => {
if (err) throw err;
stream.on('close', (code, signal) => {
console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
//console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
var n = {}
n.data = 'close'
io.emit('message_close', n);
sshconnect.end();
}).on('data', (data) => {
var line = '' + data; // unbeautiful ;)
console.log(line);
//console.log(line);
if(line.substr(0, 10) === 'EXEC PID: ') {
console.log('PID1: ' + line.substr(10));
//console.log('PID1: ' + line.substr(10));
var sshpid1 = line.substr(10).trim();
//set pid on server for later use e.g. kill
global.SSHPID[sshpid1] = sshconnect
@ -3593,7 +4261,7 @@ try {
//set pid on client for later use e.g. kill
io.emit('build_set_sshpid', n);
}
console.log('STDOUT: ' + data);
//console.log('STDOUT: ' + data);
var n = {}
n.data = data.toString('utf8')
io.emit('message_out', n);

27
src/App.vue

@ -269,15 +269,16 @@
<b-list-group-item variant="light" name="Storage" class="ti-server m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_storage')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_storage') }" @click="hybrid('storage')"> Storage</b-list-group-item>
<b-list-group-item variant="light" name="Microservice" class="ti-cloud m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_microservice')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_microservice') }" @click="hybrid('microservice')"> MicroServices</b-list-group-item>
<b-list-group-item variant="light" name="Proof_of_concept" class=" ti-light-bulb m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_proofofconcept')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_proofofconcept') }" @click="hybrid('proofofconcept')"> Proof_of_concept</b-list-group-item>
<b-list-group-item variant="light" name="communityMicroservice" class="ti-user m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_mymicroservice')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_mymicroservice') }" @click="hybrid('mymicroservice')"> Users images</b-list-group-item>
</b-collapse>
<!-- Menou builders -->
<b-list-group-item v-b-toggle.hybrid-builders variant="light" name="Private" class="ti-settings list-group-item list-group-item-action" v-on:click="setActive('builders','')" style="cursor: pointer;" :class="{ active: isActive('builders') }" @click="hybrid('builders')" > Builders</b-list-group-item>
<b-list-group-item v-b-toggle.hybrid-builders variant="light" name="Private" class="ti-settings list-group-item list-group-item-action" v-on:click="setActive('builders','')" style="cursor: pointer;" :class="{ active: isActive('builders') }" @click="hybrid('builders')" > Build</b-list-group-item>
<b-collapse id="hybrid-builders" class="m-subm" accordion="m-sidebar" role="tabpanel">
<b-list-group-item variant="light" name="build_vmware" class=" ti-folder m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('builders','hybrid_builders')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_builders') }" @click="hybrid('builders')"> VM</b-list-group-item>
<b-list-group-item variant="light" name="build_vmware" class=" ti-folder m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('builders','hybrid_builders')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_builders') }" @click="hybrid('builders')"> myServices</b-list-group-item>
<!--
<b-list-group-item variant="light" name="build_docker" class="ti-harddrive m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('builders','hybrid_docker')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_docker') }" @click="hybrid('build_docker')"> Docker</b-list-group-item>
-->
@ -356,15 +357,16 @@
<b-list-group-item variant="light" name="Storage" class="ti-server m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_storage')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_storage') }" @click="hybrid('storage')" title="Storage"> </b-list-group-item>
<b-list-group-item variant="light" name="Microservice" class="ti-cloud m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_microservice')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_microservice') }" @click="hybrid('microservice')" title="Microservices"> </b-list-group-item>
<b-list-group-item variant="light" name="Proof_of_concept" class="ti-light-bulb m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_proofofconcept')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_proofofconcept') }" @click="hybrid('proofofconcept')" title="Proof_of_concept"> </b-list-group-item>
<b-list-group-item variant="light" name="communityMicroservice" class="ti-user m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_mymicroservice')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_mymicroservice') }" @click="hybrid('mymicroservice')" title="Microservices"> </b-list-group-item>
</b-collapse>
<!-- Menou builders -->
<b-list-group-item v-b-toggle.hybrid-builders variant="light" name="Private" class="ti-settings list-group-item list-group-item-action" v-on:click="setActive('builders','')" style="cursor: pointer;" :class="{ active: isActive('builders') }" @click="hybrid('builders')" title="Builders" > </b-list-group-item>
<b-list-group-item v-b-toggle.hybrid-builders variant="light" name="Private" class="ti-settings list-group-item list-group-item-action" v-on:click="setActive('builders','')" style="cursor: pointer;" :class="{ active: isActive('builders') }" @click="hybrid('builders')" title="Build" > </b-list-group-item>
<b-collapse id="hybrid-builders1" class="m-subm" accordion="m-sidebar" role="tabpanel">
<b-list-group-item variant="light" name="build_vmware" class=" ti-folder m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('builders','hybrid_builders')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_builders') }" @click="hybrid('builders')" title="Build VM"> </b-list-group-item>
<b-list-group-item variant="light" name="build_vmware" class=" ti-folder m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('builders','hybrid_builders')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_builders') }" @click="hybrid('builders')" title="Build Service"> </b-list-group-item>
<!--
<b-list-group-item variant="light" name="build_docker" class="ti-harddrive m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('builders','hybrid_docker')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_docker') }" @click="hybrid('build_docker')" title="Build Docker"> </b-list-group-item>
-->
@ -500,6 +502,19 @@
<!-- ------ hybrid manage microservices --------------- -->
<!-- ----------------------------------- -->
<!-- ----------------------------------- -->
<!-- ------ hybrid manage mymicroservices --------------- -->
<!-- ----------------------------------- -->
<manage-mymicroservices
:key="mycomponentKeyreload3"
v-show="hybridmenou == 'mymicroservice'"
style="background-color: #f8f9fa"
>
</manage-mymicroservices>
<!-- ----------------------------------- -->
<!-- ------ hybrid manage microservices --------------- -->
<!-- ----------------------------------- -->
<!-- ----------------------------------- -->
<!-- ------ hybrid manage proofofconcept --------------- -->
<!-- ----------------------------------- -->
@ -617,6 +632,7 @@ import ServicesTable from "./components/myservices.vue";
import ManageServices from "./components/manageservices.vue";
import ManageStorage from "./components/mystorage.vue";
import ManageMicroservices from "./components/mymicroservices.vue";
import ManageMymicroservices from "./components/mymicroservicescustom.vue";
import ManageProofofconcept from "./components/proofofconcept.vue";
import ManageBuilders from "./components/mybuild.vue";
import ManageDeploy from "./components/managedeploy.vue";
@ -634,6 +650,7 @@ export default {
ManageServices,
ManageStorage,
ManageMicroservices,
ManageMymicroservices,
ManageProofofconcept,
ManageBuilders,
ManageDeploy,
@ -646,6 +663,7 @@ export default {
componentKeyreload1:1,
componentKeyreload2:1,
componentKeyreload3:1,
mycomponentKeyreload3:1,
componentKeyreload4:1,
componentKeybuilders:1,
setStatusAgent:'',
@ -717,6 +735,7 @@ export default {
this.componentKeyreload1 += 1
this.componentKeyreload2 += 1
this.componentKeyreload3 += 1
this.mycomponentKeyreload3 += 1
this.componentKeyreload4 += 1
this.componentKeybuilders += 1
}

26
src/components/mybuild.vue

@ -3,22 +3,21 @@
<div class="row" >
<div class="col-7 order-first " >
<br>
<view-network>
</view-network>
<builder-services>
</builder-services>
<br>
<builder-my-services>
</builder-my-services>
</div>
<div class="col-5 order-last" >
<br>
<adhoc-view>
<service-view>
</adhoc-view>
</service-view>
</div>
</div>
@ -27,17 +26,20 @@
</template>
<script>
import {mapState, mapGetters, mapActions} from 'vuex'
import ViewNetwork from "./mynetwork/mybuilder.vue";
import AdhocView from "./mynetwork/AdhocView.vue";
//import ViewNetwork from "./mynetwork/mybuilder.vue";
//import AdhocView from "./mynetwork/AdhocView.vue";
import ServiceView from "./mynetwork/customservices.vue";
import BuilderServices from "./mynetwork/builderservices.vue";
import BuilderMyServices from "./mynetwork/buildermyservices.vue";
import card from '@/components/Card.vue'
//import AvailableServices from "./mynetwork/availableservices.vue";
export default {
components: {
ViewNetwork,
AdhocView,
// ViewNetwork,
ServiceView,
card,
BuilderServices
BuilderServices,
BuilderMyServices
// AvailableServices
},
data () {

69
src/components/mymicroservicescustom.vue

@ -0,0 +1,69 @@
<template>
<card class="card-user" style="max-height:100%">
<div class="row" >
<div class="col-7 order-first " >
<br>
<!--
<view-network>
</view-network>
-->
<available-mymicroservices
:key="componentKeyreloadservice5"
>
</available-mymicroservices>
</div>
<div class="col-5 order-last" >
<br>
<adhoc-view>
</adhoc-view>
</div>
</div>
</card>
</template>
<script>
import {mapState, mapGetters, mapActions} from 'vuex'
//import ViewNetwork from "./mynetwork/mytable.vue";
import AdhocView from "./mynetwork/AdhocView.vue";
import card from '@/components/Card.vue'
//import DockerServices from "./mynetwork/dockerservices.vue";
import AvailableMymicroservices from "./mynetwork/availablemicroservicescustom.vue";
export default {
components: {
// ViewNetwork,
AdhocView,
card,
// DockerServices,
AvailableMymicroservices
},
data () {
return {
componentKeyreloadservice5:1,
loading: false,
consoleView: 'off',
productIndex: 1
}
},
mounted() {
this.$root.$on('hybrid_refresh_info_deploy_local', () => {
this.componentKeyreloadservice5 += 1
})
},
beforeDestroy () {
this.$root.$off('hybrid_refresh_info_deploy_local')
},
created () {
}
};
</script>
<style>
</style>

1336
src/components/mynetwork/\

File diff suppressed because it is too large

1181
src/components/mynetwork/availablemicroservicescustom.vue

File diff suppressed because it is too large

472
src/components/mynetwork/buildermyservices.vue

@ -0,0 +1,472 @@
<template>
<card class="card-user" style="max-height:100%">
<br>
<v-wait for="myRunInstancetutormybuild">
<template slot="waiting">
<div>
<img src="@/assets/loading.gif" />
Enter Lab_room...
</div>
</template>
</v-wait>
<div class="row text-center">
<div class="col-12">
<b>Swarmlab <span class="text-info">my Custom MicroServices</span></b>
</div>
</div>
<br>
<div class="input-group input-group-sm sm-3">
</div>
<div class="input-group input-group-sm sm-3">
<input type="text"
class="form-control"
aria-label="Small" aria-describedby="inputGroup-sizing-sm"
placeholder="Search"
v-model="searchFor"
@keyup.enter="setFilter"
>
<div class="input-group-append">
<button
class="btn btn-outline-primary"
round
type="button"
@click="setFilter">
Go</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-secondary"
round
type="button"
@click="resetFilter">
Reset</button>
</div>
</div>
<div class="input-group-append"
v-if="viewhybridoptions && heavy"
>
<p class="text-danger">{{ heavytext }}</p>
</div>
<div class="white h-100 flex-fixed-width-item"
<vuetable
ref="vuetable"
:key="vuetablekeygmybuildservice123"
:api-url='apiurl'
:api-mode="true"
:http-options="httpOptions"
:fields="fields"
:item-actions="itemActions"
:sort-order="sortOrder"
:show-sort-icons="true"
:multi-sort="multiSort"
:per-page="perpage"
pagination-path="links.pagination"
:pagination-component="paginationComponent"
:append-params="moreParams"
wrapper-class="vuetable-wrapper"
loading-class="loading"
detail-row-id="id"
@vuetable:pagination-data="onPaginationData"
@vuetable:load-success="loadsuccess"
@vuetable:load-error="onLoadError"
:css="css.table"
>
<div slot="actions" slot-scope="props">
<div class="d-flex justify-content-center">
<button
class="ti-pencil btn btn-outline-secondary btn-sm"
title="Upload MicroService"
round
@click="onAction('upload-item', props.rowData, props.rowData._id)">
</button>
<button
class="ti-trash btn btn-outline-warning btn-sm"
title="MicroService Info"
round
@click="onAction('rm-item', props.rowData, props.rowData._id)">
</button>
</div>
</div>
</vuetable>
<div class="vuetable-pagination ui basic segment grid">
<vuetable-pagination-info
ref="paginationInfo"
:css="css.paginationInfo"
>
</vuetable-pagination-info>
<vuetable-pagination
:css="css.pagination"
ref="pagination"
@vuetable-pagination:change-page="onChangePage"
>
</vuetable-pagination>
</div>
</div>
</b-container>
</card>
</template>
<script>
import store from '@/store/index'
import {mapState, mapGetters, mapActions,dispatch} from 'vuex'
import Vue from 'vue'
import {Vuetable, VuetablePaginationDropdown} from 'vuetable-2'
import VuetablePaginationInfo from 'vuetable-2/src/components/VuetablePaginationInfo'
import VuetablePagination from 'vuetable-2/src/components/VuetablePagination'
import CssConfig from 'vuetable-2/src/components/VuetableCssConfig.js'
import card from '@/components/Card.vue'
import {ApiConfig} from "@/config/index";
import {ApiConfigWEB} from "@/config/index-web";
export default {
components: {
card,
Vuetable,
VuetablePagination,
VuetablePaginationInfo,
VuetablePaginationDropdown
},
props: {
},
data() {
return{
testactionrowindex:[], // downloaded used in installed
teststatusindex:[], // status stop run used in status
testtest:[], // up or down services
testtestdir:[], // install download or not service
hybridoptions: {
'index':'',
'swarmlabname':'',
'size':'',
'port':''
},
viewhybridoptions: false,
heavy: false,
heavytext: '',
customedit: false,
custommenouopen: false,
custommenou: false,
custom: {
'os':'',
'sh':''
},
customostext: '',
customshtext: '',
up_name:'',
swarmlab:{},
playbookInfo: {},
token: '',
playbook: {
'title':'',
'name':'',
'description':''
},
container:{
name:'',
view:0
},
pipeline:{},
selected: 'hybrid',
options: [
{ text: 'Packages', value: 'packages' },
{ text: 'Images', value: 'images' },
{ text: 'Scripts', value: 'scripts' }