infra: vr healthcheck (#428)

Fixes #362

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Abhishek Kumar 2020-06-24 13:30:59 +05:30 committed by Rohit Yadav
parent 029e13c37d
commit 10e6d59bc1
4 changed files with 207 additions and 3 deletions

View File

@ -61,6 +61,7 @@ export default {
case 'Started':
case 'Download Complete':
case 'Successfully Installed':
case 'True':
status = 'success'
break
case 'Disabled':
@ -69,6 +70,7 @@ export default {
case 'Stopped':
case 'Declined':
case 'Disconnected':
case 'False':
status = 'error'
break
case 'Migrating':

View File

@ -30,6 +30,10 @@ export default {
}, {
name: 'nics',
component: () => import('@/views/network/NicsTable.vue')
}, {
name: 'router.health.checks',
show: (record, route, user) => { return ['Running'].includes(record.state) && ['Admin'].includes(user.roletype) },
component: () => import('@views/infra/routers/RouterHealthCheck.vue')
}],
actions: [
{
@ -81,7 +85,7 @@ export default {
icon: 'drag',
label: 'label.action.migrate.router',
dataView: true,
show: (record) => { return record.state === 'Running' },
show: (record, store) => { return ['Running'].includes(record.state) && ['Admin'].includes(store.userInfo.roletype) },
args: ['virtualmachineid', 'hostid'],
mapping: {
virtualmachineid: {
@ -94,7 +98,7 @@ export default {
icon: 'reconciliation',
label: 'label.action.run.diagnostics',
dataView: true,
show: (record) => { return record.state === 'Running' },
show: (record, store) => { return ['Running'].includes(record.state) && ['Admin'].includes(store.userInfo.roletype) },
args: ['targetid', 'type', 'ipaddress', 'params'],
mapping: {
targetid: {
@ -111,7 +115,7 @@ export default {
icon: 'download',
label: 'label.action.get.diagnostics',
dataView: true,
show: (record) => { return record.state === 'Running' },
show: (record, store) => { return ['Running'].includes(record.state) && ['Admin'].includes(store.userInfo.roletype) },
args: ['targetid', 'files'],
mapping: {
targetid: {

View File

@ -224,6 +224,7 @@
"label.action.revert.snapshot": "Revert to Snapshot",
"label.action.revert.snapshot.processing": "Reverting to Snapshot...",
"label.action.router.health.checks": "Get health checks result",
"label.perform.fresh.checks":"Perform fresh checks",
"label.action.run.diagnostics": "Run Diagnostics",
"label.action.secure.host": "Provision Host Security Keys",
"label.action.share.template": "Update Template Permissions",
@ -2206,6 +2207,7 @@
"message.action.restore.instance": "Please confirm that you want to restore this instance.",
"message.action.revert.snapshot": "Please confirm that you want to revert the owning volume to this snapshot.",
"message.action.router.health.checks": "Health checks result will be fetched from router.",
"message.action.router.health.checks.disabled.warning": "Please enable router health checks.",
"message.action.secure.host": "This will restart the host agent and libvirtd process after applying new X509 certificates, please confirm?",
"message.action.settings.warning.vm.running": "Please stop the virtual machine to access settings",
"message.action.settings.warning.vm.started": "Virtual machine has been started. It needs to be stopped to access settings",

View File

@ -0,0 +1,196 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
<template>
<a-spin :spinning="loading">
<a-alert
v-if="!routerHealthChecksEnabled"
banner
:message="$t('message.action.router.health.checks.disabled.warning')" />
<div v-else>
<a-button :disabled="!('getRouterHealthCheckResults' in $store.getters.apis)" type="primary" icon="download" style="width: 100%; margin-bottom: 15px" @click="showGetHelathCheck">
{{ $t('label.action.router.health.checks') }}
</a-button>
<a-table
style="overflow-y: auto"
:columns="columns"
:dataSource="healthChecks"
:pagination="false"
:rowKey="record => record.checkname"
size="large">
<template slot="status" slot-scope="record">
<status class="status" :text="record.success === true ? 'True' : 'False'" displayText />
</template>
</a-table>
<a-modal
v-if="'getRouterHealthCheckResults' in $store.getters.apis"
style="top: 20px;"
:title="$t('label.action.router.health.checks')"
:visible="showGetHealthChecksForm"
:closable="true"
@ok="handleGetHealthChecksSubmit"
@cancel="onCloseGetHealthChecksForm"
centered>
<a-spin :spinning="loading">
<a-form
:form="form"
@submit="handleGetHealthChecksSubmit"
layout="vertical">
<a-form-item>
<span slot="label">
{{ $t('label.perform.fresh.checks') }}
<a-tooltip :title="apiParams.performfreshchecks.description">
<a-icon type="info-circle" style="color: rgba(0,0,0,.45)" />
</a-tooltip>
</span>
<a-switch
v-decorator="[$t('performfreshchecks')]"
:placeholder="apiParams.performfreshchecks.description" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</div>
</a-spin>
</template>
<script>
import { api } from '@/api'
import Status from '@/components/widgets/Status'
export default {
name: 'RouterHealthCheck',
components: {
Status
},
props: {
resource: {
type: Object,
required: true
}
},
data () {
return {
routerHealthChecksEnabled: false,
healthChecks: [],
loading: false,
columns: [
{
title: this.$t('label.router.health.check.name'),
dataIndex: 'checkname'
},
{
title: this.$t('label.type'),
dataIndex: 'checktype'
},
{
title: this.$t('label.router.health.check.success'),
scopedSlots: { customRender: 'status' }
},
{
title: this.$t('label.router.health.check.last.updated'),
dataIndex: 'lastupdated'
},
{
title: this.$t('label.details'),
dataIndex: 'details'
}
],
showGetHealthChecksForm: false
}
},
beforeCreate () {
this.form = this.$form.createForm(this)
this.apiConfigParams = (this.$store.getters.apis.getRouterHealthCheckResults && this.$store.getters.apis.getRouterHealthCheckResults.params) || []
this.apiParams = {}
this.apiConfigParams.forEach(param => {
this.apiParams[param.name] = param
})
},
watch: {
resource: function (newItem, oldItem) {
this.updateResource(newItem)
}
},
mounted () {
this.updateResource(this.resource)
},
methods: {
updateResource (resource) {
if (!resource) {
return
}
this.resource = resource
if (!resource.id) {
return
}
this.checkConfigurationAndGetHealthChecks()
},
showGetHelathCheck () {
this.showGetHealthChecksForm = true
},
onCloseGetHealthChecksForm () {
this.showGetHealthChecksForm = false
},
handleGetHealthChecksSubmit (e) {
e.preventDefault()
this.form.validateFields((err, values) => {
if (err) {
return
}
this.onCloseGetHealthChecksForm()
this.checkConfigurationAndGetHealthChecks(values.performfreshchecks)
})
},
checkConfigurationAndGetHealthChecks (performFreshChecks) {
var params = { name: 'router.health.checks.enabled' }
this.loading = true
api('listConfigurations', params).then(json => {
this.routerHealthChecksEnabled = false
if (json.listconfigurationsresponse.configuration !== null) {
var config = json.listconfigurationsresponse.configuration[0]
if (config && config.name === params.name) {
this.routerHealthChecksEnabled = config.value === 'true'
}
}
}).catch(error => {
this.$notifyError(error)
}).finally(f => {
this.loading = false
if (this.routerHealthChecksEnabled) {
this.getHealthChecks(performFreshChecks)
}
})
},
getHealthChecks (performFreshChecks) {
var params = { routerid: this.resource.id }
if (performFreshChecks) {
params.performfreshchecks = performFreshChecks
}
this.loading = true
api('getRouterHealthCheckResults', params).then(json => {
this.healthChecks = json.getrouterhealthcheckresultsresponse.routerhealthchecks.healthchecks
}).catch(error => {
this.$notifyError(error)
}).finally(f => {
this.loading = false
})
}
}
}
</script>