Browse Source

add storage module

master
zeus 3 years ago
parent
commit
71c04c2325
  1. 2
      dist/index.html
  2. 2
      dist/js/app.c5d83cd1.js
  3. 1
      dist/js/app.c5d83cd1.js.map
  4. 2
      dist/js/app.e36a9864.js
  5. 1
      dist/js/app.e36a9864.js.map
  6. 91
      src-local/llo/new.js
  7. 83
      src/components/mynetwork/availablestorage.vue
  8. 54
      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.2301b4fb.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.c5d83cd1.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.2301b4fb.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.c5d83cd1.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.2301b4fb.css" rel="preload" as="style"><link href="/css/chunk-vendors.e469b508.css" rel="preload" as="style"><link href="/js/app.e36a9864.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.2301b4fb.css" rel="stylesheet"></head><body><div id="app"></div><script src="/js/chunk-vendors.d8d18fe6.js"></script><script src="/js/app.e36a9864.js"></script></body></html>

2
dist/js/app.c5d83cd1.js

File diff suppressed because one or more lines are too long

1
dist/js/app.c5d83cd1.js.map

File diff suppressed because one or more lines are too long

2
dist/js/app.e36a9864.js

File diff suppressed because one or more lines are too long

1
dist/js/app.e36a9864.js.map

File diff suppressed because one or more lines are too long

91
src-local/llo/new.js

