Skip to content

Commit 5e56e43

Browse files
author
Mice Xia
committed
fix CLOUDSTACK-2930, exception while applying ACL rule with protocol as ALL.
1) change UI, disable startport and endport when protocol=All 2) validate parameters for API createNetworkACL
1 parent 18163ea commit 5e56e43

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ private void validateNetworkACLItem(Integer portStart, Integer portEnd, List<Str
294294
throw new InvalidParameterValueException("Start port can't be bigger than end port");
295295
}
296296

297+
// start port and end port must be null for protocol = 'all'
298+
if ((portStart != null || portEnd != null ) && protocol != null && protocol.equalsIgnoreCase("all"))
299+
throw new InvalidParameterValueException("start port and end port must be null if protocol = 'all'");
300+
297301
if (sourceCidrList != null) {
298302
for (String cidr: sourceCidrList){
299303
if (!NetUtils.isValidCIDR(cidr)){

ui/scripts/vpc.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@
9797
name != 'icmpcode' &&
9898
name != 'cidrlist';
9999
});
100+
var $portFields = $inputs.filter(function() {
101+
var name = $(this).attr('name');
102+
return $.inArray(name, [
103+
'startport',
104+
'endport'
105+
]) > -1;
106+
});
100107

101108
var $protocolinput = args.$form.find('td input');
102109
var $protocolFields = $protocolinput.filter(function(){
@@ -124,6 +131,10 @@
124131
$icmpFields.hide();
125132
$icmpFields.parent().find('label.error').hide();
126133
$protocolFields.hide().removeClass('required');
134+
if ($(this).val() == 'all'){
135+
$portFields.attr('disabled', 'disabled');
136+
$portFields.hide();
137+
}
127138
}
128139
});
129140

@@ -216,11 +227,11 @@
216227

217228

218229

219-
if((args.data.protocol == 'tcp' || args.data.protocol == 'udp' || args.data.protocol == 'all') && (args.data.startport=="" || args.data.startport == undefined)){
230+
if((args.data.protocol == 'tcp' || args.data.protocol == 'udp') && (args.data.startport=="" || args.data.startport == undefined)){
220231
cloudStack.dialog.notice({message:_l('Start Port or End Port value should not be blank')});
221232
$(window).trigger('cloudStack.fullRefresh');
222233
}
223-
else if((args.data.protocol == 'tcp' || args.data.protocol == 'udp' || args.data.protocol == 'all') && (args.data.endport=="" || args.data.endport == undefined)){
234+
else if((args.data.protocol == 'tcp' || args.data.protocol == 'udp') && (args.data.endport=="" || args.data.endport == undefined)){
224235
cloudStack.dialog.notice({message:_l('Start Port or End Port value should not be blank')});
225236
$(window).trigger('cloudStack.fullRefresh');
226237
}

0 commit comments

Comments
 (0)