From 05b28c9344dc09225f04818a710ce224b0977fa7 Mon Sep 17 00:00:00 2001 From: zhangke Date: Thu, 10 Mar 2022 11:28:08 +0800 Subject: [PATCH] fix: the host name should show service.host instead of hypervisor_hostname, pages involved are as follows: Management Platform: Virtual Machine Manager, Virtual Machine Manager Details, Migration, Live Migration Change-Id: Icb8b9ed8bb61fb6c715193f1c48bd1c2da45316f --- .../Hypervisors/Hypervisor/Detail/index.jsx | 2 +- .../Hypervisors/Hypervisor/index.jsx | 2 +- .../Instance/actions/LiveMigrate.jsx | 24 +++---------------- .../containers/Instance/actions/Migrate.jsx | 24 +++---------------- .../actions/StepCreate/SystemStep/index.jsx | 22 +++++++++++++++-- src/resources/hypervisor.jsx | 4 ++-- src/stores/nova/hypervisor.js | 9 +++++++ 7 files changed, 39 insertions(+), 48 deletions(-) diff --git a/src/pages/compute/containers/Hypervisors/Hypervisor/Detail/index.jsx b/src/pages/compute/containers/Hypervisors/Hypervisor/Detail/index.jsx index dd755f1f..1fa5338b 100644 --- a/src/pages/compute/containers/Hypervisors/Hypervisor/Detail/index.jsx +++ b/src/pages/compute/containers/Hypervisors/Hypervisor/Detail/index.jsx @@ -36,7 +36,7 @@ export class HypervisorDetail extends Base { const info = [ { title: t('Hostname'), - dataIndex: 'hypervisor_hostname', + dataIndex: 'service_host', }, { title: t('Type'), diff --git a/src/pages/compute/containers/Hypervisors/Hypervisor/index.jsx b/src/pages/compute/containers/Hypervisors/Hypervisor/index.jsx index 9026e605..45312b5b 100644 --- a/src/pages/compute/containers/Hypervisors/Hypervisor/index.jsx +++ b/src/pages/compute/containers/Hypervisors/Hypervisor/index.jsx @@ -46,7 +46,7 @@ export class Hypervisors extends Base { const columns = [...hypervisorColumns]; columns[0] = { title: t('ID/Name'), - dataIndex: 'hypervisor_hostname', + dataIndex: 'service_host', routeName: 'hypervisorDetailAdmin', isLink: true, }; diff --git a/src/pages/compute/containers/Instance/actions/LiveMigrate.jsx b/src/pages/compute/containers/Instance/actions/LiveMigrate.jsx index 95d6fcdf..f9f42f4a 100644 --- a/src/pages/compute/containers/Instance/actions/LiveMigrate.jsx +++ b/src/pages/compute/containers/Instance/actions/LiveMigrate.jsx @@ -22,7 +22,6 @@ import { isPaused, } from 'resources/instance'; import globalHypervisorStore from 'stores/nova/hypervisor'; -import globalComputeHostStore from 'stores/nova/compute-host'; import { hypervisorColumns, hypervisorFilters } from 'resources/hypervisor'; @inject('rootStore') @@ -36,7 +35,6 @@ export default class LiveMigrate extends ModalAction { this.store = globalServerStore; this.hypervisorStore = globalHypervisorStore; this.getHypervisors(); - this.getComputeHosts(); } get name() { @@ -61,26 +59,13 @@ export default class LiveMigrate extends ModalAction { return it.hypervisor_type !== 'ironic'; }) .map((it) => { - const computeHost = this.computeHosts.find( - (host) => host.host === it.hypervisor_hostname - ); return { ...it, key: it.id, - name: it.hypervisor_hostname, - computeHost, }; }); } - getComputeHosts() { - globalComputeHostStore.fetchList({ binary: 'nova-compute' }); - } - - get computeHosts() { - return globalComputeHostStore.list.data || []; - } - get tips() { return t( 'Choose a host to live migrate instance to. If not selected, the scheduler will auto select target host.' @@ -128,9 +113,7 @@ export default class LiveMigrate extends ModalAction { label: t('Target Compute Host'), type: 'select-table', data: this.hypervisors, - isLoading: - this.hypervisorStore.list.isLoading && - globalComputeHostStore.list.isLoading, + isLoading: this.hypervisorStore.list.isLoading, isMulti: false, extra: t( 'If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.' @@ -138,8 +121,7 @@ export default class LiveMigrate extends ModalAction { filterParams: hypervisorFilters, columns: hypervisorColumns, disabledFunc: (record) => - record.name === host || - (record.computeHost && record.computeHost.status === 'disabled'), + record.service_host === host || record.status !== 'enabled', }, { name: 'option', @@ -157,7 +139,7 @@ export default class LiveMigrate extends ModalAction { } = values; const { id } = this.item; const body = { - host: host ? host.selectedRows[0].name : null, + host: host ? host.selectedRows[0].service_host : null, block_migration: blockMigrate || 'auto', }; return this.store.migrateLive({ id, body }); diff --git a/src/pages/compute/containers/Instance/actions/Migrate.jsx b/src/pages/compute/containers/Instance/actions/Migrate.jsx index ec2587e4..846e11fb 100644 --- a/src/pages/compute/containers/Instance/actions/Migrate.jsx +++ b/src/pages/compute/containers/Instance/actions/Migrate.jsx @@ -22,7 +22,6 @@ import { isStopped, } from 'resources/instance'; import globalHypervisorStore from 'stores/nova/hypervisor'; -import globalComputeHostStore from 'stores/nova/compute-host'; import { hypervisorColumns, hypervisorFilters } from 'resources/hypervisor'; @inject('rootStore') @@ -36,7 +35,6 @@ export default class LiveMigrate extends ModalAction { this.store = globalServerStore; this.hypervisorStore = globalHypervisorStore; this.getHypervisors(); - this.getComputeHosts(); } get name() { @@ -61,26 +59,13 @@ export default class LiveMigrate extends ModalAction { return it.hypervisor_type !== 'ironic'; }) .map((it) => { - const computeHost = this.computeHosts.find( - (host) => host.host === it.hypervisor_hostname - ); return { ...it, key: it.id, - name: it.hypervisor_hostname, - computeHost, }; }); } - getComputeHosts() { - globalComputeHostStore.fetchList({ binary: 'nova-compute' }); - } - - get computeHosts() { - return globalComputeHostStore.list.data || []; - } - get tips() { return t( 'Choose a host to migrate instance to. If not selected, the scheduler will auto select target host.' @@ -125,9 +110,7 @@ export default class LiveMigrate extends ModalAction { label: t('Target Compute Host'), type: 'select-table', data: this.hypervisors, - isLoading: - this.hypervisorStore.list.isLoading && - globalComputeHostStore.list.isLoading, + isLoading: this.hypervisorStore.list.isLoading, isMulti: false, extra: t( 'If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.' @@ -135,8 +118,7 @@ export default class LiveMigrate extends ModalAction { filterParams: hypervisorFilters, columns: hypervisorColumns, disabledFunc: (record) => - record.name === host || - (record.computeHost && record.computeHost.status === 'disabled'), + record.service_host === host || record.status !== 'enabled', }, ]; } @@ -147,7 +129,7 @@ export default class LiveMigrate extends ModalAction { let body = null; if (selectedRows.length > 0) { body = { - host: selectedRows[0].name, + host: selectedRows[0]?.service_host, }; } return this.store.migrate({ id, body }); diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx index 208d9576..e1b919f1 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/SystemStep/index.jsx @@ -35,6 +35,24 @@ export class SystemStep extends Base { this.getServerGroups(); } + get hypervisorColumns() { + const columns = [...hypervisorColumns]; + columns[0] = { + title: t('Hostname'), + dataIndex: 'hypervisor_hostname', + }; + return columns; + } + + get hypervisorFilters() { + const columns = [...hypervisorFilters]; + columns[0] = { + label: t('Hostname'), + name: 'hypervisor_hostname', + }; + return columns; + } + get title() { return 'SystemStep'; } @@ -283,8 +301,8 @@ export class SystemStep extends Base { extra: t( 'You can manually specify a physical node to create an instance.' ), - columns: hypervisorColumns, - filterParams: hypervisorFilters, + columns: this.hypervisorColumns, + filterParams: this.hypervisorFilters, }, { name: 'serverGroup', diff --git a/src/resources/hypervisor.jsx b/src/resources/hypervisor.jsx index a055deab..b657a974 100644 --- a/src/resources/hypervisor.jsx +++ b/src/resources/hypervisor.jsx @@ -19,7 +19,7 @@ import { Tooltip } from 'antd'; export const hypervisorColumns = [ { title: t('Hostname'), - dataIndex: 'hypervisor_hostname', + dataIndex: 'service_host', }, { title: t('Type'), @@ -84,7 +84,7 @@ export const hypervisorColumns = [ export const hypervisorFilters = [ { label: t('Hostname'), - name: 'hypervisor_hostname', + name: 'service_host', }, { label: t('Type'), diff --git a/src/stores/nova/hypervisor.js b/src/stores/nova/hypervisor.js index 363f293a..51b6960d 100644 --- a/src/stores/nova/hypervisor.js +++ b/src/stores/nova/hypervisor.js @@ -34,6 +34,15 @@ export class HypervisorStore extends Base { return true; } + get mapper() { + return (data) => { + return { + ...data, + service_host: data?.service?.host || '', + }; + }; + } + // get mapper() { // return (item) => { // item.vcpus_used_percent = ((item.vcpus_used / item.vcpus) * 100).toFixed(2);