fix: Show VGPU info if architecture is heterogeneous_computing

Use placement service to get VGPU infomation

Change-Id: Ib6d8b77f562369f69e9a6aa937abde5ef7099cce
This commit is contained in:
xusongfu 2021-11-25 15:26:57 +08:00
parent ba13abec54
commit 5c3c89c78a
5 changed files with 53 additions and 9 deletions

View File

@ -29,6 +29,9 @@ class PlacementClient extends Base {
{
key: 'inventories',
},
{
key: 'usages',
},
],
},
{

View File

@ -811,7 +811,7 @@
"ICMP Code": "ICMP编码",
"ICMP Type": "ICMP类型",
"ICMP Type/ICMP Code": "类型值/编码值",
"ID": "印度尼西亚",
"ID": "ID",
"ID/Floating IP": "ID/浮动IP",
"ID/Name": "ID/名称",
"IGMP": "",

View File

@ -33,7 +33,7 @@ export class HypervisorDetail extends Base {
}
get detailInfos() {
return [
const info = [
{
title: t('Hostname'),
dataIndex: 'hypervisor_hostname',
@ -71,6 +71,15 @@ export class HypervisorDetail extends Base {
),
},
];
const { vgpus, vgpus_used } = this.store.detail;
if (vgpus) {
info.push({
title: t('VGPU (Core)'),
dataIndex: 'vgpus',
render: () => `${vgpus_used} / ${vgpus}`,
});
}
return info;
}
get tabs() {

View File

@ -118,25 +118,36 @@ export class BaseDetail extends Base {
}
get flavorCard() {
const privateFlavors = toJS(this.detailData.flavor) || [];
const flavor = toJS(this.detailData.flavor) || {};
const { extra_specs = {} } = flavor;
const options = [
{
label: t('Flavor Name'),
content: privateFlavors.original_name,
content: flavor.original_name,
},
{
label: t('RAM'),
content: `${privateFlavors.ram / 1024} GB`,
content: `${flavor.ram / 1024} GB`,
},
{
label: t('VCPUs'),
content: privateFlavors.vcpus,
content: flavor.vcpus,
},
// {
// label: t('Disk'),
// content: `${privateFlavors.disk} GB`,
// content: `${flavor.disk} GB`,
// },
];
if (
extra_specs[':architecture'] === 'heterogeneous_computing' &&
extra_specs[':category'] ===
'visualization_compute_optimized_type_with_gpu'
) {
options.push({
label: t('VGPU'),
content: extra_specs['resources:VGPU'],
});
}
return {
title: t('Flavor Info'),
options,

View File

@ -88,17 +88,38 @@ export class HypervisorStore extends Base {
const result = await this.client.show(id);
const originData = get(result, this.responseKey) || result;
const item = this.mapperBeforeFetchProject(originData);
const inventoriesReuslt = await this.providerClient.inventories.list(id);
const { resource_providers } = await this.providerClient.list({
in_tree: id,
});
const provider = (resource_providers || []).filter((it) => it.uuid !== id);
const promiseArr = [this.providerClient.inventories.list(id)];
if (provider.length) {
// 如果有provider说明有VGPU
promiseArr.push(
this.providerClient.inventories.list(provider[0].uuid),
this.providerClient.usages.list(provider[0].uuid)
);
}
const [inventoriesBase, inventoriesVGPU, usagesVGPU] = await Promise.all(
promiseArr
);
if (item.hypervisor_type !== 'ironic') {
const {
inventories: {
VCPU: { allocation_ratio },
MEMORY_MB: { allocation_ratio: memory_ratio },
},
} = inventoriesReuslt;
} = inventoriesBase;
item.vcpus *= allocation_ratio;
item.memory_mb *= memory_ratio;
}
if (inventoriesVGPU && usagesVGPU) {
const { inventories: { VGPU: { allocation_ratio, total } } = {} } =
inventoriesVGPU;
item.vgpus = allocation_ratio * total;
const { usages: { VGPU } = {} } = usagesVGPU;
item.vgpus_used = VGPU;
}
item.memory_mb_used_gb = getGBValue(item.memory_mb_used);
item.memory_mb_gb = getGBValue(item.memory_mb);
const newItem = await this.detailDidFetch(item, all_projects);