You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2014/05/14 22:07:44 UTC

[2/2] git commit: updated refs/heads/master to 8d9bdb1

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

Branch: refs/heads/master
Commit: 8d9bdb19b41de3c1f9759afe6c8843c47c0069f1
Parents: 961e2c4
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed May 14 12:26:25 2014 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Wed May 14 12:34:39 2014 -0700

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


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