@ -161,6 +161,89 @@ app.post('/save_course_ascii', (req, res, next) => {
});
app.post('/check_storage_sudorun', (req, res, next) => {
const service = req.body["storagename"]
var mypath = process.cwd()
if(service){
var services_path = './instance/'+service
var ENV_service_file_sudorun = services_path+'/swarmlabconfig/sudorun-storage-run'
var ENV_service_file_sudorundest = services_path+'/sudorun-storage-run'
//console.log(ENV_service_file_sudorun)
if (fs.existsSync(ENV_service_file_sudorun)) {
fs.copyFile(ENV_service_file_sudorun, ENV_service_file_sudorundest, (err) => {
if (err){
var n = {}
n.data = 'yes'
n.path = mypath+'/instance/'+service
n.error = 'yes'
res.json(n)
}else{
var n = {}
n.data = 'yes'
n.path = mypath+'/instance/'+service
n.error = 'no'
res.json(n)
}
});
}else{
var n = {}
n.data = 'error'
n.path = mypath+'/instance/'+service
n.error = 'yes'
res.json(n)
}
}else{
var n = {}
n.data = 'nosudo'
n.path = mypath
res.json(n)
}
});
app.post('/check_storage_sudostop', (req, res, next) => {
const service = req.body["storagename"]
var mypath = process.cwd()
if(service){
var services_path = './instance/'+service
var ENV_service_file_sudostop = services_path+'/swarmlabconfig/sudorun-storage-stop'
var ENV_service_file_sudostopdest = services_path+'/sudorun-storage-stop'
//console.log(ENV_service_file_sudorun)
if (fs.existsSync(ENV_service_file_sudostop)) {
fs.copyFile(ENV_service_file_sudostop, ENV_service_file_sudostopdest, (err) => {
if (err){
var n = {}
n.data = 'yes'
n.path = mypath+'/instance/'+service
n.error = 'yes'
res.json(n)
}else{
var n = {}
n.data = 'yes'
n.path = mypath+'/instance/'+service
n.error = 'no'
res.json(n)
}
});
}else{
var n = {}
n.data = 'error'
n.path = mypath+'/instance/'+service
n.error = 'yes'
res.json(n)
}
}else{
var n = {}
n.data = 'nosudo'
n.path = mypath
res.json(n)
}
});
app.get('/get_course_ascii', (req, res, next) => {
const dir = req.query["dir"]
@ -686,7 +769,7 @@ app.get('/getstoragestatus', (req, res, next) => {
var found = 'no'
RES.error = false
RES.error_msg = "ok"
RES.data = "no sudorun file found";
RES.data = "no instance file found";
console.log(JSON.stringify(err))
res.json(RES)
}else{
@ -1223,7 +1306,7 @@ SWARMLAB_STORAGE_PASSWORD=${service_password}
var service_git = value.git
var services_path = './instance/'+service
var ENV_service_dir = services_path+'/'+service
var ENV_service_file_path = services_path+'/'+service+'/'.env
var ENV_service_file_path = services_path+'/'+service+'/.env'
var nn = {}
nn.data = 'Wait for service(s) to be available before executing a command'
io.emit('message_out', nn);
@ -1309,7 +1392,9 @@ SSH_PORT=
var service_git = value.git
var services_path = './instance/'+service
var ENV_service_dir = services_path+'/'+service
var ENV_service_file_path = services_path+'/'+service+'/'.env
var ENV_service_file_path = services_path+'/'+service+'/.env'
var nn = {}
nn.data = 'Wait for service(s) to be available before executing a command'
io.emit('message_out_storage', nn);

83
src/components/mynetwork/availablestorage.vue

@ -79,7 +79,7 @@
<button class="btn btn-outline-success"
round
type="button"
@click="setHybridoptions"
@click="checkHybridoptions"
>
Up</button>
</div>
@ -450,10 +450,22 @@ export default {
}else if(action == 'delete-item' ){
this.hybridoptions.swarmlabname = data.swarmlabname
var info='<h5>This will remove the storage with the name<b> '+ data.swarmlabname +'</b> </h5>'
var info='<h5>This will remove the storage with the name<b> '+ data.swarmlabname +'</b> </h5><br>'
var storage = this.hybridoptions.swarmlabname
var winfo=''
var res1 = await store.dispatch('pipelineLLO/getstoragesudopreparestop', storage)
if(res1.data.data == 'yes' && res1.data.error == 'no'){
var winfopath = res1.data.path
winfo='<span class="text-danger">Before continuing RUN the following command </span><br><br>'
winfo +='<span class="text-success">sudo /bin/bash '
winfo += winfopath.trim()
winfo += '/sudorun-storage-stop </span>'
}
this.$swal({
type: 'info',
html: info,
html: info+winfo,
icon:'info',
showCloseButton: true,
showLoaderOnConfirm: false,
@ -548,9 +560,69 @@ export default {
}
this.refreshVuetable()
},
async setHybridoptions(){
async checkHybridoptions(){
var storage = this.hybridoptions.swarmlabname
var res1 = await store.dispatch('pipelineLLO/getstoragesudoprepare', storage)
if(res1.data.data == 'yes' && res1.data.error == 'no'){
var info='<h4>Storage prepare2start</h4> <h5><i>Copy-and-run-command </i></h5> <br>'
var winfopath = res1.data.path
var winfo='<span class="text-success">sudo /bin/bash '
winfo += winfopath.trim()
winfo += '/sudorun-storage-run </span>'
this.$swal({
type: 'info',
html: info+winfo,
icon:'info',
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: true,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Yes, Run it!'
}).then((result)=> {
this.setHybridoptions(result);
})
}else if(res1.data.data == 'yes' && res1.data.error == 'yes'){
var info='<h4>Storage prepare2start</h4> <h5><i>Copy-and-run-command </i></h5> <br>'
var winfopath = res1.data.path
var winfo="<span class='text-success'>Can't write to file "
winfo += winfopath.trim()
winfo += '/sudorun-storage-run </span>'
this.$swal({
type: 'info',
html: info+winfo,
icon:'info',
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Ok!'
})
}else if(res1.data.data == 'nosudo'){ // nosudo file exec without
var myaction = {}
myaction.isConfirmed = 'true'
this.setHybridoptions(myaction)
}else if(res1.data.data == 'error' && res1.data.error == 'yes'){ // nosudufile exec
var myaction = {}
myaction.isConfirmed = 'true'
this.setHybridoptions(myaction)
}else{ // no files exec without
var myaction = {}
myaction.isConfirmed = 'true'
this.setHybridoptions(myaction)
}
},
async setHybridoptions(action){
console.log(JSON.stringify(action))
if(action.isConfirmed){
this.$wait.start('myRunInstancetutorstorage');
//console.log(JSON.stringify(this.hybridoptions))
//console.log('RUN 1 '+ JSON.stringify(data.swarmlabname))
// run on mytable.vue
@ -562,6 +634,7 @@ export default {
this.$root.$emit('hybrid_start_instance_storage', value)
Vue.set(this.testactionrowindex, value.swarmlabname, value.index)
Vue.nextTick( () => this.$refs.vuetable.refresh())
}
},
refreshVuetable() {

54
src/store/modules/create_pipelineLLO.js

@ -572,6 +572,60 @@ export default {
}
}
},
async getstoragesudoprepare({commit,rootGetters}, value) {
try {
var token = value.token
var params = {
storagename: value
}
var options = {
headers: { 'content-type': 'application/json',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/check_storage_sudorun'
var p = await axios.post(sock_server_l,params,options);
console.log('error '+JSON.stringify(p))
return p
} catch (e) {
if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){
//window.location.href = 'https://api-login.swarmlab.io:8089';
}else{
var R = {
ERROR_str: e,
ERROR: 'yes'
}
return R;
}
}
},
async getstoragesudopreparestop({commit,rootGetters}, value) {
try {
var token = value.token
var params = {
storagename: value
}
var options = {
headers: { 'content-type': 'application/json',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/check_storage_sudostop'
var p = await axios.post(sock_server_l,params,options);
console.log('error '+JSON.stringify(p))
return p
} catch (e) {
if(e.message == "Request failed with status code 401" || /401/i.test(e.message)){
//window.location.href = 'https://api-login.swarmlab.io:8089';
}else{
var R = {
ERROR_str: e,
ERROR: 'yes'
}
return R;
}
}
},
async get_llo_course_ascii({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value))

Loading…
Cancel
Save