You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/05/15 09:24:04 UTC

git commit: updated refs/heads/4.4 to f20b2f4

Repository: cloudstack
Updated Branches:
  refs/heads/4.4 e796d885f -> f20b2f47d


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/f20b2f47
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f20b2f47
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f20b2f47

Branch: refs/heads/4.4
Commit: f20b2f47dd660886a8ddef14bd9f4f6529025a87
Parents: e796d88
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed May 14 12:26:25 2014 -0700
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu May 15 09:23:44 2014 +0200

----------------------------------------------------------------------
 .../firewall/UpdatePortForwardingRuleCmd.java   | 32 +++++++++-----------
 1 file changed, 14 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f20b2f47/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;
     }
 }