Browse Source

add storage 1

master
zeus 3 years ago
parent
commit
77307c68db
  1. 2
      src-local/LabLearningObject-hybrid
  2. 244
      src-local/llo/new.js
  3. 26
      src/App.vue
  4. 8
      src/components/mynetwork/availableservices.vue
  5. 666
      src/components/mynetwork/availablestorage.vue
  6. 43
      src/components/mynetwork/mytable.vue
  7. 70
      src/components/mystorage.vue
  8. 80
      src/store/modules/create_pipelineLLO.js

2
src-local/LabLearningObject-hybrid

@ -1 +1 @@
Subproject commit 922df495bbafc1b8580dc8bbdf019d27ac31f320 Subproject commit 1f4f01de2f0c87e952dc8f3ea59bde7cd4bbe95c

244
src-local/llo/new.js

@ -675,6 +675,59 @@ app.get('/getservicesstatus', (req, res, next) => {
}); });
app.get('/getstoragestatus', (req, res, next) => {
var RES = new Object();
RES.instance = req.query["instance"]
var showfile = `./instance/${RES.instance}/swarmlabconfig/instance`
//console.log(JSON.stringify(showfile))
fs.readFile(showfile, 'utf8', function (err, data) {
if (err) {
var found = 'no'
RES.error = false
RES.error_msg = "ok"
RES.data = "no sudorun file found";
console.log(JSON.stringify(err))
res.json(RES)
}else{
data = data.trim();
var showexec = `docker ps --format '{"Names":"{{ .Names }}", "Status":"{{.Status}}"}' | jq . -s `
exec(showexec, (err, stdout, stderr) => {
if (err) {
return;
}
if (stdout) {
var string = stdout.toString()
var datajson = JSON.parse(string);
var extenderror = new RegExp(data);
var found = 'no';
for(var i = 0; i < datajson.length; i++) {
var servicename = datajson[i].Names
if(extenderror.test(servicename)){
found = 'yes';
}
}
RES.error = false
RES.error_msg = "ok"
RES.test = datajson;
RES.data = found;
res.json(RES)
}else{
var found = 'no'
RES.error = false
RES.error_msg = "ok"
RES.data = found;
res.json(RES)
}
});
}
});
});
app.get('/rm_swarmlab', (req, res, next) => { app.get('/rm_swarmlab', (req, res, next) => {
var mypath = process.cwd() var mypath = process.cwd()
@ -696,6 +749,28 @@ app.get('/rm_swarmlab', (req, res, next) => {
} }
}); });
});
app.get('/rm_swarmlabstorage', (req, res, next) => {
var mypath = process.cwd()
var RES = new Object();
RES.instance = req.query["instance"]
var services_path = './instance/'+RES.instance
fs.rm(services_path, {
recursive: true,
force: true
}, (error) => {
if (error) {
RES.error = true
RES.error_msg = "no"
res.json(RES)
} else {
RES.error = false
RES.error_msg = "ok"
res.json(RES)
}
});
}); });
app.get('/get_config', (req, res, next) => { app.get('/get_config', (req, res, next) => {
@ -1033,6 +1108,60 @@ TEST=${service}
} }
}); });
socket.on('start_storage', (value) => {
if(value.swarmlabname){
var service = value.swarmlabname
var services_path = './instance/'+service
var ENV_service_file_path = services_path+'/.env'
var service_password = ''
if(value.password){
service_password = value.password
}else{
service_password = Math.random().toString(36).substring(7);
}
var ENV_service_file = `
SWARMLAB_STORAGE_PASSWORD=${service_password}
`
fs.writeFileSync(ENV_service_file_path, ENV_service_file ,{encoding:'utf8',flag:'a'});
var service_up = '/bin/bash ./run.sh'
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()
io.emit('message_out_storage', n);
});
child[0].stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err_storage', n);
});
child[0].on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close_storage', n);
});
}else{
var n = {}
n.data = 'NoSwarmlabname'
io.emit('message_err_storage', n);
}
});
socket.on('stop', (service) => { socket.on('stop', (service) => {
var services_path = './instance/'+service+'/'+service var services_path = './instance/'+service+'/'+service
@ -1060,6 +1189,33 @@ TEST=${service}
}); });
}); });
socket.on('stop_storage', (service) => {
var services_path = './instance/'+service
//console.log(services_path)
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_storage', n);
});
stop.stderr.on('data', function (data) {
var n = {}
n.data = data.toString()
io.emit('message_err_storage', n);
});
stop.on('close', function (code) {
var n = {}
n.data = code
io.emit('message_close_storage', n);
});
});
socket.on('install', (value) => { socket.on('install', (value) => {
if(value.swarmlabname){ if(value.swarmlabname){
//console.log('install') //console.log('install')
@ -1145,6 +1301,94 @@ SSH_PORT=
} }
}); });
socket.on('installstorage', (value) => {
if(value.swarmlabname){
//console.log('install')
var service = value.swarmlabname
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 nn = {}
nn.data = 'Wait for service(s) to be available before executing a command'
io.emit('message_out_storage', 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_storage', n);
n.data = '...'
io.emit('message_out_storage', n);
n.data = 'ok'
io.emit('message_close_storage', n);
//create_project_storage(service,service)
}).catch((err) => {
var n = {}
n.data = err.toString()
io.emit('message_err_storage', n);
console.log('error ' + JSON.stringify(err))
});
} catch (e) {
var n = {}
n.data = e.toString()
io.emit('message_err_storage', n);
}
}else{
fs.mkdir(services_path, { recursive: true }, (err) => {
if (err){
console.log('error ' + JSON.stringify(err))
}else{
// var ENV_service_file = `
//IMAGE_NAME=${service}
//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_storage', n);
n.data = '...'
io.emit('message_out_storage', n);
n.data = 'ok'
io.emit('message_close_storage', n);
//fs.writeFileSync(ENV_service_file_path, ENV_service_file);
//create_project_storage(service,service)
}).catch((err) => {
var n = {}
n.data = err.toString()
io.emit('message_err_storage', n);
console.log('error ' + JSON.stringify(err))
});
} catch (e) {
var n = {}
n.data = e.toString()
io.emit('message_err_storage', n);
}
}
});
}
}else{
var n = {}
n.data = 'no services'
io.emit('message_err_storage', n);
}
});
socket.on('container-stop', (service, id) => { socket.on('container-stop', (service, id) => {
var mypath = process.cwd() var mypath = process.cwd()
//console.log(mypath); //console.log(mypath);

26
src/App.vue

@ -256,7 +256,8 @@
<b-list-group-item v-b-toggle.hybrid-private variant="light" name="Private" class="ti-home list-group-item list-group-item-action" v-on:click="setActive('private','')" style="cursor: pointer;" :class="{ active: isActive('private') }" @click="hybrid('services')" > Private/Local</b-list-group-item> <b-list-group-item v-b-toggle.hybrid-private variant="light" name="Private" class="ti-home list-group-item list-group-item-action" v-on:click="setActive('private','')" style="cursor: pointer;" :class="{ active: isActive('private') }" @click="hybrid('services')" > Private/Local</b-list-group-item>
<b-collapse id="hybrid-private" class="m-subm" accordion="m-sidebar" role="tabpanel"> <b-collapse id="hybrid-private" class="m-subm" accordion="m-sidebar" role="tabpanel">
<b-list-group-item variant="light" name="Container" class="ti-harddrive m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_private')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_private') }" @click="hybrid('services')"> Bootstrap</b-list-group-item> <b-list-group-item variant="light" name="Container" class="ti-harddrive m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_private')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_private') }" @click="hybrid('services')"> LabRoom</b-list-group-item>
<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-collapse> </b-collapse>
<!-- Menou llo --> <!-- Menou llo -->
@ -322,7 +323,8 @@
<b-list-group-item v-b-toggle.hybrid-private1 variant="light" name="Private" class="ti-home list-group-item list-group-item-action" v-on:click="setActive('private','')" style="cursor: pointer;" :class="{ active: isActive('private') }" @click="hybrid('services')" title="Private"> </b-list-group-item> <b-list-group-item v-b-toggle.hybrid-private1 variant="light" name="Private" class="ti-home list-group-item list-group-item-action" v-on:click="setActive('private','')" style="cursor: pointer;" :class="{ active: isActive('private') }" @click="hybrid('services')" title="Private"> </b-list-group-item>
<b-collapse id="hybrid-private1" class="m-subm" accordion="m-sidebar" role="tabpanel"> <b-collapse id="hybrid-private1" class="m-subm" accordion="m-sidebar" role="tabpanel">
<b-list-group-item variant="light" name="Container" class="ti-harddrive m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_private')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_private') }" @click="hybrid('services')" title="Bootstrap"> </b-list-group-item> <b-list-group-item variant="light" name="Container" class="ti-harddrive m-subm-listgroup list-group-item list-group-item-action" v-on:click="setActive('private','hybrid_private')" style="cursor: pointer;" :class="{ active: isActiveSub('hybrid_private') }" @click="hybrid('services')" title="LabRoom"> </b-list-group-item>
<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-collapse> </b-collapse>
<!-- Menou llo --> <!-- Menou llo -->
@ -421,6 +423,20 @@
<!-- ------ hybrid private bootstrap --------------- --> <!-- ------ hybrid private bootstrap --------------- -->
<!-- ----------------------------------- --> <!-- ----------------------------------- -->
<!-- ----------------------------------- -->
<!-- ------ hybrid manage storage --------------- -->
<!-- ----------------------------------- -->
<manage-storage
:key="componentKeyreload2"
v-show="hybridmenou == 'storage'"
style="background-color: #f8f9fa"
>
</manage-storage>
<!-- ----------------------------------- -->
<!-- ------ hybrid manage storage --------------- -->
<!-- ----------------------------------- -->
<!-- ----------------------------------- --> <!-- ----------------------------------- -->
<!-- ------ hybrid private deploy --------------- --> <!-- ------ hybrid private deploy --------------- -->
<!-- ----------------------------------- --> <!-- ----------------------------------- -->
@ -509,6 +525,7 @@ import ConnectServer from "./components/myconnect-server.vue";
import NetworkTable from "./components/mynetwork.vue"; import NetworkTable from "./components/mynetwork.vue";
import ServicesTable from "./components/myservices.vue"; import ServicesTable from "./components/myservices.vue";
import ManageServices from "./components/manageservices.vue"; import ManageServices from "./components/manageservices.vue";
import ManageStorage from "./components/mystorage.vue";
import ManageDeploy from "./components/managedeploy.vue"; import ManageDeploy from "./components/managedeploy.vue";
import ManageLlo from "./components/managello.vue"; import ManageLlo from "./components/managello.vue";
import ViewDashboard from "./components/dashboard.vue"; import ViewDashboard from "./components/dashboard.vue";
@ -521,6 +538,7 @@ export default {
ServicesTable, ServicesTable,
ConnectServer, ConnectServer,
ManageServices, ManageServices,
ManageStorage,
ManageDeploy, ManageDeploy,
ManageLlo ManageLlo
}, },
@ -529,6 +547,7 @@ export default {
warning: true, warning: true,
componentKeyreload:1, componentKeyreload:1,
componentKeyreload1:1, componentKeyreload1:1,
componentKeyreload2:1,
setStatusAgent:'', setStatusAgent:'',
issocket:false, //socket server issocket:false, //socket server
isconnect:false, // dockerswarm wg isconnect:false, // dockerswarm wg
@ -596,6 +615,7 @@ export default {
//window.location.reload() //window.location.reload()
this.componentKeyreload += 1 this.componentKeyreload += 1
this.componentKeyreload1 += 1 this.componentKeyreload1 += 1
this.componentKeyreload2 += 1
} }
}, },
async serverstatus(action){ async serverstatus(action){
@ -632,6 +652,8 @@ export default {
this.$root.$emit('hybrid_refresh_availableservices') this.$root.$emit('hybrid_refresh_availableservices')
}else if(action == 'manage_service'){ }else if(action == 'manage_service'){
//this.$root.$emit('hybrid_manage_service') //this.$root.$emit('hybrid_manage_service')
}else if(action == 'storage'){
//this.$root.$emit('hybrid_manage_service')
}else if(action == 'manage_deploy'){ }else if(action == 'manage_deploy'){
} }
}, },

