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
This commit is contained in:
zhangke 2022-03-10 11:28:08 +08:00 committed by Jingwei.Zhang
parent 1dcdd82a06
commit 05b28c9344
7 changed files with 39 additions and 48 deletions

View File

@ -36,7 +36,7 @@ export class HypervisorDetail extends Base {
const info = [
{
title: t('Hostname'),
dataIndex: 'hypervisor_hostname',
dataIndex: 'service_host',
},
{
title: t('Type'),

View File

@ -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,
};

View File

@ -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 });

View File

@ -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 });

View File

@ -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',

View File

@ -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'),

View File

@ -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);