cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/master to d905c10
Date Wed, 13 Nov 2013 01:17:15 GMT
Updated Branches:
  refs/heads/master 81949ec64 -> d905c1021


listFirewallRules - added optional networkId parameter allowing to search for firewall rules
by guest network id


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

Branch: refs/heads/master
Commit: d905c102148e130469bf1d02def2b82696947e21
Parents: 81949ec
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Nov 12 15:44:17 2013 -0800
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Nov 12 17:17:48 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/server/ResourceTag.java       |  2 +-
 .../user/firewall/ListFirewallRulesCmd.java     | 10 ++++++++
 server/src/com/cloud/api/ApiResponseHelper.java |  9 +++----
 .../metadata/ResourceMetaDataManagerImpl.java   |  1 +
 .../network/firewall/FirewallManagerImpl.java   | 27 ++++++++------------
 5 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d905c102/api/src/com/cloud/server/ResourceTag.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java
index 35efcf0..e15a070 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -31,7 +31,7 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
         Snapshot (true, false),
         Network (true, true),
         Nic (false, true),
-        LoadBalancer (true, false),
+        LoadBalancer (true, true),
         PortForwardingRule (true, true),
         FirewallRule (true, true),
         SecurityGroup (true, false),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d905c102/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java
b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java
index c2aee55..38c8e62 100644
--- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java
@@ -23,10 +23,12 @@ import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.BaseCmd.CommandType;
 import org.apache.cloudstack.api.response.FirewallResponse;
 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.FirewallRule;
@@ -47,6 +49,10 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd {
     @Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.UUID, entityType = IPAddressResponse.class,
             description="the id of IP address of the firwall services")
     private Long ipAddressId;
+    
+    @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+            description="list firewall rules for ceratin network", since="4.3")
+    private Long networkId;
 
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -63,6 +69,10 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd {
     public Long getId() {
         return id;
     }
+    
+    public Long getNetworkId() {
+        return networkId;
+    }
 
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d905c102/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 89c951c..903c485 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2374,12 +2374,11 @@ public class ApiResponseHelper implements ResponseGenerator {
             IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
             response.setPublicIpAddressId(ip.getUuid());
             response.setPublicIpAddress(ip.getAddress().addr());
-        } else if (fwRule.getTrafficType() == FirewallRule.TrafficType.Egress) {
-            response.setPublicIpAddress(null);
-            Network network = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
-            response.setNetworkId(network.getUuid());
         }
-
+        
+        Network network = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
+        response.setNetworkId(network.getUuid());
+        
         FirewallRule.State state = fwRule.getState();
         String stateToSet = state.toString();
         if (state.equals(FirewallRule.State.Revoke)) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d905c102/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
index 8c4415c..12ac26a 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -96,6 +96,7 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
         _daoMap.put(ResourceObjectType.FirewallRule, _firewallRuleDetailsDao);
         _daoMap.put(ResourceObjectType.PublicIpAddress, _userIpAddressDetailsDao);
         _daoMap.put(ResourceObjectType.PortForwardingRule, _firewallRuleDetailsDao);
+        _daoMap.put(ResourceObjectType.LoadBalancer, _firewallRuleDetailsDao);
 
         return true;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d905c102/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
index ccceb8d..6ccf500 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -27,13 +27,12 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-import org.apache.cloudstack.api.command.user.firewall.ListEgressFirewallRulesCmd;
 import org.apache.cloudstack.api.command.user.firewall.ListFirewallRulesCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.configuration.Config;
 import com.cloud.domain.dao.DomainDao;
@@ -70,7 +69,6 @@ import com.cloud.network.rules.FirewallRule.State;
 import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.PortForwardingRule;
 import com.cloud.network.rules.PortForwardingRuleVO;
-import com.cloud.network.rules.StaticNat;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.network.vpc.VpcManager;
 import com.cloud.projects.Project.ListProjectResourcesCriteria;
@@ -88,11 +86,11 @@ 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.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.TransactionStatus;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.UserVmVO;
@@ -256,7 +254,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
     public Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewallRulesCmd
cmd) {
         Long ipId = cmd.getIpAddressId();
         Long id = cmd.getId();
-        Long networkId = null;
+        Long networkId = cmd.getNetworkId();
         Map<String, String> tags = cmd.getTags();
         FirewallRule.TrafficType trafficType = cmd.getTrafficType();
 
@@ -283,15 +281,10 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
 
         sb.and("id", sb.entity().getId(), Op.EQ);
         sb.and("trafficType", sb.entity().getTrafficType(), Op.EQ);
-        if (cmd instanceof ListEgressFirewallRulesCmd ) {
-            networkId =((ListEgressFirewallRulesCmd)cmd).getNetworkId();
-            sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
-        } else {
+        sb.and("networkId", sb.entity().getNetworkId(), Op.EQ);
         sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
-        }
         sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
 
-
         if (tags != null && !tags.isEmpty()) {
             SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
             for (int count=0; count < tags.size(); count++) {
@@ -323,10 +316,10 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
 
         if (ipId != null) {
             sc.setParameters("ip", ipId);
-        } else if (cmd instanceof ListEgressFirewallRulesCmd) {
-            if (networkId != null) {
-                sc.setParameters("networkId", networkId);
-            }
+        }
+        
+        if (networkId != null) {
+            sc.setParameters("networkId", networkId);
         }
 
         sc.setParameters("purpose", Purpose.Firewall);


Mime
View raw message