fix: fix the magnum quotai and other infos
1. support volume quota when create cluster instance 2. fix subnet reseting when fixed network changed 3. show project id of cluster template if switch to administrator platform Closes-Bug: #2000141 Change-Id: I6cb59e9f74c76cb3d0901e89c9bf01d48a85d747
This commit is contained in:
parent
d48aca89a4
commit
e03182b072
@ -56,6 +56,11 @@ export class ClusterTemplateDetail extends Base {
|
|||||||
dataIndex: 'updated_at',
|
dataIndex: 'updated_at',
|
||||||
valueRender: 'toLocalTime',
|
valueRender: 'toLocalTime',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t('Project ID'),
|
||||||
|
dataIndex: 'project_id',
|
||||||
|
hidden: !this.isAdminPage,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,10 @@ export class StepNetwork extends Base {
|
|||||||
master_lb_enabled,
|
master_lb_enabled,
|
||||||
floating_ip_enabled,
|
floating_ip_enabled,
|
||||||
} = {},
|
} = {},
|
||||||
|
context: {
|
||||||
|
fixedNetwork: fixedNetworkContext,
|
||||||
|
fixedSubnet: fixedSubnetContext,
|
||||||
|
},
|
||||||
} = this.props;
|
} = this.props;
|
||||||
values = {
|
values = {
|
||||||
network_driver,
|
network_driver,
|
||||||
@ -111,13 +115,13 @@ export class StepNetwork extends Base {
|
|||||||
floating_ip_enabled,
|
floating_ip_enabled,
|
||||||
};
|
};
|
||||||
if (fixed_network) {
|
if (fixed_network) {
|
||||||
values.fixedNetwork = {
|
values.fixedNetwork = fixedNetworkContext || {
|
||||||
selectedRowKeys: [fixed_network],
|
selectedRowKeys: [fixed_network],
|
||||||
selectedRows: [fixedNetwork],
|
selectedRows: [fixedNetwork],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (fixed_subnet) {
|
if (fixed_subnet) {
|
||||||
values.fixedSubnet = {
|
values.fixedSubnet = fixedSubnetContext || {
|
||||||
selectedRowKeys: [fixed_subnet],
|
selectedRowKeys: [fixed_subnet],
|
||||||
selectedRows: [fixedSubnet],
|
selectedRows: [fixedSubnet],
|
||||||
};
|
};
|
||||||
@ -128,7 +132,15 @@ export class StepNetwork extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
const { extra: { network_driver } = {} } = this.props;
|
const {
|
||||||
|
extra: { network_driver, fixed_subnet, fixedSubnet } = {},
|
||||||
|
context: { fixedSubnet: fixedSubnetContext },
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
const initSubnet = fixedSubnetContext || {
|
||||||
|
selectedRowKeys: fixed_subnet ? [fixed_subnet] : [],
|
||||||
|
selectedRows: fixedSubnet ? [fixedSubnet] : [],
|
||||||
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -204,10 +216,10 @@ export class StepNetwork extends Base {
|
|||||||
onChange: (value) => {
|
onChange: (value) => {
|
||||||
this.updateContext({
|
this.updateContext({
|
||||||
fixedNetwork: value,
|
fixedNetwork: value,
|
||||||
});
|
fixedSubnet: {
|
||||||
this.updateFormValue('fixedSubnet', {
|
selectedRowKeys: [],
|
||||||
selectedRowKeys: [],
|
selectedRows: [],
|
||||||
selectedRows: [],
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -223,6 +235,12 @@ export class StepNetwork extends Base {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
columns: subnetColumns,
|
columns: subnetColumns,
|
||||||
|
initValue: initSubnet,
|
||||||
|
onChange: (value) => {
|
||||||
|
this.updateContext({
|
||||||
|
fixedSubnet: value,
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'dns_nameserver',
|
name: 'dns_nameserver',
|
||||||
|
@ -33,6 +33,13 @@ export class ClusterTemplates extends Base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFetchParams = (params) => {
|
||||||
|
return {
|
||||||
|
...params,
|
||||||
|
shouldFetchProject: this.isAdminPage,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
get actionConfigs() {
|
get actionConfigs() {
|
||||||
if (this.isAdminPage) {
|
if (this.isAdminPage) {
|
||||||
return actionConfigs.actionConfigsAdmin;
|
return actionConfigs.actionConfigsAdmin;
|
||||||
|
@ -185,6 +185,11 @@ export class StepNetworks extends Base {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
columns: subnetColumns,
|
columns: subnetColumns,
|
||||||
|
onChange: (value) => {
|
||||||
|
this.updateContext({
|
||||||
|
fixedSubnet: value,
|
||||||
|
});
|
||||||
|
},
|
||||||
initValue: initSubnet,
|
initValue: initSubnet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -74,15 +74,22 @@ export class StepNodeSpec extends Base {
|
|||||||
|
|
||||||
get defaultValue() {
|
get defaultValue() {
|
||||||
const {
|
const {
|
||||||
context: { clusterTemplate = {}, keypair, masterFlavor, flavor } = {},
|
context: {
|
||||||
|
clusterTemplate = {},
|
||||||
|
keypair,
|
||||||
|
masterFlavor,
|
||||||
|
flavor,
|
||||||
|
master_count,
|
||||||
|
node_count,
|
||||||
|
} = {},
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { selectedRows = [] } = clusterTemplate;
|
const { selectedRows = [] } = clusterTemplate;
|
||||||
const { master_flavor_id, flavor_id, keypair_id, selfKeypair } =
|
const { master_flavor_id, flavor_id, keypair_id, selfKeypair } =
|
||||||
selectedRows[0] || {};
|
selectedRows[0] || {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
master_count: 1,
|
master_count: master_count || 1,
|
||||||
node_count: 1,
|
node_count: node_count || 1,
|
||||||
masterFlavor: masterFlavor || {
|
masterFlavor: masterFlavor || {
|
||||||
selectedRowKeys: master_flavor_id ? [master_flavor_id] : [],
|
selectedRowKeys: master_flavor_id ? [master_flavor_id] : [],
|
||||||
selectedRows: this.masterFlavors.filter(
|
selectedRows: this.masterFlavors.filter(
|
||||||
|
@ -131,6 +131,7 @@ export class StepCreate extends StepAction {
|
|||||||
title: t('Clusters'),
|
title: t('Clusters'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { newNodes } = this.getNodesInput();
|
||||||
const {
|
const {
|
||||||
instances = {},
|
instances = {},
|
||||||
cores = {},
|
cores = {},
|
||||||
@ -138,7 +139,7 @@ export class StepCreate extends StepAction {
|
|||||||
} = toJS(this.projectStore.novaQuota) || {};
|
} = toJS(this.projectStore.novaQuota) || {};
|
||||||
const instanceQuotaInfo = {
|
const instanceQuotaInfo = {
|
||||||
...instances,
|
...instances,
|
||||||
add: quotaError ? 0 : 1,
|
add: quotaError ? 0 : newNodes,
|
||||||
name: 'instance',
|
name: 'instance',
|
||||||
title: t('Instance'),
|
title: t('Instance'),
|
||||||
type: 'line',
|
type: 'line',
|
||||||
@ -161,11 +162,21 @@ export class StepCreate extends StepAction {
|
|||||||
type: 'line',
|
type: 'line',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { volumes } = toJS(this.projectStore.cinderQuota) || {};
|
||||||
|
const volumeQuotaInfo = {
|
||||||
|
...volumes,
|
||||||
|
add: quotaError ? 0 : newNodes,
|
||||||
|
name: 'volume',
|
||||||
|
title: t('Volume'),
|
||||||
|
type: 'line',
|
||||||
|
};
|
||||||
|
|
||||||
const quotaInfo = [
|
const quotaInfo = [
|
||||||
clusterQuotaInfo,
|
clusterQuotaInfo,
|
||||||
instanceQuotaInfo,
|
instanceQuotaInfo,
|
||||||
cpuQuotaInfo,
|
cpuQuotaInfo,
|
||||||
ramQuotaInfo,
|
ramQuotaInfo,
|
||||||
|
volumeQuotaInfo,
|
||||||
];
|
];
|
||||||
|
|
||||||
return quotaInfo;
|
return quotaInfo;
|
||||||
@ -184,15 +195,25 @@ export class StepCreate extends StepAction {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getNodesInput() {
|
||||||
|
const { data = {} } = this.state;
|
||||||
|
const { node_count = 0, master_count = 0 } = data;
|
||||||
|
const newNodes = node_count + master_count;
|
||||||
|
return {
|
||||||
|
newNodes,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
checkInstanceQuota() {
|
checkInstanceQuota() {
|
||||||
const { quotaLoading } = this.state;
|
const { quotaLoading } = this.state;
|
||||||
if (quotaLoading) {
|
if (quotaLoading) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
const { newNodes } = this.getNodesInput();
|
||||||
const { instances = {} } = this.projectStore.novaQuota || {};
|
const { instances = {} } = this.projectStore.novaQuota || {};
|
||||||
const { left = 0 } = instances;
|
const { left = 0 } = instances;
|
||||||
if (left === 0) {
|
if (left !== -1 && left < newNodes) {
|
||||||
return this.getQuotaMessage(1, instances, t('Instance'));
|
return this.getQuotaMessage(newNodes, instances, t('Instance'));
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -247,11 +268,26 @@ export class StepCreate extends StepAction {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkVolumeQuota() {
|
||||||
|
const { quotaLoading } = this.state;
|
||||||
|
if (quotaLoading) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
const { newNodes } = this.getNodesInput();
|
||||||
|
const { volumes } = toJS(this.projectStore.cinderQuota) || {};
|
||||||
|
const { left = 0 } = volumes;
|
||||||
|
if (left !== -1 && left < newNodes) {
|
||||||
|
return this.getQuotaMessage(newNodes, volumes, t('Volume'));
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
checkQuotaInput() {
|
checkQuotaInput() {
|
||||||
const clusterMsg = this.checkClusterQuota();
|
const clusterMsg = this.checkClusterQuota();
|
||||||
const instanceMsg = this.checkInstanceQuota();
|
const instanceMsg = this.checkInstanceQuota();
|
||||||
const flavorMsg = this.checkFlavorQuota();
|
const flavorMsg = this.checkFlavorQuota();
|
||||||
const error = clusterMsg || instanceMsg || flavorMsg;
|
const volumeMsg = this.checkVolumeQuota();
|
||||||
|
const error = clusterMsg || instanceMsg || flavorMsg || volumeMsg;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
this.status = 'success';
|
this.status = 'success';
|
||||||
this.errorMsg = '';
|
this.errorMsg = '';
|
||||||
@ -304,6 +340,7 @@ export class StepCreate extends StepAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
...rest,
|
||||||
name: values.name,
|
name: values.name,
|
||||||
labels: {
|
labels: {
|
||||||
...requestLabels,
|
...requestLabels,
|
||||||
@ -311,31 +348,14 @@ export class StepCreate extends StepAction {
|
|||||||
auto_scaling_enabled: `${!!auto_scaling_enabled}`,
|
auto_scaling_enabled: `${!!auto_scaling_enabled}`,
|
||||||
},
|
},
|
||||||
cluster_template_id: clusterTemplate.selectedRowKeys[0],
|
cluster_template_id: clusterTemplate.selectedRowKeys[0],
|
||||||
...rest,
|
keypair: (keypair && keypair.selectedRowKeys[0]) || null,
|
||||||
|
master_flavor_id:
|
||||||
|
(masterFlavor && masterFlavor.selectedRowKeys[0]) || null,
|
||||||
|
flavor_id: (flavor && flavor.selectedRowKeys[0]) || null,
|
||||||
|
fixed_network: (!newNetwork && fixedNetwork.selectedRowKeys[0]) || null,
|
||||||
|
fixed_subnet: (!newNetwork && fixedSubnet.selectedRowKeys[0]) || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (keypair) {
|
|
||||||
data.keypair = keypair.selectedRowKeys[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (masterFlavor) {
|
|
||||||
data.master_flavor_id = masterFlavor.selectedRowKeys[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flavor) {
|
|
||||||
data.flavor_id = flavor.selectedRowKeys[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newNetwork && fixedNetwork) {
|
|
||||||
const { selectedRowKeys = [] } = fixedNetwork;
|
|
||||||
data.fixed_network = selectedRowKeys[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newNetwork && fixedSubnet) {
|
|
||||||
const { selectedRowKeys = [] } = fixedSubnet;
|
|
||||||
data.fixed_subnet = selectedRowKeys[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.store.create(data);
|
return this.store.create(data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,12 @@ export const getBaseSimpleFlavorColumns = (self) => [
|
|||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
routeName: self ? self.getRouteName('flavorDetail') : '',
|
routeName: self ? self.getRouteName('flavorDetail') : '',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t('Project ID/Name'),
|
||||||
|
dataIndex: 'project_name',
|
||||||
|
isHideable: true,
|
||||||
|
hidden: !self.isAdminPage,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: t('Architecture'),
|
title: t('Architecture'),
|
||||||
dataIndex: 'architecture',
|
dataIndex: 'architecture',
|
||||||
|
@ -78,10 +78,14 @@ export class ClusterTemplatesStore extends Base {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async listDidFetch(items) {
|
async listDidFetch(items, _, filters) {
|
||||||
if (!items.length) return items;
|
if (!items.length) return items;
|
||||||
|
const { shouldFetchProject } = filters;
|
||||||
|
const newData = await this.listDidFetchProject(items, {
|
||||||
|
all_projects: shouldFetchProject,
|
||||||
|
});
|
||||||
const { keypairs = [] } = (await client.nova.keypairs.list()) || {};
|
const { keypairs = [] } = (await client.nova.keypairs.list()) || {};
|
||||||
return items.map((it) => {
|
return newData.map((it) => {
|
||||||
const keypair = keypairs.find((k) => k?.keypair?.name === it.keypair_id);
|
const keypair = keypairs.find((k) => k?.keypair?.name === it.keypair_id);
|
||||||
if (keypair) {
|
if (keypair) {
|
||||||
it.selfKeypair = true;
|
it.selfKeypair = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user