8
src/components/mynetwork/availableservices.vue

@ -17,7 +17,7 @@
</v-wait> </v-wait>
<div class="row text-center"> <div class="row text-center">
<div class="col-12"> <div class="col-12">
<b>Swarmlab Deploy - Local </b> <b>Swarmlab <span class="text-info">LabRoom</span> Deploy - Local </b>
</div> </div>
</div> </div>
@ -125,7 +125,7 @@
<button <button
v-if="testactionrowindex[props.rowData.swarmlabname] == props.rowIndex" v-if="testactionrowindex[props.rowData.swarmlabname] == props.rowIndex"
class="ti-thumb-up btn btn-info btn-sm" class="ti-thumb-up btn btn-info btn-sm"
title="Stop Lan_Instance" title="Stop Lab_Instance"
round round
@click="onAction('down-item', props.rowData, props.rowIndex)" @click="onAction('down-item', props.rowData, props.rowIndex)"
> >
@ -133,7 +133,7 @@
<button <button
v-if="testactionrowindex[props.rowData.swarmlabname] != props.rowIndex && testactionrowindex[props.rowIndex] == props.rowIndex" v-if="testactionrowindex[props.rowData.swarmlabname] != props.rowIndex && testactionrowindex[props.rowIndex] == props.rowIndex"
class="ti-thumb-down btn btn-secondary btn-sm" class="ti-thumb-down btn btn-secondary btn-sm"
title="Start Lan_Instance" title="Start Lab_Instance"
round round
@click="onAction('run-item', props.rowData, props.rowIndex)" @click="onAction('run-item', props.rowData, props.rowIndex)"
> >
@ -143,7 +143,7 @@
<div slot="actionslocal" slot-scope="props"> <div slot="actionslocal" slot-scope="props">
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<button <button
v-if="testactionrowindex[props.rowIndex] == props.rowIndex" v-if="testactionrowindex[props.rowIndex] == props.rowIndex && testactionrowindex[props.rowData.swarmlabname] != props.rowIndex"
class="ti-trash btn btn-info btn-sm" class="ti-trash btn btn-info btn-sm"
title="Remove Lab_Instance" title="Remove Lab_Instance"
@click="onAction('rm-install', props.rowData, props.rowIndex)" @click="onAction('rm-install', props.rowData, props.rowIndex)"

