mirror of https://github.com/apache/cloudstack.git
Allow list of source CIDRs
This commit is contained in:
parent
6dd7e71e2e
commit
fcbddd8b01
|
|
@ -402,20 +402,16 @@ public class NetrisServiceImpl implements NetrisService, Configurable {
|
|||
String trafficType = baseNetworkRule.getTrafficType().toUpperCase(Locale.ROOT);
|
||||
String sourcePrefix;
|
||||
String destinationPrefix;
|
||||
boolean result = true;
|
||||
List<String> sourceCidrs = baseNetworkRule.getSourceCidrList();
|
||||
int index = 1;
|
||||
for (String sourceCidr : sourceCidrs) {
|
||||
if ("INGRESS".equals(trafficType)) {
|
||||
sourcePrefix = baseNetworkRule.getSourceCidrList().get(0);
|
||||
if (NetUtils.isValidIp4Cidr(sourcePrefix)) {
|
||||
destinationPrefix = network.getCidr();
|
||||
sourcePrefix = sourceCidr;
|
||||
destinationPrefix = NetUtils.isValidIp4Cidr(sourcePrefix) ? network.getCidr() : network.getIp6Cidr();
|
||||
} else {
|
||||
destinationPrefix = network.getIp6Cidr();
|
||||
}
|
||||
} else {
|
||||
destinationPrefix = baseNetworkRule.getSourceCidrList().get(0);
|
||||
if (NetUtils.isValidIp4Cidr(destinationPrefix)) {
|
||||
sourcePrefix = network.getCidr();
|
||||
} else {
|
||||
sourcePrefix = network.getIp6Cidr();
|
||||
}
|
||||
destinationPrefix = sourceCidr;
|
||||
sourcePrefix = NetUtils.isValidIp4Cidr(destinationPrefix) ? network.getCidr() : network.getIp6Cidr();
|
||||
}
|
||||
String srcPort;
|
||||
String dstPort;
|
||||
|
|
@ -430,6 +426,9 @@ public class NetrisServiceImpl implements NetrisService, Configurable {
|
|||
"null".equals(srcPort) ? 1 : Integer.parseInt(srcPort),
|
||||
"null".equals(dstPort) ? 65535 : Integer.parseInt(dstPort), baseNetworkRule.getProtocol());
|
||||
String aclName = String.format("V%s-N%s-ACL%s", vpcId, networkId, rule.getBaseRule().getRuleId());
|
||||
if (sourceCidrs.size() > 1) {
|
||||
aclName = aclName + "-" + index++;
|
||||
}
|
||||
String netrisAclName = NetrisResourceObjectUtils.retrieveNetrisResourceObjectName(cmd, NetrisResourceObjectUtils.NetrisObjectType.ACL, aclName);
|
||||
cmd.setNetrisAclName(netrisAclName);
|
||||
cmd.setReason(rule.getReason());
|
||||
|
|
@ -437,7 +436,9 @@ public class NetrisServiceImpl implements NetrisService, Configurable {
|
|||
cmd.setIcmpType(baseNetworkRule.getIcmpType());
|
||||
}
|
||||
NetrisAnswer answer = sendNetrisCommand(cmd, zoneId);
|
||||
return answer.getResult();
|
||||
result = result && answer.getResult();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getPrefix(String prefix) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue