fix: Improve quota in magnum service
1.Show quota info by template when create cluster if did not select flavor or master flavor 2.Remove link of keypair if the keypair is not belong to the current user Change-Id: Ic6faebfa21b92479b982770a00046a54882f21d8
This commit is contained in:
parent
a2d170e285
commit
228ccff07b
@ -132,7 +132,7 @@ export class BaseDetail extends Base {
|
||||
}
|
||||
|
||||
get specCard() {
|
||||
const { image_id, keypair_id, flavor_id, master_flavor_id } =
|
||||
const { image_id, keypair_id, flavor_id, master_flavor_id, selfKeypair } =
|
||||
this.detailData;
|
||||
const imageUrl = image_id
|
||||
? this.getLinkRender('imageDetail', image_id, {
|
||||
@ -140,11 +140,12 @@ export class BaseDetail extends Base {
|
||||
})
|
||||
: '-';
|
||||
|
||||
const keypairUrl = keypair_id
|
||||
? this.getLinkRender('keypairDetail', keypair_id, {
|
||||
id: keypair_id,
|
||||
})
|
||||
: '-';
|
||||
const keypairUrl =
|
||||
keypair_id && selfKeypair
|
||||
? this.getLinkRender('keypairDetail', keypair_id, {
|
||||
id: keypair_id,
|
||||
})
|
||||
: keypair_id || '-';
|
||||
|
||||
const flavorUrl = flavor_id
|
||||
? this.getLinkRender('flavorDetail', flavor_id, {
|
||||
@ -169,7 +170,7 @@ export class BaseDetail extends Base {
|
||||
hidden: this.isAdminPage,
|
||||
},
|
||||
{
|
||||
label: t('Flavor ID'),
|
||||
label: t('Node Flavor ID'),
|
||||
content: flavorUrl,
|
||||
},
|
||||
{
|
||||
|
@ -107,8 +107,8 @@ export class StepCreate extends StepAction {
|
||||
const requestLabels = {};
|
||||
if (additionalLabels) {
|
||||
additionalLabels.forEach((item) => {
|
||||
const labelKey = item.value.key.toLowerCase().trim();
|
||||
const labelValue = item.value.value.toLowerCase().trim();
|
||||
const labelKey = item.value.key;
|
||||
const labelValue = item.value.value;
|
||||
requestLabels[labelKey] = labelValue;
|
||||
});
|
||||
}
|
||||
|
@ -81,6 +81,11 @@ export class StepInfo extends Base {
|
||||
},
|
||||
],
|
||||
columns: getBaseTemplateColumns(this),
|
||||
onChange: (value) => {
|
||||
this.updateContext({
|
||||
clusterTemplate: value,
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
@ -65,26 +65,40 @@ export class StepNodeSpec extends Base {
|
||||
};
|
||||
|
||||
get defaultValue() {
|
||||
const { context: { clusterTemplate = {} } = {} } = this.props;
|
||||
const { selectedRows = [] } = clusterTemplate;
|
||||
const { master_flavor_id, flavor_id } = selectedRows[0] || {};
|
||||
|
||||
return {
|
||||
master_count: 1,
|
||||
node_count: 1,
|
||||
masterFlavor: {
|
||||
selectedRowKeys: [master_flavor_id],
|
||||
},
|
||||
flavor: { selectedRowKeys: [flavor_id] },
|
||||
};
|
||||
}
|
||||
|
||||
get formItems() {
|
||||
const { context: { clusterTemplate = {} } = {} } = this.props;
|
||||
const { selectedRows = [] } = clusterTemplate;
|
||||
const { master_flavor_id, flavor_id, keypair_id } = selectedRows[0] || {};
|
||||
const { master_flavor_id, flavor_id, keypair_id, selfKeypair } =
|
||||
selectedRows[0] || {};
|
||||
const { initKeyPair } = this.state;
|
||||
const templateHasSelfKeypair = keypair_id && selfKeypair;
|
||||
const templateInitKeypair = {
|
||||
selectedRowKeys: [keypair_id],
|
||||
};
|
||||
|
||||
return [
|
||||
{
|
||||
name: 'keypair',
|
||||
label: t('Keypair'),
|
||||
type: 'select-table',
|
||||
required: !keypair_id,
|
||||
required: !templateHasSelfKeypair,
|
||||
data: this.keypairs,
|
||||
initValue: initKeyPair,
|
||||
initValue:
|
||||
initKeyPair || (templateHasSelfKeypair && templateInitKeypair),
|
||||
isLoading: this.keyPairStore.list.isLoading,
|
||||
header: getKeyPairHeader(this),
|
||||
tip: t(
|
||||
|
@ -15,6 +15,7 @@ import { toJS } from 'mobx';
|
||||
import { StepAction } from 'src/containers/Action';
|
||||
import globalClustersStore from 'src/stores/magnum/clusters';
|
||||
import globalProjectStore from 'stores/keystone/project';
|
||||
import globalFlavorStore from 'stores/nova/flavor';
|
||||
import { getGiBValue } from 'utils';
|
||||
import { message as $message } from 'antd';
|
||||
import StepInfo from './StepInfo';
|
||||
@ -85,6 +86,10 @@ export class StepCreate extends StepAction {
|
||||
return this.props.rootStore.checkEndpoint('cinder');
|
||||
}
|
||||
|
||||
get flavors() {
|
||||
return toJS(globalFlavorStore.list.data) || [];
|
||||
}
|
||||
|
||||
get showQuota() {
|
||||
return true;
|
||||
}
|
||||
@ -179,6 +184,20 @@ export class StepCreate extends StepAction {
|
||||
return '';
|
||||
}
|
||||
|
||||
get templateFlavor() {
|
||||
const { data = {} } = this.state;
|
||||
const { clusterTemplate: { selectedRows = [] } = {} } = data;
|
||||
const { master_flavor_id, flavor_id } = selectedRows[0] || {};
|
||||
const masterTemplateFlavor = this.flavors.find(
|
||||
(it) => it.id === master_flavor_id
|
||||
);
|
||||
const workTemplateFlavor = this.flavors.find((it) => it.id === flavor_id);
|
||||
return {
|
||||
masterTemplateFlavor,
|
||||
workTemplateFlavor,
|
||||
};
|
||||
}
|
||||
|
||||
getFlavorInput() {
|
||||
const { data = {} } = this.state;
|
||||
const {
|
||||
@ -187,10 +206,11 @@ export class StepCreate extends StepAction {
|
||||
masterFlavor: { selectedRows: selectedRowsMaster = [] } = {},
|
||||
master_count = 1,
|
||||
} = data;
|
||||
const { vcpus = 0, ram = 0 } = selectedRows[0] || {};
|
||||
const { vcpus = 0, ram = 0 } =
|
||||
selectedRows[0] || this.templateFlavor.workTemplateFlavor || {};
|
||||
const ramGiB = getGiBValue(ram);
|
||||
const { vcpus: vcpusMaster = 0, ram: ramMaster = 0 } =
|
||||
selectedRowsMaster[0] || {};
|
||||
selectedRowsMaster[0] || this.templateFlavor.masterTemplateFlavor || {};
|
||||
const ramGiBMaster = getGiBValue(ramMaster);
|
||||
const newCPU = vcpus * node_count + vcpusMaster * master_count;
|
||||
const newRam = ramGiB * node_count + ramGiBMaster * master_count;
|
||||
@ -262,8 +282,8 @@ export class StepCreate extends StepAction {
|
||||
|
||||
if (additionalLabels) {
|
||||
additionalLabels.forEach((item) => {
|
||||
const labelKey = item.value.key.toLowerCase().trim();
|
||||
const labelValue = item.value.value.toLowerCase().trim();
|
||||
const labelKey = item.value.key;
|
||||
const labelValue = item.value.value;
|
||||
requestLabels[labelKey] = labelValue;
|
||||
});
|
||||
}
|
||||
|
@ -33,10 +33,11 @@ export const getBaseTemplateColumns = (self) => [
|
||||
isHideable: true,
|
||||
dataIndex: 'keypair_id',
|
||||
hidden: self.isAdminPage,
|
||||
render: (value) => {
|
||||
return value
|
||||
? self.getLinkRender('keypairDetail', value, { id: value })
|
||||
: '-';
|
||||
render: (value, row) => {
|
||||
if (value && row.selfKeypair) {
|
||||
return self.getLinkRender('keypairDetail', value, { id: value });
|
||||
}
|
||||
return value || '-';
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -61,6 +61,27 @@ export class ClusterTemplatesStore extends Base {
|
||||
id: data.uuid,
|
||||
});
|
||||
}
|
||||
|
||||
async listDidFetch(items) {
|
||||
if (!items.length) return items;
|
||||
const { keypairs = [] } = (await client.nova.keypairs.list()) || {};
|
||||
return items.map((it) => {
|
||||
const keypair = keypairs.find((k) => k?.keypair?.name === it.keypair_id);
|
||||
if (keypair) {
|
||||
it.selfKeypair = true;
|
||||
}
|
||||
return it;
|
||||
});
|
||||
}
|
||||
|
||||
async detailDidFetch(item) {
|
||||
const { keypairs = [] } = (await client.nova.keypairs.list()) || {};
|
||||
const keypair = keypairs.find((k) => k?.keypair?.name === item.keypair_id);
|
||||
if (keypair) {
|
||||
item.selfKeypair = true;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
const globalClusterTemplateStore = new ClusterTemplatesStore();
|
||||
|
Loading…
Reference in New Issue
Block a user