Repository: cloudstack Updated Branches: refs/heads/4.4-forward 9e21b8b04 -> 3b5f95c54
CLOUDSTACK-6675: updatePFRule - retrieve network sync object based on the PF rule id that is passed in to the call; not the public ip address Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3b5f95c5 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3b5f95c5 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3b5f95c5 Branch: refs/heads/4.4-forward Commit: 3b5f95c5473165356702d16873ac3d7cd8c514e8 Parents: 9e21b8b Author: Alena Prokharchyk <alena.prokharc...@citrix.com> Authored: Wed May 14 12:26:25 2014 -0700 Committer: Alena Prokharchyk <alena.prokharc...@citrix.com> Committed: Wed May 14 12:33:15 2014 -0700 ---------------------------------------------------------------------- .../firewall/UpdatePortForwardingRuleCmd.java | 32 +++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3b5f95c5/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java index 78525ba..eb4d468 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java @@ -16,8 +16,6 @@ // under the License. package org.apache.cloudstack.api.command.user.firewall; -import org.apache.log4j.Logger; - import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; @@ -27,10 +25,10 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; -import com.cloud.network.IpAddress; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.PortForwardingRule; import com.cloud.user.Account; @@ -94,10 +92,6 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { return protocol; } - public Long getPublicIpId() { - return publicIpId; - } - public String getPublicPort() { return publicPort; } @@ -109,11 +103,16 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { public Boolean getDisplay() { return display; } + public Long getId() { + return id; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// + + @Override public String getCommandName() { return s_name; @@ -121,9 +120,9 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { @Override public long getEntityOwnerId() { - IpAddress addr = _entityMgr.findById(IpAddress.class, getPublicIpId()); - if (addr != null) { - return addr.getAccountId(); + PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, getId()); + if (rule != null) { + return rule.getAccountId(); } // bad address given, parent this command to SYSTEM so ERROR events are tracked @@ -173,14 +172,11 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { @Override public Long getSyncObjId() { - return getIp().getAssociatedWithNetworkId(); - } - - private IpAddress getIp() { - IpAddress ip = _networkService.getIp(publicIpId); - if (ip == null) { - throw new InvalidParameterValueException("Unable to find ip address by id " + publicIpId); + PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, getId()); + if (rule != null) { + return rule.getNetworkId(); + } else { + throw new InvalidParameterValueException("Unable to find the rule by id"); } - return ip; } }