cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 04884b8
Date Tue, 12 Nov 2013 00:32:25 GMT
Updated Branches:
  refs/heads/master 8b7b7a041 -> 04884b8f0


ListPortFowardingRules: added networkId to the list of optional parameters to list by


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/268c27b4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/268c27b4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/268c27b4

Branch: refs/heads/master
Commit: 268c27b4f22b3818a54271a4484f47cfa1f8075d
Parents: 8b7b7a0
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Nov 11 10:11:13 2013 -0800
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Nov 11 16:17:43 2013 -0800

----------------------------------------------------------------------
 .../user/firewall/ListPortForwardingRulesCmd.java       |  9 +++++++++
 .../cloudstack/api/response/FirewallRuleResponse.java   |  7 +++++++
 server/src/com/cloud/api/ApiResponseHelper.java         |  3 +++
 .../src/com/cloud/network/rules/RulesManagerImpl.java   | 12 +++++++++---
 4 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/268c27b4/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java
b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java
index 9fd4e45..7e96e0b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java
@@ -26,6 +26,7 @@ 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.ListResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.log4j.Logger;
 
 import com.cloud.network.rules.PortForwardingRule;
@@ -48,6 +49,10 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd
{
     @Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.UUID, entityType = IPAddressResponse.class,
             description="the id of IP address of the port forwarding services")
     private Long ipAddressId;
+    
+    @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+            description="list port forwarding rules for ceratin network", since="4.3")
+    private Long networkId;
 
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -60,6 +65,10 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd
{
     public Long getId() {
         return id;
     }
+    
+    public Long getNetworkId() {
+        return networkId;
+    }
 
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/268c27b4/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java b/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java
index 787410a..20ea407 100644
--- a/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java
@@ -73,6 +73,9 @@ public class FirewallRuleResponse extends BaseResponse {
 
     @SerializedName(ApiConstants.VM_GUEST_IP) @Param(description="the vm ip address for the
port forwarding rule")
     private String destNatVmIp;
+    
+    @SerializedName(ApiConstants.NETWORK_ID) @Param(description="the id of the guest network
the port forwarding rule belongs to")
+    private String networkId;
 
 
     public String getDestNatVmIp() {
@@ -196,4 +199,8 @@ public class FirewallRuleResponse extends BaseResponse {
     public void setTags(List<ResourceTagResponse> tags) {
         this.tags = tags;
     }
+
+    public void setNetworkId(String networkId) {
+        this.networkId = networkId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/268c27b4/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index f70af5f..89c951c 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1023,6 +1023,9 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setPublicEndPort(Integer.toString(fwRule.getSourcePortEnd()));
         List<String> cidrs = ApiDBUtils.findFirewallSourceCidrs(fwRule.getId());
         response.setCidrList(StringUtils.join(cidrs, ","));
+        
+        Network guestNtwk = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
+        response.setNetworkId(guestNtwk.getUuid());
 
         IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
         response.setPublicIpAddressId(ip.getUuid());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/268c27b4/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index 2ea1021..5808938 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -25,10 +25,10 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
 import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.log4j.Logger;
 
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.domain.dao.DomainDao;
@@ -75,10 +75,10 @@ import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.JoinBuilder;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.TransactionCallbackNoReturn;
-import com.cloud.utils.db.TransactionCallbackWithException;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionCallbackNoReturn;
+import com.cloud.utils.db.TransactionCallbackWithException;
 import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
 import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -783,6 +783,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager,
Rules
         Long ipId = cmd.getIpAddressId();
         Long id = cmd.getId();
         Map<String, String> tags = cmd.getTags();
+        Long networkId = cmd.getNetworkId();
 
         Account caller = CallContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
@@ -808,6 +809,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager,
Rules
         sb.and("id", sb.entity().getId(), Op.EQ);
         sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
         sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
+        sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
 
         if (tags != null && !tags.isEmpty()) {
             SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
@@ -842,6 +844,10 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager,
Rules
         if (ipId != null) {
             sc.setParameters("ip", ipId);
         }
+        
+        if (networkId != null) {
+            sc.setParameters("networkId", networkId);
+        }
 
         sc.setParameters("purpose", Purpose.PortForwarding);
 


Mime
View raw message