Skip to content

Commit c92f72b

Browse files
committed
address review comments
1 parent df0b890 commit c92f72b

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd {
5858
private Integer publicEndPort;
5959

6060
@Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the CIDR list to allow traffic from/to. Multiple entries must be separated by a single comma character (,).")
61-
private List<String> cidrlist;
61+
private List<String> cidrList;
6262

6363
@Parameter(name = ApiConstants.ICMP_TYPE, type = CommandType.INTEGER, description = "type of the ICMP message being sent")
6464
private Integer icmpType;
@@ -118,8 +118,8 @@ public void setProtocol(String protocol) {
118118
}
119119

120120
public List<String> getSourceCidrList() {
121-
if (cidrlist != null) {
122-
return cidrlist;
121+
if (cidrList != null) {
122+
return cidrList;
123123
} else {
124124
List<String> oneCidrList = new ArrayList<String>();
125125
oneCidrList.add(NetUtils.ALL_IP4_CIDRS);
@@ -238,8 +238,8 @@ public String getReason() {
238238
return reason;
239239
}
240240

241-
public void setCidrlist(List<String> cidrlist) {
242-
this.cidrlist = cidrlist;
241+
public void setCidrList(List<String> cidrList) {
242+
this.cidrList = cidrList;
243243
}
244244

245245
public void setIcmpType(Integer icmpType) {

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939

4040
@APICommand(name = "importNetworkACL", description = "Imports network ACL rules.",
4141
responseObject = NetworkACLItemResponse.class,
42-
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
42+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
43+
since = "4.22.1")
4344
public class ImportNetworkACLCmd extends BaseAsyncCmd {
4445

4546
// ///////////////////////////////////////////////////
@@ -51,19 +52,17 @@ public class ImportNetworkACLCmd extends BaseAsyncCmd {
5152
type = CommandType.UUID,
5253
entityType = NetworkACLResponse.class,
5354
required = true,
54-
description = "The ID of the network ACL to which the rules will be imported",
55-
since = "4.22.0"
55+
description = "The ID of the network ACL to which the rules will be imported"
5656
)
5757
private Long aclId;
5858

5959
@Parameter(name = ApiConstants.RULES, type = CommandType.MAP, required = true,
60-
description = "Rules param list, id and protocol are must. Example: " +
60+
description = "Rules param list, id and protocol are must. Invalid rules will be discarded. Example: " +
6161
"rules[0].id=101&rules[0].protocol=tcp&rules[0].traffictype=ingress&rules[0].state=active&rules[0].cidrlist=192.168.1.0/24" +
6262
"&rules[0].tags=web&rules[0].aclid=acl-001&rules[0].aclname=web-acl&rules[0].number=1&rules[0].action=allow&rules[0].fordisplay=true" +
6363
"&rules[0].description=allow%20web%20traffic&rules[1].id=102&rules[1].protocol=udp&rules[1].traffictype=egress&rules[1].state=enabled" +
6464
"&rules[1].cidrlist=10.0.0.0/8&rules[1].tags=db&rules[1].aclid=acl-002&rules[1].aclname=db-acl&rules[1].number=2&rules[1].action=deny" +
65-
"&rules[1].fordisplay=false&rules[1].description=deny%20database%20traffic",
66-
since = "4.22.0")
65+
"&rules[1].fordisplay=false&rules[1].description=deny%20database%20traffic")
6766
private Map rules;
6867

6968

@@ -112,7 +111,7 @@ public long getEntityOwnerId() {
112111

113112
@Override
114113
public String getEventType() {
115-
return EventTypes.EVENT_NETWORK_ACL_CREATE;
114+
return EventTypes.EVENT_NETWORK_ACL_IMPORT;
116115
}
117116

118117
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ private NetworkACLItem createACLRuleFromMap(Map<String, Object> ruleMap, long ac
11011101
}
11021102
String action = (String) ruleMap.getOrDefault(ApiConstants.ACTION, "deny");
11031103
String trafficType = (String) ruleMap.getOrDefault(ApiConstants.TRAFFIC_TYPE, NetworkACLItem.TrafficType.Ingress);
1104-
String forDisplay = (String ) ruleMap.getOrDefault(ApiConstants.FOR_DISPLAY, "true");
1104+
String forDisplay = (String) ruleMap.getOrDefault(ApiConstants.FOR_DISPLAY, "true");
11051105

11061106
// Create ACL rule using the service
11071107
CreateNetworkACLCmd cmd = new CreateNetworkACLCmd();
@@ -1122,7 +1122,7 @@ private NetworkACLItem createACLRuleFromMap(Map<String, Object> ruleMap, long ac
11221122
} else if (cidrObj instanceof List) {
11231123
cidrList.addAll((List<String>) cidrObj);
11241124
}
1125-
cmd.setCidrlist(cidrList);
1125+
cmd.setCidrList(cidrList);
11261126
}
11271127

11281128
if (ruleMap.containsKey(ApiConstants.START_PORT)) {

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,6 +3640,7 @@
36403640
"message.move.acl.order.processing": "Moving ACL rule...",
36413641
"message.network.acl.default.allow": "Warning: With this policy all traffic will be allowed through the firewall to this VPC Network Tier. You should consider securing your Network.",
36423642
"message.network.acl.default.deny": "Warning: With this policy all traffic will be denied through the firewall to this VPC Network Tier. In order to allow traffic through you will need to change policies.",
3643+
"message.network.acl.import.note": "Note: Only valid rules from the CSV will be imported. Invalid entries will be discarded.",
36433644
"message.network.addvm.desc": "Please specify the Network that you would like to add this Instance to. A new NIC will be added for this Network.",
36443645
"message.network.description": "Setup Network and traffic.",
36453646
"message.network.error": "Network Error",

ui/src/views/network/ImportNetworkACL.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</a-descriptions>
3737
</div>
3838

39-
<a-form-item name="file" ref="file">
39+
<a-form-item name="file" ref="file">
4040
<template #label>
4141
<tooltip-label :title="$t('label.rules.file')" :tooltip="$t('label.rules.file.to.import')"/>
4242
</template>
@@ -81,6 +81,8 @@
8181
</div>
8282
</a-form-item>
8383

84+
<span>{{ $t('message.network.acl.import.note') }}</span><br/>
85+
8486
<div :span="24" class="action-button">
8587
<a-button class="button-cancel" @click="closeAction">{{ $t('label.cancel') }}</a-button>
8688
<a-button
@@ -99,7 +101,6 @@
99101

100102
<script>
101103
import { ref, reactive, toRaw } from 'vue'
102-
// import { Tag } from 'ant-design-vue'
103104
import { postAPI } from '@/api'
104105
import TooltipLabel from '@/components/widgets/TooltipLabel'
105106
@@ -182,7 +183,7 @@ export default {
182183
this.form = reactive({})
183184
this.rules = reactive({
184185
file: [
185-
{ required: true, message: this.$t('this.$message.error.required.input') },
186+
{ required: true, message: this.$t('message.error.required.input') },
186187
{
187188
validator: this.checkCsvRulesFile,
188189
message: this.$t('label.error.rules.file.import')
@@ -262,7 +263,7 @@ export default {
262263
readCsvFile (file) {
263264
return new Promise((resolve, reject) => {
264265
if (window.FileReader) {
265-
var reader = new FileReader()
266+
const reader = new FileReader()
266267
reader.onload = (event) => {
267268
const text = event.target.result
268269
const lines = text.split('\n').filter(line => line.trim() !== '')

0 commit comments

Comments
 (0)