Commit e3f189c2 by Heechul Kim

Add server-side supported os

parent 89c8c1bb
...@@ -39,6 +39,7 @@ from porch.config import PORCH_USER ...@@ -39,6 +39,7 @@ from porch.config import PORCH_USER
from porch.config import IPMITOOL, IPMIPOWER, IPMICONSOLE, IPMIUSER, IPMIPASS from porch.config import IPMITOOL, IPMIPOWER, IPMICONSOLE, IPMIUSER, IPMIPASS
from porch.config import OS_LOG from porch.config import OS_LOG
from porch.config import FAI_MONITOR from porch.config import FAI_MONITOR
from porch.config import SUPPORTED_OS
from porch.utils import cmd from porch.utils import cmd
...@@ -432,7 +433,7 @@ def install_machine(data): ...@@ -432,7 +433,7 @@ def install_machine(data):
# power on the physical machines if any. # power on the physical machines if any.
if len(l_ipmi): if len(l_ipmi):
for ipmi_ip in l_ipmi: for ipmi_ip in l_ipmi:
s_cmd = "{} -I lanplus -H {} -U {} -f {} chassis power cycle"\ s_cmd = "{} -I lanplus -H {} -U {} -f {} chassis power reset"\
.format(IPMITOOL, ipmi_ip, IPMIUSER, s_tmp) .format(IPMITOOL, ipmi_ip, IPMIUSER, s_tmp)
(b_ret, l_out) = cmd(s_cmd) (b_ret, l_out) = cmd(s_cmd)
...@@ -593,3 +594,11 @@ def poweroff_machine(name): ...@@ -593,3 +594,11 @@ def poweroff_machine(name):
log.warn(e) log.warn(e)
return (b_ret, s_msg) return (b_ret, s_msg)
def supported_os_machine():
"""Returns supported OS."""
l_supported_os = list()
l_supported_os = SUPPORTED_OS
return l_supported_os
...@@ -29,6 +29,7 @@ from porch.api.machine.bizlogic import close_console_machine ...@@ -29,6 +29,7 @@ from porch.api.machine.bizlogic import close_console_machine
from porch.api.machine.bizlogic import dpt_machine from porch.api.machine.bizlogic import dpt_machine
from porch.api.machine.bizlogic import poweron_machine from porch.api.machine.bizlogic import poweron_machine
from porch.api.machine.bizlogic import poweroff_machine from porch.api.machine.bizlogic import poweroff_machine
from porch.api.machine.bizlogic import supported_os_machine
log = logging.getLogger('porch') log = logging.getLogger('porch')
...@@ -236,3 +237,15 @@ class MachinePowerOff(Resource): ...@@ -236,3 +237,15 @@ class MachinePowerOff(Resource):
return d_msg, i_ret_code return d_msg, i_ret_code
@ns.route('/supported_os')
class MachineSupportedOS(Resource):
@ns.response(200, 'Machine successfully powered off.')
@jwt_required
def get(self):
"""Get supported OS.
"""
l_supported_os = list()
l_supported_os = supported_os_machine()
return l_supported_os
...@@ -34,6 +34,8 @@ MY_IP = '121.254.203.198' ...@@ -34,6 +34,8 @@ MY_IP = '121.254.203.198'
PROXY_URL = '192.168.24.50' PROXY_URL = '192.168.24.50'
PROXY_PORT = 3128 PROXY_PORT = 3128
# Supported OS List
SUPPORTED_OS = ['JESSIE', 'CENTOS7', 'CENTOS6', 'UXENOS']
# #
## Do not edit below!!! ## Do not edit below!!!
...@@ -80,3 +82,4 @@ FILE_LOG = APP_ROOT + '/log/file' ...@@ -80,3 +82,4 @@ FILE_LOG = APP_ROOT + '/log/file'
# ansible # ansible
ANSIBLE_PLAYBOOK = '/usr/local/bin/ansible-playbook' ANSIBLE_PLAYBOOK = '/usr/local/bin/ansible-playbook'
...@@ -272,9 +272,6 @@ export default { ...@@ -272,9 +272,6 @@ export default {
rowsPerPage: 10, rowsPerPage: 10,
options: [5, 10, 15, 30, 50, 100] options: [5, 10, 15, 30, 50, 100]
}, },
sort (a, b) {
return (a - b)
},
messages: { messages: {
noData: '<i>warning</i> 데이터가 없습니다.', noData: '<i>warning</i> 데이터가 없습니다.',
noDataAfterFiltering: '<i>warning</i> 검색 결과가 없습니다.' noDataAfterFiltering: '<i>warning</i> 검색 결과가 없습니다.'
...@@ -289,9 +286,6 @@ export default { ...@@ -289,9 +286,6 @@ export default {
rowsPerPage: 10, rowsPerPage: 10,
options: [5, 10, 15, 30, 50, 100] options: [5, 10, 15, 30, 50, 100]
}, },
sort (a, b) {
return (a - b)
},
messages: { messages: {
noData: '<i>warning</i> 데이터가 없습니다.', noData: '<i>warning</i> 데이터가 없습니다.',
noDataAfterFiltering: '<i>warning</i> 검색 결과가 없습니다.' noDataAfterFiltering: '<i>warning</i> 검색 결과가 없습니다.'
...@@ -306,9 +300,6 @@ export default { ...@@ -306,9 +300,6 @@ export default {
rowsPerPage: 10, rowsPerPage: 10,
options: [5, 10, 15, 30, 50, 100] options: [5, 10, 15, 30, 50, 100]
}, },
sort (a, b) {
return (a - b)
},
messages: { messages: {
noData: '<i>warning</i> 데이터가 없습니다.', noData: '<i>warning</i> 데이터가 없습니다.',
noDataAfterFiltering: '<i>warning</i> 검색 결과가 없습니다.' noDataAfterFiltering: '<i>warning</i> 검색 결과가 없습니다.'
...@@ -319,7 +310,7 @@ export default { ...@@ -319,7 +310,7 @@ export default {
label: '배포일', label: '배포일',
field: 'logname', field: 'logname',
filter: true, filter: true,
sort: true, sort: 'date',
width: '100px' width: '100px'
}, },
{ {
...@@ -341,7 +332,7 @@ export default { ...@@ -341,7 +332,7 @@ export default {
label: '배포일', label: '배포일',
field: 'logname', field: 'logname',
filter: true, filter: true,
sort: true, sort: 'date',
width: '100px' width: '100px'
}, },
{ {
...@@ -369,7 +360,7 @@ export default { ...@@ -369,7 +360,7 @@ export default {
label: '배포일', label: '배포일',
field: 'logname', field: 'logname',
filter: true, filter: true,
sort: true, sort: 'date',
width: '100px' width: '100px'
}, },
{ {
......
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
</template> </template>
<script> <script>
import { API_URL, selectOS } from 'config' import { API_URL } from 'config'
import { Toast } from 'quasar' import { Toast } from 'quasar'
import { required, minLength } from 'vuelidate/lib/validators' import { required, minLength } from 'vuelidate/lib/validators'
...@@ -194,7 +194,7 @@ export default { ...@@ -194,7 +194,7 @@ export default {
{'label': 'PM', value: 'PM'}, {'label': 'PM', value: 'PM'},
{'label': 'VM', value: 'VM'} {'label': 'VM', value: 'VM'}
], ],
selectOS: selectOS, selectOS: [],
selectDPT: [] selectDPT: []
} }
}, },
...@@ -246,6 +246,23 @@ export default { ...@@ -246,6 +246,23 @@ export default {
this.$refs.name.focus() this.$refs.name.focus()
}) })
}, },
getSupportedOS: function () {
const url = API_URL + '/machine/supported_os'
const token = this.$store.state.token
const headers = {
headers: {
'Authorization': `Bearer ${token}`
}
}
this.$http.get(url, headers).then(response => {
let self = this
response.body.forEach(function (el) {
self.selectOS.push({'label': el, 'value': el})
})
}, response => {
Toast.create.negative('지원 OS 정보 수신 실패')
})
},
getDPT: function () { getDPT: function () {
const url = API_URL + '/machine/dpt' const url = API_URL + '/machine/dpt'
const token = this.$store.state.token const token = this.$store.state.token
...@@ -265,8 +282,9 @@ export default { ...@@ -265,8 +282,9 @@ export default {
} }
}, },
mounted () { mounted () {
if (!this.$store.state.login) { this.$router.push('/') } // if (!this.$store.state.login) { this.$router.push('/') }
this.getSupportedOS()
this.getDPT() this.getDPT()
this.$refs.name.focus() this.$refs.name.focus()
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
</template> </template>
<script> <script>
import { API_URL, selectOS, POLLING_INTERVAL } from 'config' import { API_URL, POLLING_INTERVAL } from 'config'
import { Loading, Dialog, Toast } from 'quasar' import { Loading, Dialog, Toast } from 'quasar'
function show (options) { function show (options) {
...@@ -347,7 +347,7 @@ export default { ...@@ -347,7 +347,7 @@ export default {
os: { os: {
type: 'radio', type: 'radio',
model: row.os, model: row.os,
items: selectOS items: this.getSupportedOS()
}, },
header11: { header11: {
type: 'heading', type: 'heading',
...@@ -469,6 +469,24 @@ export default { ...@@ -469,6 +469,24 @@ export default {
] ]
}) })
}, },
getSupportedOS: function () {
const url = API_URL + '/machine/supported_os'
const token = this.$store.state.token
const headers = {
headers: {
'Authorization': `Bearer ${token}`
}
}
let selectOS = []
this.$http.get(url, headers).then(response => {
response.body.forEach(function (el) {
selectOS.push({'label': el, 'value': el})
})
}, response => {
Toast.create.negative('지원 OS 정보 수신 실패')
})
return selectOS
},
getDPT: function () { getDPT: function () {
const url = API_URL + '/machine/dpt' const url = API_URL + '/machine/dpt'
const token = this.$store.state.token const token = this.$store.state.token
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
</template> </template>
<script> <script>
import { API_URL, selectOS } from 'config' import { API_URL } from 'config'
import { Toast } from 'quasar' import { Toast } from 'quasar'
export default { export default {
...@@ -112,13 +112,9 @@ export default { ...@@ -112,13 +112,9 @@ export default {
data: function () { data: function () {
return { return {
qtabs: 'os-tab', qtabs: 'os-tab',
selectOS: selectOS, selectOS: this.getSupportedOS(),
machines: [], machines: [],
allSelected: false, allSelected: false,
oses: {
'JESSIE': [],
'CENTOS7': []
},
form: { form: {
os: '', os: '',
machines: [] machines: []
...@@ -192,12 +188,28 @@ export default { ...@@ -192,12 +188,28 @@ export default {
Toast.create.negative('서버 정보 수신 실패') Toast.create.negative('서버 정보 수신 실패')
return return
}) })
},
getSupportedOS: function () {
const url = API_URL + '/machine/supported_os'
const token = this.$store.state.token
const headers = {
headers: {
'Authorization': `Bearer ${token}`
}
}
let selectOS = []
this.$http.get(url, headers).then(response => {
response.body.forEach(function (el) {
selectOS.push({'label': el, 'value': el})
})
}, response => {
Toast.create.negative('지원 OS 정보 수신 실패')
})
return selectOS
} }
}, },
mounted: function () { mounted: function () {
if (!this.$store.state.login) { this.$router.push('/') } this.getSupportedOS()
},
destroyed: function () {
} }
} }
</script> </script>
......
...@@ -65,6 +65,12 @@ ...@@ -65,6 +65,12 @@
<div class="card-content"> <div class="card-content">
<div class="card" v-for="(machines, section) in this.sections"> <div class="card" v-for="(machines, section) in this.sections">
<div class="card-title"> <div class="card-title">
<input
type="checkbox"
@click="toggle"
v-model="groupSelected"
v-bind:value="section"
>
그룹 {{ section }} 그룹 {{ section }}
</div> </div>
<div class="card-content"> <div class="card-content">
...@@ -140,7 +146,7 @@ export default { ...@@ -140,7 +146,7 @@ export default {
tags: [], tags: [],
sections: {'b': []}, sections: {'b': []},
machines: [], machines: [],
allSelected: false, groupSelected: false,
playlog: '', playlog: '',
dLog: {}, dLog: {},
sameAsBefore: 0, sameAsBefore: 0,
...@@ -192,12 +198,14 @@ export default { ...@@ -192,12 +198,14 @@ export default {
}, },
toggle: function () { toggle: function () {
let selected = [] let selected = []
if (this.allSelected) { console.log(this.groupSelected)
if (this.groupSelected) {
this.machines.forEach(function (machine) { this.machines.forEach(function (machine) {
selected.push(machine) selected.push(machine)
}) })
} }
this.form.machines = selected this.form.machines = selected
console.log(selected)
}, },
radioVal: function () { radioVal: function () {
// get tags when app is selected. // get tags when app is selected.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment