| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <template>
- <detail
- :on-manager="onManager"
- :data="itemData"
- :base-info="baseInfo"
- :extra-info="extraInfo"
- resource="hosts"
- status-module="host" />
- </template>
- <script>
- import {
- getUserTagColumn,
- getExtTagColumn,
- } from '@/utils/common/detailColumn'
- import { getEnabledTableColumn, getCopyWithContentTableColumn, getPublicScopeTableColumn } from '@/utils/common/tableColumn'
- import { sizestr } from '@/utils/utils'
- import i18n from '@/locales'
- import WindowsMixin from '@/mixins/windows'
- import { getMaintenanceTableColumn } from '../utils/columns'
- const storageType = {
- rotate: i18n.t('compute.text_47'),
- ssd: i18n.t('compute.text_48'),
- hybrid: i18n.t('compute.text_578'),
- }
- export default {
- name: 'PhysicalmachineDetail',
- mixins: [WindowsMixin],
- props: {
- hostInfo: {
- type: Object,
- required: true,
- },
- onManager: {
- type: Function,
- required: true,
- },
- columns: Array,
- },
- data () {
- return {
- itemData: {
- status: 'ready',
- host_status: 'ready',
- enabled: true,
- },
- storageColumns: [
- {
- field: 'adapter',
- title: this.$t('compute.text_579'),
- width: 70,
- },
- {
- field: 'driver',
- title: this.$t('compute.text_378'),
- width: 140,
- },
- {
- field: 'model',
- title: this.$t('compute.text_580'),
- showOverflow: 'ellipsis',
- minWidth: 200,
- },
- {
- field: 'rotate',
- title: this.$t('compute.text_175'),
- width: 80,
- formatter: ({ cellValue, row }) => {
- if (cellValue === true) return this.$t('compute.text_581')
- return 'SSD'
- },
- },
- {
- field: 'size',
- title: this.$t('compute.text_397'),
- formatter: ({ cellValue, row }) => {
- return sizestr(cellValue, 'M', 1024)
- },
- },
- ],
- hostColumns: [
- {
- field: 'mac',
- title: this.$t('compute.text_385'),
- showOverflow: 'ellipsis',
- width: 200,
- formatter: ({ cellValue, row }) => {
- return cellValue || '-'
- },
- },
- {
- field: 'nic_type',
- width: 100,
- title: this.$t('compute.text_175'),
- },
- {
- field: 'ip_addr',
- title: 'IP',
- width: 160,
- formatter: ({ cellValue, row }) => {
- if (row.ip_addr) {
- return row.ip_addr + '/' + row.masklen
- } else {
- return '-'
- }
- },
- },
- {
- field: 'net',
- title: this.$t('compute.text_106'),
- },
- {
- field: 'wire',
- title: this.$t('compute.text_844'),
- },
- {
- field: 'rate',
- title: this.$t('compute.text_584'),
- },
- {
- field: 'link_up',
- title: this.$t('compute.netif_linkup_status'),
- },
- ],
- baseInfo: [
- getUserTagColumn({ onManager: this.onManager, resource: 'host', columns: () => this.columns, tipName: this.$t('compute.text_112') }),
- getExtTagColumn({ onManager: this.onManager, resource: 'host', columns: () => this.columns, tipName: this.$t('compute.text_112') }),
- getPublicScopeTableColumn({ vm: this, resource: 'hosts' }),
- getEnabledTableColumn(),
- getMaintenanceTableColumn(),
- {
- field: 'access_ip',
- title: 'IP',
- },
- getCopyWithContentTableColumn({
- field: 'server',
- title: this.$t('compute.text_602'),
- hideField: true,
- slotCallback: row => {
- if (!row.server) return '-'
- return [
- <a onClick={ () => this.$emit('tab-change', 'baremetal-list') }>{row.server}</a>,
- ]
- },
- }),
- getCopyWithContentTableColumn({ field: 'server', title: this.$t('compute.text_602') }),
- {
- field: 'access_mac',
- title: this.$t('compute.text_385'),
- formatter: ({ cellValue, row }) => {
- return cellValue || '-'
- },
- },
- {
- field: 'schedtags',
- title: this.$t('compute.text_311'),
- formatter: ({ cellValue, row }) => {
- if (row.schedtags && row.schedtags.length > 0) {
- const schedtags = row.schedtags.map(v => v.name)
- return schedtags.join(',')
- }
- return '-'
- },
- },
- {
- field: 'version',
- title: this.$t('compute.text_585'),
- },
- {
- field: 'kvm_module',
- title: this.$t('compute.text_586'),
- formatter: ({ cellData, row }) => {
- const kvmModuleMap = {
- 'kvm-intel': 'Intel',
- 'kvm-amd': 'AMD',
- unsupport: this.$t('compute.text_587'),
- }
- if (!row.sys_info) return '-'
- return kvmModuleMap[row.sys_info.kvm_module] || '-'
- },
- },
- {
- field: 'cdrom_boot',
- title: this.$t('compute.text_588'),
- formatter: ({ cellData, row }) => {
- let ret = '-'
- if (row.ipmi_info && row.ipmi_info.cdrom_boot === 'true') {
- ret = this.$t('compute.text_589')
- } else {
- ret = this.$t('compute.text_587')
- }
- return ret
- },
- },
- {
- field: 'isolated_device_count',
- title: this.$t('compute.passthrough_device_count'),
- slots: {
- default: ({ row }, h) => {
- return [
- <a onClick={ () => this.$emit('tab-change', 'gpu-list') }>{row.isolated_device_count || 0}</a>,
- ]
- },
- },
- },
- ],
- extraInfo: [
- {
- title: this.$t('compute.text_590'),
- items: [
- {
- field: 'manufacture',
- title: this.$t('compute.text_228'),
- formatter: ({ cellValue, row }) => {
- return ((row.sys_info || {}).manufacture) || '-'
- },
- },
- {
- field: 'model',
- title: this.$t('compute.text_580'),
- formatter: ({ cellValue, row }) => {
- return ((row.sys_info || {}).model) || '-'
- },
- },
- getCopyWithContentTableColumn({
- field: 'sn',
- title: this.$t('compute.text_591'),
- }),
- ],
- },
- {
- title: 'CPU',
- items: [
- {
- field: 'cpu_count',
- title: this.$t('compute.text_592'),
- formatter: ({ cellValue }) => {
- return cellValue + this.$t('compute.text_167')
- },
- },
- {
- field: 'node_count',
- title: this.$t('compute.text_593'),
- formatter: ({ cellValue }) => {
- return cellValue + this.$t('compute.text_200')
- },
- },
- {
- field: 'cpu_cmtbound',
- title: this.$t('compute.text_594'),
- },
- {
- field: 'cpu_commit_rate',
- title: this.$t('compute.text_859'),
- },
- {
- field: 'cpu_desc',
- title: this.$t('compute.text_596'),
- },
- ],
- },
- {
- title: this.$t('compute.text_369'),
- items: [
- {
- field: 'mem_size',
- title: this.$t('compute.text_397'),
- formatter: ({ cellValue, row }) => {
- return sizestr(cellValue, 'M', 1024)
- },
- },
- {
- field: 'mem_reserved',
- title: this.$t('compute.text_598'),
- formatter: ({ cellValue, row }) => {
- return sizestr(cellValue, 'M', 1024)
- },
- },
- {
- field: 'mem_cmtbound',
- title: this.$t('compute.text_594'),
- },
- {
- field: 'mem_commit_rate',
- title: this.$t('compute.text_859'),
- },
- ],
- },
- {
- title: this.$t('compute.text_99'),
- items: [
- {
- field: 'storage_size',
- title: this.$t('compute.text_397'),
- // formatter: ({ cellValue, row }) => {
- // return sizestr(cellValue, 'M', 1024)
- // },
- slots: {
- default: ({ row }, h) => {
- return [
- <p>{ this.$t('compute.text_1321', { num: sizestr(row.storage_size, 'M', 1024) }) }</p>,
- ]
- },
- },
- },
- {
- field: 'storage_type',
- title: this.$t('compute.text_175'),
- formatter: ({ cellValue, row }) => {
- return storageType[cellValue]
- },
- },
- {
- field: 'storage_commit_rate',
- title: this.$t('compute.text_859'),
- },
- {
- field: 'storage_waste',
- title: this.$t('compute.text_599'),
- formatter: ({ cellValue, row }) => {
- return sizestr(cellValue || 0, 'M', 1024)
- },
- },
- {
- title: '',
- field: 'storage_info',
- slots: {
- default: ({ row }, h) => {
- return [
- <vxe-grid class="mb-2" data={ row.storage_info } columns={ this.storageColumns } />,
- ]
- },
- },
- },
- ],
- },
- {
- title: this.$t('compute.text_600'),
- field: 'nic_info',
- slots: {
- default: ({ row }, h) => {
- if (!row || !row.nic_info) {
- return []
- }
- const nics = row.nic_info.filter(
- (o) => {
- return o.nic_type !== 'ipmi'
- },
- )
- return [
- <vxe-grid class="mb-2" data={ nics } columns={ this.hostColumns } />,
- ]
- },
- },
- },
- {
- title: 'BMC' + this.$t('compute.text_600'),
- field: 'nic_info',
- slots: {
- default: ({ row }, h) => {
- if (!row || !row.nic_info) {
- return []
- }
- const nics = row.nic_info.filter(
- (o) => {
- return o.nic_type === 'ipmi'
- },
- )
- return [
- <vxe-grid class="mb-2" data={ nics } columns={ this.hostColumns } />,
- ]
- },
- },
- },
- ],
- }
- },
- created () {
- this.updateDetailData()
- },
- methods: {
- updateDetailData () {
- const hostManager = new this.$Manager('hosts')
- hostManager.get({ id: this.hostInfo.id })
- .then((res) => {
- this.itemData = res.data
- })
- },
- },
- }
- </script>
|