666
src/components/mynetwork/availablestorage.vue

@ -0,0 +1,666 @@
<template>
<card class="card-user" style="max-height:100%">
<div class="author">
<img class="avatar border-white" src="@/assets/img/docker.png" alt="...">
</div>
<b-container fluid class="bv-example-row">
<v-wait for="myRunInstancetutorstorage">
<template slot="waiting">
<div>
<img src="@/assets/loading.gif" />
Enter Lab_room storage...
</div>
</template>
</v-wait>
<div class="row text-center">
<div class="col-12">
<b>Swarmlab <span class="text-info">Storage</span> Deploy - Local </b>
</div>
</div>
<br>
<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="row"
v-if="viewhybridoptions"
>
<b-col class="text-center" cols="12" sm="12" md="12">
<span>
<b>Storage Service Options</b>
</span>
</b-col>
</div>
<div class="input-group-append"
v-if="viewhybridoptions"
>
<button class="btn btn-outline-secondary"
round
type="button"
>
Admin </button>
<input type="text"
class="form-control"
aria-label="Small" aria-describedby="inputGroup-sizing-sm"
placeholder="New Password"
v-model="hybridoptions.password"
>
<button class="btn btn-outline-success"
round
type="button"
@click="setHybridoptions"
>
Up</button>
</div>
<div class="white h-100 flex-fixed-width-item"
<vuetable
ref="vuetable"
:key="vuetablekeystorage"
: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="actionsenabled" slot-scope="props">
<div class="d-flex justify-content-center">
<button
v-if="testactionrowindex[props.rowData.swarmlabname] == props.rowIndex"
class="ti-thumb-up btn btn-info btn-sm"
title="Stop Lab_Instance"
round
@click="onAction('down-item', props.rowData, props.rowIndex)"
>
</button>
<button
v-if="testactionrowindex[props.rowData.swarmlabname] != props.rowIndex && testactionrowindex[props.rowIndex] == props.rowIndex"
class="ti-thumb-down btn btn-secondary btn-sm"
title="Start Lab_Instance"
round
@click="onAction('run-item', props.rowData, props.rowIndex)"
>
</button>
</div>
</div>
<div slot="actionslocal" slot-scope="props">
<div class="d-flex justify-content-center">
<button
v-if="testactionrowindex[props.rowIndex] == props.rowIndex && testactionrowindex[props.rowData.swarmlabname] != props.rowIndex"
class="ti-trash btn btn-info btn-sm"
title="Remove Lab_Instance"
@click="onAction('delete-item', props.rowData, props.rowIndex)"
round
>
</button>
</div>
</div>
<div slot="actions" slot-scope="props">
<div class="d-flex justify-content-center">
<button
v-if="checkactionrowindex(props.rowData,props.rowIndex)"
class="ti-cloud-down btn btn-outline-secondary btn-sm"
title="Download Lab_Instance"
round
@click="onAction('run-install', props.rowData, props.rowIndex)">
</button>
<button
class="ti-info btn btn-outline-secondary btn-sm"
title="Lab_Instance Info"
round
@click="onAction('view-item', props.rowData, props.rowIndex)">
</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";
export default {
components: {
card,
Vuetable,
VuetablePagination,
VuetablePaginationInfo,
VuetablePaginationDropdown
},
props: {
},
data() {
return{
testactionrowindex:[], // downloaded used in installed
teststatusindex:[], // status stop run used in status
hybridoptions: {
'index':'',
'swarmlabname':'',
'password':'',
'port':''
},
viewhybridoptions: false,
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' }
],
showModal: false,
visibility: [],
active:false,
vuetablekeystorage:0,
fielddata:{},
fields: [
{
name: 'swarmlabname',
title: '<span class="orange"></span>Name',
sortField: 'swarmlabname',
visible:true,
dataClass: 'left aligned col-3',
width: '68%'
},
{
name: '_id',
title: '<span class="orange"></span>mongo',
visible:false
},
{
name: 'description',
sortField: 'gitrepoCloneUrl',
titleClass: 'center aligned',
dataClass: 'left aligned w-25',
visible:false,
width: '15%'
},
{
name: 'gitrepoFullName',
sortField: 'gitrepoFullName',
titleClass: 'center aligned',
dataClass: 'left aligned w-25',
visible:false,
width: '15%'
},
{
name: '__slot:actionsenabled', // <----
title: 'Status',
titleClass: 'center',
dataClass: 'center aligned',
width: '5%'
},
{
name: '__slot:actionslocal', // <----
title: 'Installed',
titleClass: 'center',
dataClass: 'center aligned',
width: '5%'
},
{
name: '__slot:actions', // <----
title: 'Download',
titleClass: 'col text-center',
dataClass: 'center aligned',
width: '10%'
},
],
apiurl:ApiConfig.swarmlab_url_80+"/swarmlabhybridstorage",
css: CssConfig,
perpage: 5,
searchFor: '',
sortOrder: [{
field: 'pipelinename',
direction: 'asc'
}],
multiSort: true,
paginationComponent: 'vuetable-pagination',
itemActions: [
{ name: 'view-item', label: '', icon: 'glyphicon glyphicon-zoom-in', class: 'btn btn-info', extra: {'title': 'View', 'data-toggle':"tooltip", 'data-placement': "left"} },
{ name: 'edit-item', label: '', icon: 'glyphicon glyphicon-pencil', class: 'btn btn-warning', extra: {title: 'Edit', 'data-toggle':"tooltip", 'data-placement': "top"} },
{ name: 'delete-item', label: '', icon: 'glyphicon glyphicon-remove', class: 'btn btn-danger', extra: {title: 'Delete', 'data-toggle':"tooltip", 'data-placement': "right" } }
],
moreParams: {
'filter': '',
'type': 'scripts'
},
}
},
mounted() {
this.$root.$on('hybrid_refresh_availableservices_storage', () => {
Vue.nextTick( () => this.$refs.vuetable.refresh())
})
//refresh from socket mytable
this.$root.$on('hybrid_refresh_table_storage', (v) => {
this.$nextTick(function () {
Vue.nextTick( () => this.$refs.vuetable.refresh())
this.viewhybridoptions = false
this.$wait.end('myRunInstancetutorstorage');
})
})
},
created() {
var url_string = window.location.href
var url = new URL(url_string);
this.token = url.searchParams.get("token");
//console.log("token "+ this.token);
},
beforeDestroy () {
this.$root.$off('hybrid_refresh_availableservices_storage')
this.$root.$off('hybrid_refresh_table_storage')
},
computed: {
httpOptions() {
var token = this.token
var p="headers: {Authorization: token}}"; //table props -> :http-options="httpOptions"
return {headers: {Authorization: 'Bearer ' + token}} //table props -> :http-options="httpOptions"
},
},
methods: {
onError (type,description) {
var winfo=description
var info='<h5>Bootstrap '+type+'</h5>'
this.$swal({
type: type,
html: info+winfo,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Ok!'
})
},
async checkactionrowindex(data,index){
if(this.testactionrowindex[index] == index){
var obj = {}
obj.token = this.token
obj.instance = data.swarmlabname
var res1 = await store.dispatch('pipelineLLO/getstoragestatus', obj)
//console.log('res8 all '+JSON.stringify(res1))
if(res1.data.data == 'yes'){
Vue.set(this.testactionrowindex, data.swarmlabname, index)
//console.log('res8 YES '+JSON.stringify(res1.data))
}else{
//console.log('res8 NO '+JSON.stringify(res1.data))
Vue.delete(this.testactionrowindex, data.swarmlabname)
}
//console.log('is set '+index)
}else{
//console.log('not set '+index)
var obj = {}
obj.token = this.token
obj.instance = data.swarmlabname
var res = await store.dispatch('pipelineLLO/getservicesinfo', obj)
if(res.data.data == 'yes'){
//console.log('resi YES '+JSON.stringify(res))
Vue.set(this.testactionrowindex, index, index)
var res1 = await store.dispatch('pipelineLLO/getstoragestatus', obj)
//console.log('res8 alli--- '+JSON.stringify(res1))
if(res1.data.data == 'yes'){
Vue.set(this.testactionrowindex, data.swarmlabname, index)
//console.log('res8 YES '+JSON.stringify(res1.data))
}else{
//console.log('res8 NO '+JSON.stringify(res1.data))
Vue.delete(this.testactionrowindex, data.swarmlabname)
}
//console.log('resiiiiiiii yes '+JSON.stringify(this.testactionrowindex[index]))
}else{
//Vue.delete(this.testactionrowindex, index)
console.log('resi NO '+JSON.stringify(res))
}
}
},
setFilter () {
this.moreParams = {
'filter': this.searchFor,
'type': this.selected
}
Vue.nextTick( () => this.$refs.vuetable.refresh())
},
resetFilter () {
this.moreParams = {}
this.searchFor = ''
Vue.nextTick( () => this.$refs.vuetable.refresh())
},
onPaginationData (paginationData) {
this.$refs.pagination.setPaginationData(paginationData)
this.$refs.paginationInfo.setPaginationData(paginationData)
},
onChangePage (page) {
this.$refs.vuetable.changePage(page)
},
editRow(rowData) {
alert("You clicked edit on"+ JSON.stringify(rowData));
},
async onAction (action, data, index) {
if(action == 'view-item' ){
this.swarmlab=data
var container=this.swarmlab
var res = await store.dispatch('pipelineLLO/getswarmlabstorageinfo', container.swarmlabname)
var swarmlab1=JSON.stringify(res.data.swarmlab, null ,2)
var swarmlab1info=JSON.stringify(res.data.swarmlabinfo, null ,2)
var swarmlab1info=res.data.swarmlabinfo
var description='<div style="height: 250px; overflow-y: scroll;"><p><pre><code class="codeblock">'+swarmlab1+'</code></pre></p></div>'
if(res.data.error25=="ok"){
var winfo=''
var info='<h5>Swarmlab Service <a href="'+swarmlab1info+'" target="_blank" >Info</a></h5>(Open page in new window)'
this.$swal({
type: 'info',
html: info+winfo,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true
})
}
}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>'
this.$swal({
type: 'info',
html: info,
icon:'info',
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: true,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: true,
confirmButtonText: 'Yes, Delete it!'
}).then((result)=> {
this.rmStorageAndClose(result);
})
//Vue.nextTick( () => this.$refs.vuetable.refresh())
this.refreshVuetable()
}else if(action == 'run-install' ){
this.$wait.start('myRunInstancetutorstorage');
this.hybridoptions.swarmlabname = data.swarmlabname
this.hybridoptions.index = index
let value = {}
value.swarmlabname = this.hybridoptions.swarmlabname
value.index = this.hybridoptions.index
value.size = this.hybridoptions.size
value.port = this.hybridoptions.port
var res = await store.dispatch('pipelineLLO/getswarmlabstorageinfo', value.swarmlabname)
var swarmlab1info=res.data.swarmlabinfo
value.git = swarmlab1info
this.$root.$emit('hybrid_install_instance_storage', value)
this.$wait.end('myRunInstancetutorstorage');
this.refreshVuetable()
}else if(action == 'run-item' ){
this.viewhybridoptions = true
this.hybridoptions.swarmlabname = data.swarmlabname
this.hybridoptions.index = index
/*
console.log('RUN 1 '+ JSON.stringify(data.swarmlabname))
// run on mytable.vue
this.$root.$emit('hybrid_start_instance', data.swarmlabname)
Vue.set(this.testactionrowindex, data.swarmlabname, index)
Vue.nextTick( () => this.$refs.vuetable.refresh())
*/
//Vue.nextTick( () => this.$refs.vuetable.refresh())
}else if(action == 'down-item' ){
this.hybridoptions.swarmlabname = data.swarmlabname
this.hybridoptions.index = index
var info = "Stop and remove storage: containers, networks, images, and volumes"
this.$swal({
type: 'info',
html: info,
showCloseButton: true,
showLoaderOnConfirm: false,
allowOutsideClick: false,
cancelButtonText: 'No, cancel!',
showCancelButton: true,
showLoaderOnConfirm: false,
reverseButtons: true,
focusCancel: false,
confirmButtonText: 'Yes!'
}).then((result)=> {
this.rmAndClose(result);
})
//console.log('RUN 1 '+ JSON.stringify(data.swarmlabname))
Vue.nextTick( () => this.$refs.vuetable.refresh())
}
},
async rmStorageAndClose(action){
if(action.isConfirmed){
//this.hybridoptions.swarmlabname = data.swarmlabname
this.$wait.start('myRunInstancetutorstorage');
var res = await store.dispatch('pipelineLLO/rmswarmlablocalstorage', this.hybridoptions.swarmlabname)
this.$wait.end('myRunInstancetutorstorage');
//Vue.nextTick( () => this.$refs.vuetable.refresh())
Vue.delete(this.testactionrowindex, this.hybridoptions.swarmlabname)
this.refreshVuetable()
this.$root.$emit('hybrid_refresh_info_deploy_local')
//console.log('inf res '+ JSON.stringify(res))
}
},
async rmAndClose(result){
if (result.isConfirmed) {
this.$wait.start('myRunInstancetutorstorage');
var value = this.hybridoptions.swarmlabname
this.$root.$emit('hybrid_stop_instance_storage', value)
Vue.delete(this.testactionrowindex, this.hybridoptions.index)
Vue.nextTick( () => this.$refs.vuetable.refresh())
}else {
console.log('no')
}
this.refreshVuetable()
},
async setHybridoptions(){
this.$wait.start('myRunInstancetutorstorage');
//console.log(JSON.stringify(this.hybridoptions))
//console.log('RUN 1 '+ JSON.stringify(data.swarmlabname))
// run on mytable.vue
let value = {}
value.swarmlabname = this.hybridoptions.swarmlabname
value.index = this.hybridoptions.index
value.password = this.hybridoptions.password
value.port = this.hybridoptions.port
this.$root.$emit('hybrid_start_instance_storage', value)
Vue.set(this.testactionrowindex, value.swarmlabname, value.index)
Vue.nextTick( () => this.$refs.vuetable.refresh())
},
refreshVuetable() {
this.$nextTick(()=>{
this.vuetablekeystorage += 1
})
},
playbookinfoShow(value) {
return this.visibility[value]=true
},
playbookinfo(value) {
return this.playbookInfo=value
},
rowClicked(row, event) {
return {
html: true,
title: () => { return 'Hello <b>Popover:</b> ' + (++this.counter) },
content: () => { return 'The date is:<br><em>' + new Date() + '</em>' }
}
},
loadsuccess(response) {
var data = response.data.data
this.fielddata=data
var n = data.length
n=n-1
},
onLoadError(payload) {
/*
//error2 "invalid_token" join-service.vue:684
//error2 "The access token provided has expired" join-service.vue:685
//error2 "Unauthorized" join-service.vue:686
//error2 401
console.log('error2 '+JSON.stringify(payload.response.data.error))
console.log('error2 '+JSON.stringify(payload.response.data.error_description))
console.log('error2 '+JSON.stringify(payload.response.statusText))
console.log('error2 '+JSON.stringify(payload.response.status))
*/
if(payload.response.status == '401'){
window.location.href = 'https://api-login.swarmlab.io:8089';
Vue.nextTick( () => window.location.href = 'https://api-login.swarmlab.io:8089')
}
}
},
actions: {
}
};
</script>
<style>
.flex-fixed-width-item {
flex: 0 0 100px;
}
.modalinfo {
z-index: 10000000 !important;
position:fixed;
}
/* a container with flex-direction column */
.vue-notifyjs.notifications{
.alert{
z-index: 100;
}
.list-move {
transition: transform 0.3s, opacity 0.4s;
}
.list-item {
display: inline-block;
margin-right: 10px;
}
.list-enter-active {
transition: transform 0.2s ease-in, opacity 0.4s ease-in;
}
.list-leave-active {
transition: transform 1s ease-out, opacity 0.4s ease-out;
}
.list-enter {
opacity: 0;
transform: scale(1.1);
}
.list-leave-to {
opacity: 0;
transform: scale(1.2, 0.7);
}
}
pre {
//background-color: rgb(255, 247, 229);
background-color: #eff0f1;
border: 1px solid blue;
//white-space: pre-line;
}
</style>

