@Override public PortForwardingRuleVO doInTransaction(TransactionStatus status) throws NetworkRuleConflictException { PortForwardingRuleVO newRule = new PortForwardingRuleVO(rule.getXid(), rule.getSourceIpAddressId(), rule.getSourcePortStart(), rule.getSourcePortEnd(), dstIpFinal, rule.getDestinationPortStart(), rule.getDestinationPortEnd(), rule.getProtocol().toLowerCase(), networkId, accountId, domainId, vmId); _firewallMgr.createRuleForAllCidrs(ipAddrId, caller, rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getProtocol(), null, null, newRule.getId(), networkId);
_firewallMgr.validateFirewallRule(caller, ipAddress, rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getProtocol(), Purpose.PortForwarding, FirewallRuleType.User, networkId, rule.getTrafficType()); if ((rule.getDestinationPortEnd() - rule.getDestinationPortStart()) != (rule.getSourcePortEnd() - rule.getSourcePortStart())) { throw new InvalidParameterValueException("Source port and destination port ranges should be of equal sizes."); if (rule.getSourcePortStart().intValue() != rule.getSourcePortEnd().intValue() || rule.getDestinationPortStart() != rule.getDestinationPortEnd()) { validatePortRange = true; if (rule.getSourcePortEnd().intValue() != rule.getDestinationPortEnd()) { throw new InvalidParameterValueException("Private port end should be equal to public port end");
response.setProtocol(fwRule.getProtocol()); response.setPublicStartPort(Integer.toString(fwRule.getSourcePortStart())); response.setPublicEndPort(Integer.toString(fwRule.getSourcePortEnd())); List<String> cidrs = ApiDBUtils.findFirewallSourceCidrs(fwRule.getId()); response.setCidrList(StringUtils.join(cidrs, ","));