@Override public void execute() { Pair<List<? extends FirewallRule>, Integer> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId(), this.getProjectId(), this.isRecursive(), this.listAll()); ListResponse<IpForwardingRuleResponse> response = new ListResponse<IpForwardingRuleResponse>(); List<IpForwardingRuleResponse> ipForwardingResponses = new ArrayList<IpForwardingRuleResponse>(); for (FirewallRule rule : result.first()) { StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); IpForwardingRuleResponse resp = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); if (resp != null) { ipForwardingResponses.add(resp); } } response.setResponses(ipForwardingResponses, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); }
@Override public void execute() throws ResourceUnavailableException { boolean result = true; FirewallRule rule = null; try { CallContext.current().setEventDetails("Rule ID: " + getEntityId()); if (getOpenFirewall()) { result = result && _firewallService.applyIngressFirewallRules(ipAddressId, CallContext.current().getCallingAccount()); } result = result && _rulesService.applyStaticNatRules(ipAddressId, CallContext.current().getCallingAccount()); rule = _entityMgr.findById(FirewallRule.class, getEntityId()); StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); fwResponse.setResponseName(getCommandName()); setResponseObject(fwResponse); } finally { if (!result || rule == null) { if (getOpenFirewall()) { _firewallService.revokeRelatedFirewallRule(getEntityId(), true); } _rulesService.revokeStaticNatRule(getEntityId(), true); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Error in creating IP forwarding rule on the domr"); } } }
@Override public void execute() { final Pair<List<? extends FirewallRule>, Integer> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId(), this.getProjectId(), this.isRecursive(), this.listAll()); final ListResponse<IpForwardingRuleResponse> response = new ListResponse<>(); final List<IpForwardingRuleResponse> ipForwardingResponses = new ArrayList<>(); for (final FirewallRule rule : result.first()) { final StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); final IpForwardingRuleResponse resp = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); if (resp != null) { ipForwardingResponses.add(resp); } } response.setResponses(ipForwardingResponses, result.second()); response.setResponseName(getCommandName()); this.setResponseObject(response); }
@Override public void execute() throws ResourceUnavailableException { boolean result = true; FirewallRule rule = null; try { CallContext.current().setEventDetails("Rule ID: " + getEntityId()); if (getOpenFirewall()) { result = result && _firewallService.applyIngressFirewallRules(ipAddressId, CallContext.current().getCallingAccount()); } result = result && _rulesService.applyStaticNatRules(ipAddressId, CallContext.current().getCallingAccount()); rule = _entityMgr.findById(FirewallRule.class, getEntityId()); final StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); final IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); fwResponse.setResponseName(getCommandName()); setResponseObject(fwResponse); } finally { if (!result || rule == null) { if (getOpenFirewall()) { _firewallService.revokeRelatedFirewallRule(getEntityId(), true); } _rulesService.revokeStaticNatRule(getEntityId(), true); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Error in creating IP forwarding rule on the domr"); } } }