private boolean revokePortForwardingRuleInternal(long ruleId, Account caller, long userId, boolean apply) { PortForwardingRuleVO rule = _portForwardingDao.findById(ruleId); _firewallMgr.revokeRule(rule, caller, userId, true); boolean success = false; if (apply) { success = applyPortForwardingRules(rule.getSourceIpAddressId(), _ipAddrMgr.RulesContinueOnError.value(), caller); } else { success = true; } return success; }
@Override @ActionEvent(eventType = EventTypes.EVENT_NET_RULE_DELETE, eventDescription = "revoking forwarding rule", async = true) public boolean revokePortForwardingRule(long ruleId, boolean apply) { CallContext ctx = CallContext.current(); Account caller = ctx.getCallingAccount(); PortForwardingRuleVO rule = _portForwardingDao.findById(ruleId); if (rule == null) { throw new InvalidParameterValueException("Unable to find " + ruleId); } _accountMgr.checkAccess(caller, null, true, rule); if (!revokePortForwardingRuleInternal(ruleId, caller, ctx.getCallingUserId(), apply)) { throw new CloudRuntimeException("Failed to delete port forwarding rule"); } return true; }
public PortForwardingRule updatePortForwardingRule(long id, Integer privatePort, Integer privateEndPort, Long virtualMachineId, Ip vmGuestIp, String customId, Boolean forDisplay) { Account caller = CallContext.current().getCallingAccount(); PortForwardingRuleVO rule = _portForwardingDao.findById(id); if (rule == null) { throw new InvalidParameterValueException("Unable to find " + id); rule = _portForwardingDao.findById(id); rule.setState(State.Add); if (privatePort != null) { return _portForwardingDao.findById(id);