43
src/components/mynetwork/mytable.vue

@ -209,6 +209,15 @@ export default {
//console.log('RUN exec '+JSON.stringify(this.swarmlabname)) //console.log('RUN exec '+JSON.stringify(this.swarmlabname))
this.onAction('start') this.onAction('start')
}) })
this.$root.$on('hybrid_start_instance_storage', (data) => {
var obj = {}
obj.action = 'up'
obj.token = this.token
obj.swarmlabname = data.swarmlabname
obj.password = data.password
this.$socket.client.open();
this.$socket.client.emit('start_storage', obj);
})
// from available services socket run here // from available services socket run here
this.$root.$on('hybrid_install_instance', (data) => { this.$root.$on('hybrid_install_instance', (data) => {
this.swarmlabname = data.swarmlabname this.swarmlabname = data.swarmlabname
@ -216,6 +225,18 @@ export default {
//this.swarmlabname_port = data.port //this.swarmlabname_port = data.port
this.onAction('install') this.onAction('install')
}) })
// from available storage socket run here
this.$root.$on('hybrid_install_instance_storage', (data) => {
//this.swarmlabname = data.swarmlabname
//this.swarmlabname_git = data.git
var obj = {}
obj.action = 'up'
obj.token = this.token
obj.swarmlabname = data.swarmlabname
obj.git = data.git
this.$socket.client.open();
this.$socket.client.emit('installstorage', obj);
})
// from available services socket run here // from available services socket run here
this.$root.$on('hybrid_connect_server', (data) => { this.$root.$on('hybrid_connect_server', (data) => {
//this.onAction('create-wirequard') //this.onAction('create-wirequard')
@ -227,6 +248,13 @@ export default {
//console.log('RUN exec '+JSON.stringify(this.swarmlabname)) //console.log('RUN exec '+JSON.stringify(this.swarmlabname))
this.onAction('stop') this.onAction('stop')
}) })
// from available storage socket run here
this.$root.$on('hybrid_stop_instance_storage', (data) => {
//this.swarmlabname = data
//console.log('RUN exec '+JSON.stringify(this.swarmlabname))
//this.onAction('stop')
this.$socket.client.emit('stop_storage', data);
})
}, },
created() { created() {
var url_string = window.location.href var url_string = window.location.href
@ -245,6 +273,7 @@ export default {
this.$root.$off('hybrid_stop_instance') this.$root.$off('hybrid_stop_instance')
this.$root.$off('hybrid_connect_server') this.$root.$off('hybrid_connect_server')
this.$root.$off('hybrid_install_instance') this.$root.$off('hybrid_install_instance')
this.$root.$off('hybrid_install_instance_storage')
}, },
computed: { computed: {
httpOptions() { httpOptions() {
@ -632,6 +661,20 @@ info +='This permits the docker user on the local machine to connect to X window
// refresh adhocview.vue on console await console // refresh adhocview.vue on console await console
this.$root.$emit('SERVER_hybrid_table_stop') this.$root.$emit('SERVER_hybrid_table_stop')
}, },
async message_err_storage(val) {
//console.log(" socket err "+JSON.stringify(val))
this.$root.$emit('hybrid_log_in',val)
},
async message_out_storage(val) {
console.log(" socket out storage "+JSON.stringify(val))
this.$root.$emit('hybrid_log_in',val)
//this.hybridshowdata = {}
},
async message_close_storage(val) {
// refresh table hybrid storage
this.$root.$emit('hybrid_log_in',val)
this.$root.$emit('hybrid_refresh_table_storage')
},
async message_hybrid_status(val) { async message_hybrid_status(val) {
var obj = {} var obj = {}
obj.status = val obj.status = val

70
src/components/mystorage.vue

@ -0,0 +1,70 @@
<template>
<card class="card-user" style="max-height:100%">
<div class="row" >
<div class="col-7 order-first " >
<br>
<!--
<view-network>
</view-network>
-->
<available-storage
:key="componentKeyreloadstorage"
>
</available-storage>
</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 AvailableServices from "./mynetwork/availableservices.vue";
import AvailableStorage from "./mynetwork/availablestorage.vue";
export default {
components: {
// ViewNetwork,
AdhocView,
card,
// DockerServices,
AvailableStorage
},
data () {
return {
componentKeyreloadstorage:1,
loading: false,
consoleView: 'off',
productIndex: 1
}
},
mounted() {
this.$root.$on('hybrid_refresh_info_deploy_local', () => {
this.componentKeyreloadstorage += 1
})
},
beforeDestroy () {
this.$root.$off('hybrid_refresh_info_deploy_local')
},
created () {
}
};
</script>
<style>
</style>

80
src/store/modules/create_pipelineLLO.js

@ -424,6 +424,34 @@ export default {
return R; return R;
} }
} }
},
async getstoragestatus({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+'/getstoragestatus'
var p = await axios.get(sock_server_l,options);
//var p = await axios.get('https://localhost:3000/getservicesstatus',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 create_config({commit,rootGetters}, value) { async create_config({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value)) //console.log('value '+JSON.stringify(value))
@ -484,6 +512,36 @@ export default {
} }
} }
},
async rmswarmlablocalstorage({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value))
try {
var token = value.token
var params = {
instance: value
}
var options = {
params: params,
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
};
var sock_server_l = ApiConfig.url_80+'/rm_swarmlabstorage'
var p = await axios.get(sock_server_l,options);
//var p = await axios.get('https://localhost:3000/get_config',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 save_llo_asciidoctmp({commit,rootGetters}, value) { async save_llo_asciidoctmp({commit,rootGetters}, value) {
//console.log('value '+JSON.stringify(value)) //console.log('value '+JSON.stringify(value))
@ -628,6 +686,28 @@ export default {
} }
} }
}, },
async getswarmlabstorageinfo({commit,rootGetters}, value) {
try {
var token = rootGetters['pipelineLLO/gettoken']
//console.log('token ' + token)
var params = {
swarmlabname: value
}
var options = {
params: params,
headers: { 'content-type': 'application/x-www-form-urlencoded',Authorization: `Bearer ${token}` },
};
const info = await axios.get('https://api.swarmlab.io/getswarmlabhybridstorageinfo',options);
return info
} catch (e) {
//console.error(e);
if(e.error == "invalid_token"){
window.location.href = 'https://api-login.swarmlab.io:8089';
}
}
},
async hybrid_join({commit,rootGetters}, value) { async hybrid_join({commit,rootGetters}, value) {
try { try {
var token = value.token var token = value.token

Loading…
Cancel
Save