diff --git a/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx b/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx
index 4dccb319..4408f4a1 100644
--- a/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx
+++ b/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx
@@ -264,8 +264,10 @@ export default class CreateIronic extends StepAction {
// // delete_on_termination: deleteType === 1,
// };
let hasIp = false;
+ const { selectedRows: securityGroupSelectedRows = [] } =
+ securityGroup || {};
const server = {
- security_groups: securityGroup.selectedRows.map((it) => ({
+ security_groups: securityGroupSelectedRows.map((it) => ({
name: it.id,
})),
name,
diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/ConfirmStep/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/ConfirmStep/index.jsx
index 9ff2a41c..ab98ee81 100644
--- a/src/pages/compute/containers/Instance/actions/StepCreate/ConfirmStep/index.jsx
+++ b/src/pages/compute/containers/Instance/actions/StepCreate/ConfirmStep/index.jsx
@@ -89,8 +89,7 @@ export default class ConfirmStep extends Base {
getSecurityGroups() {
const { context } = this.props;
- const { securityGroup } = context;
- const { selectedRows } = securityGroup;
+ const { securityGroup: { selectedRows = [] } = {} } = context;
const values = selectedRows.map((it) => it.name);
return values;
// return values.join(
);
diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx
index f44de979..ef028301 100644
--- a/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx
+++ b/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx
@@ -159,6 +159,9 @@ export default class NetworkStep extends Base {
get formItems() {
const { networkSelectRows = [], subnets, initValue = [] } = this.state;
const showNetworks = networkSelectRows.length > 0;
+ const showSecurityGroups =
+ networkSelectRows.length &&
+ networkSelectRows.every((it) => it.port_security_enabled);
return [
{
name: 'networkSelect',
@@ -229,7 +232,8 @@ export default class NetworkStep extends Base {
),
backendPageStore: this.securityGroupStore,
extraParams: { project_id: this.currentProjectId },
- required: true,
+ hidden: !showSecurityGroups,
+ required: showSecurityGroups,
isMulti: true,
header: (
diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx
index a8e1a1d6..f2992c14 100644
--- a/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx
+++ b/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx
@@ -297,8 +297,10 @@ class StepCreate extends StepAction {
// rootVolume.disk_bus = 'ide';
// dataVolumes[0].disk_bus = 'virtio';
}
+ const { selectedRows: securityGroupSelectedRows = [] } =
+ securityGroup || {};
const server = {
- security_groups: securityGroup.selectedRows.map((it) => ({
+ security_groups: securityGroupSelectedRows.map((it) => ({
name: it.id,
})),
name,
diff --git a/src/pages/network/containers/Network/Detail/Detail.jsx b/src/pages/network/containers/Network/Detail/Detail.jsx
index f60230ea..99ce1b60 100644
--- a/src/pages/network/containers/Network/Detail/Detail.jsx
+++ b/src/pages/network/containers/Network/Detail/Detail.jsx
@@ -62,6 +62,11 @@ export default class BaseDetail extends Base {
dataIndex: 'qos_policy_id',
render: (data) => data || '-',
},
+ {
+ label: t('Port Security Enabled'),
+ dataIndex: 'port_security_enabled',
+ valueRender: 'yesNo',
+ },
];
return {
title: t('Base Info'),
diff --git a/src/pages/network/containers/Network/actions/CreateNetwork.jsx b/src/pages/network/containers/Network/actions/CreateNetwork.jsx
index 2d9dfe0c..37b28d3e 100644
--- a/src/pages/network/containers/Network/actions/CreateNetwork.jsx
+++ b/src/pages/network/containers/Network/actions/CreateNetwork.jsx
@@ -73,6 +73,7 @@ export default class CreateNetwork extends ModalAction {
ip_version: 'ipv4',
disable_gateway: false,
more: false,
+ port_security_enabled: true,
};
}
@@ -91,6 +92,7 @@ export default class CreateNetwork extends ModalAction {
host_routes,
description,
mtu,
+ port_security_enabled,
...rest
} = values;
@@ -103,6 +105,7 @@ export default class CreateNetwork extends ModalAction {
description,
availability_zone_hints: [availableZone],
mtu,
+ port_security_enabled,
};
const networkAdminPageData = {
@@ -303,6 +306,12 @@ export default class CreateNetwork extends ModalAction {
type: 'check',
hidden: !this.isSystemAdmin,
},
+ {
+ name: 'port_security_enabled',
+ label: t('Port Security Enabled'),
+ type: 'switch',
+ required: true,
+ },
// {
// name: 'admin_state_up',
// label: t('Enable Admin State'),
diff --git a/src/pages/network/containers/Network/actions/Edit.jsx b/src/pages/network/containers/Network/actions/Edit.jsx
index 59a8d2ee..3b29d925 100644
--- a/src/pages/network/containers/Network/actions/Edit.jsx
+++ b/src/pages/network/containers/Network/actions/Edit.jsx
@@ -17,6 +17,7 @@ import { ModalAction } from 'containers/Action';
import globalNetworkStore from 'stores/neutron/network';
import checkPolicy, { checkPolicyRule } from 'resources/policy';
import globalRootStore from 'stores/root';
+import { getYesNoList } from 'utils/index';
@inject('rootStore')
@observer
@@ -49,8 +50,8 @@ export default class Edit extends ModalAction {
onSubmit = (values) => {
const { item: { id } = {} } = this.props;
- const { name, description, ...rest } = values;
- const data = { name, description };
+ const { name, description, port_security_enabled, ...rest } = values;
+ const data = { name, description, port_security_enabled };
if (this.isSystemAdmin) {
data.shared = rest.shared;
}
@@ -85,18 +86,15 @@ export default class Edit extends ModalAction {
{
name: 'shared',
label: t('Shared'),
- type: 'select',
+ type: 'radio',
hidden: !this.isSystemAdmin,
- options: [
- {
- label: t('Yes'),
- value: true,
- },
- {
- label: t('No'),
- value: false,
- },
- ],
+ options: getYesNoList(),
+ },
+ {
+ name: 'port_security_enabled',
+ label: t('Port Security Enabled'),
+ type: 'switch',
+ required: true,
},
{
name: 'router:external',
diff --git a/src/pages/network/containers/VirtualAdapter/Detail/index.jsx b/src/pages/network/containers/VirtualAdapter/Detail/index.jsx
index 5f3cb66e..bac7764d 100644
--- a/src/pages/network/containers/VirtualAdapter/Detail/index.jsx
+++ b/src/pages/network/containers/VirtualAdapter/Detail/index.jsx
@@ -74,9 +74,9 @@ export default class VirtualAdapterDetail extends Base {
dataIndex: 'network_id',
},
{
- title: t('Port Security'),
+ title: t('Port Security Enabled'),
dataIndex: 'port_security_enabled',
- render: (data) => (data ? t('Open') : t('Close')),
+ valueRender: 'yesNo',
},
{
title: t('Mac Address'),
@@ -98,12 +98,12 @@ export default class VirtualAdapterDetail extends Base {
},
{
title: t('Fixed IPs'),
- key: 'fixed ips',
+ key: 'fixed_ips',
component: FixedIPs,
},
{
title: t('Security Groups'),
- key: 'security groups',
+ key: 'security_groups',
component: SecurityGroups,
},
{
@@ -112,6 +112,10 @@ export default class VirtualAdapterDetail extends Base {
component: AllowedAddressPair,
},
];
+ const { port_security_enabled } = this.detailData;
+ if (!port_security_enabled) {
+ return tabs.filter((it) => it.key !== 'security_groups');
+ }
return tabs;
}
diff --git a/src/pages/network/containers/VirtualAdapter/actions/ManageSecurityGroup.jsx b/src/pages/network/containers/VirtualAdapter/actions/ManageSecurityGroup.jsx
index 1fb9de70..c907c5b3 100644
--- a/src/pages/network/containers/VirtualAdapter/actions/ManageSecurityGroup.jsx
+++ b/src/pages/network/containers/VirtualAdapter/actions/ManageSecurityGroup.jsx
@@ -35,7 +35,7 @@ export default class ManageSecurityGroup extends ModalAction {
static policy = 'update_port:port_security_enabled';
- static allowed = () => Promise.resolve(true);
+ static allowed = (item) => Promise.resolve(item.port_security_enabled);
init() {
this.securityGroupStore = new SecurityGroupStore();