Skip to content

Commit 63cde64

Browse files
committed
Parse csv in UI, prepare payload for import
1 parent 2b7dc78 commit 63cde64

File tree

5 files changed

+402
-12
lines changed

5 files changed

+402
-12
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/network/ImportNetworkACLCmd.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.cloud.exception.ResourceUnavailableException;
3737
import com.cloud.network.vpc.NetworkACLItem;
3838
import com.cloud.user.Account;
39-
import com.cloud.utils.Pair;
4039

4140
@APICommand(name = "importNetworkACL", description = "Imports network ACL rules.",
4241
responseObject = NetworkACLItemResponse.class,

server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626

2727
import javax.inject.Inject;
2828

29-
import com.cloud.dc.DataCenter;
30-
import com.cloud.exception.PermissionDeniedException;
31-
import com.cloud.network.dao.NetrisProviderDao;
32-
import com.cloud.network.dao.NsxProviderDao;
33-
import com.cloud.network.element.NetrisProviderVO;
34-
import com.cloud.network.element.NsxProviderVO;
35-
3629
import org.apache.cloudstack.api.ApiConstants;
3730
import org.apache.cloudstack.api.ApiErrorCode;
3831
import org.apache.cloudstack.api.ServerApiException;
@@ -50,15 +43,21 @@
5043
import org.apache.commons.lang3.StringUtils;
5144
import org.springframework.stereotype.Component;
5245

46+
import com.cloud.dc.DataCenter;
5347
import com.cloud.event.ActionEvent;
5448
import com.cloud.event.EventTypes;
5549
import com.cloud.exception.InvalidParameterValueException;
50+
import com.cloud.exception.PermissionDeniedException;
5651
import com.cloud.exception.ResourceUnavailableException;
5752
import com.cloud.network.Network;
5853
import com.cloud.network.NetworkModel;
5954
import com.cloud.network.Networks;
55+
import com.cloud.network.dao.NetrisProviderDao;
6056
import com.cloud.network.dao.NetworkDao;
6157
import com.cloud.network.dao.NetworkVO;
58+
import com.cloud.network.dao.NsxProviderDao;
59+
import com.cloud.network.element.NetrisProviderVO;
60+
import com.cloud.network.element.NsxProviderVO;
6261
import com.cloud.network.vpc.NetworkACLItem.Action;
6362
import com.cloud.network.vpc.NetworkACLItem.TrafficType;
6463
import com.cloud.network.vpc.dao.NetworkACLDao;
@@ -82,7 +81,6 @@
8281
import com.cloud.utils.db.SearchCriteria.Op;
8382
import com.cloud.utils.exception.CloudRuntimeException;
8483
import com.cloud.utils.net.NetUtils;
85-
import com.google.protobuf.Api;
8684

8785
@Component
8886
public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLService {

ui/public/locales/en.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"label.accounts": "Accounts",
4343
"label.accountstate": "Account state",
4444
"label.accounttype": "Account type",
45-
"label.acl.export": "Export ACL rules",
45+
"label.import": "Import",
46+
"label.acl.import": "Import rules",
47+
"label.acl.export": "Export rules",
4648
"label.acl.id": "ACL ID",
4749
"label.acl.rules": "ACL rules",
4850
"label.acl.reason.description": "Enter the reason behind an ACL rule.",
@@ -251,7 +253,7 @@
251253
"label.activeviewersessions": "Active sessions",
252254
"label.add": "Add",
253255
"label.add.account": "Add Account",
254-
"label.add.acl.rule": "Add ACL rule",
256+
"label.add.acl.rule": "Add rule",
255257
"label.add.acl": "Add ACL",
256258
"label.add.affinity.group": "Add new Affinity Group",
257259
"label.add.backup.schedule": "Add Backup Schedule",
@@ -699,6 +701,7 @@
699701
"label.cron.mode": "Cron mode",
700702
"label.crosszones": "Cross Zones",
701703
"label.csienabled": "CSI Enabled",
704+
"label.csv.preview": "Data preview",
702705
"label.currency": "Currency",
703706
"label.current": "Current",
704707
"label.currentstep": "Current step",
@@ -2895,6 +2898,8 @@
28952898
"message.action.create.snapshot.from.vmsnapshot": "Please confirm that you want to create Snapshot from Instance Snapshot",
28962899
"message.action.create.instance.from.backup": "Please confirm that you want to create a new Instance from the given Backup.<br>Click on configure to edit the parameters for the new Instance before creation.",
28972900
"message.create.instance.from.backup.different.zone": "Creating Instance from Backup on a different Zone. Please ensure that the backup repository is accessible in the selected Zone.",
2901+
"message.csv.empty": "Empty CSV File",
2902+
"message.csv.missing.headers": "Columns are missing from headers in CSV",
28982903
"message.template.ostype.different.from.backup": "Selected Template has a different OS type than the Backup. Please proceed with caution.",
28992904
"message.iso.ostype.different.from.backup": "Selected ISO has a different OS type than the Backup. Please proceed with caution.",
29002905
"message.action.delete.asnrange": "Please confirm the AS range that you want to delete",

ui/src/views/network/AclRulesTab.vue

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
{{ $t('label.add.acl.rule') }}
2929
</a-button>
3030

31+
<a-button type="dashed" @click="handleImportRules" style="width: 100%; margin-right: 10px">
32+
<template #icon><upload-outlined /></template>
33+
{{ $t('label.acl.import') }}
34+
</a-button>
35+
3136
<a-button type="dashed" @click="exportAclList" style="width: 100%">
3237
<template #icon><download-outlined /></template>
3338
{{ $t('label.acl.export') }}
3439
</a-button>
40+
3541
<div class="search-bar">
3642
<a-input-search
3743
style="width: 25vw;float: right;margin-left: 10px; z-index: 8"
@@ -304,6 +310,21 @@
304310
</div>
305311
</a-form>
306312
</a-modal>
313+
314+
<a-modal
315+
v-if="showImportModal"
316+
:visible="showImportModal"
317+
:title="$t('label.acl.import')"
318+
:closable="true"
319+
:maskClosable="false"
320+
:footer="null"
321+
:width="800"
322+
@cancel="closeImportModal">
323+
<import-network-a-c-l
324+
:resource="resource"
325+
@refresh-data="fetchData"
326+
@close-action="closeImportModal" />
327+
</a-modal>
307328
</a-spin>
308329
</template>
309330

@@ -313,13 +334,15 @@ import { getAPI, postAPI } from '@/api'
313334
import draggable from 'vuedraggable'
314335
import { mixinForm } from '@/utils/mixin'
315336
import TooltipButton from '@/components/widgets/TooltipButton'
337+
import ImportNetworkACL from './ImportNetworkACL'
316338
317339
export default {
318340
name: 'AclListRulesTab',
319341
mixins: [mixinForm],
320342
components: {
321343
draggable,
322-
TooltipButton
344+
TooltipButton,
345+
ImportNetworkACL
323346
},
324347
props: {
325348
resource: {
@@ -344,6 +367,7 @@ export default {
344367
tagsModalVisible: false,
345368
tagsLoading: false,
346369
ruleModalVisible: false,
370+
showImportModal: false,
347371
ruleModalTitle: this.$t('label.edit.rule'),
348372
ruleFormMode: 'edit'
349373
}
@@ -788,6 +812,12 @@ export default {
788812
},
789813
capitalise (val) {
790814
return val.toUpperCase()
815+
},
816+
handleImportRules () {
817+
this.showImportModal = true
818+
},
819+
closeImportModal () {
820+
this.showImportModal = false
791821
}
792822
}
793823
}

0 commit comments

Comments
 (0)