cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [10/18] api_refactor: refactor firewall apis
Date Tue, 04 Dec 2012 19:32:06 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/25b5aadb/api/src/org/apache/cloudstack/api/user/firewall/command/ListPortForwardingRulesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/firewall/command/ListPortForwardingRulesCmd.java
b/api/src/org/apache/cloudstack/api/user/firewall/command/ListPortForwardingRulesCmd.java
new file mode 100644
index 0000000..b45fc35
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/user/firewall/command/ListPortForwardingRulesCmd.java
@@ -0,0 +1,88 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.user.firewall.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.FirewallRuleResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.network.rules.PortForwardingRule;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists all port forwarding rules for an IP address.", responseObject=FirewallRuleResponse.class)
+public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListPortForwardingRulesCmd.class.getName());
+
+    private static final String s_name = "listportforwardingrulesresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="firewall_rules")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="Lists rule with
the specified ID.")
+    private Long id;
+
+    @IdentityMapper(entityTableName="user_ip_address")
+    @Parameter(name=ApiConstants.IP_ADDRESS_ID, type=CommandType.LONG, description="the id
of IP address of the port forwarding services")
+    private Long ipAddressId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getIpAddressId() {
+        return ipAddressId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends PortForwardingRule>, Integer> result = _rulesService.listPortForwardingRules(this);
+        ListResponse<FirewallRuleResponse> response = new ListResponse<FirewallRuleResponse>();
+        List<FirewallRuleResponse> fwResponses = new ArrayList<FirewallRuleResponse>();
+
+        for (PortForwardingRule fwRule : result.first()) {
+            FirewallRuleResponse ruleData = _responseGenerator.createPortForwardingRuleResponse(fwRule);
+            ruleData.setObjectName("portforwardingrule");
+            fwResponses.add(ruleData);
+        }
+        response.setResponses(fwResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/25b5aadb/api/src/org/apache/cloudstack/api/user/nat/command/DisableStaticNatCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/user/nat/command/DisableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/user/nat/command/DisableStaticNatCmd.java
index 912ad99..e228e71 100644
--- a/api/src/org/apache/cloudstack/api/user/nat/command/DisableStaticNatCmd.java
+++ b/api/src/org/apache/cloudstack/api/user/nat/command/DisableStaticNatCmd.java
@@ -16,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.user.nat.command;
 
-import com.cloud.api.commands.DeletePortForwardingRuleCmd;
+import org.apache.cloudstack.api.user.firewall.command.DeletePortForwardingRuleCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/25b5aadb/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 8a3a010..9dbad2b 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -129,9 +129,9 @@ disassociateIpAddress=org.apache.cloudstack.api.user.address.command.Disassociat
 listPublicIpAddresses=org.apache.cloudstack.api.user.address.command.ListPublicIpAddressesCmd;15
 
 #### firewall commands
-listPortForwardingRules=com.cloud.api.commands.ListPortForwardingRulesCmd;15
-createPortForwardingRule=com.cloud.api.commands.CreatePortForwardingRuleCmd;15
-deletePortForwardingRule=com.cloud.api.commands.DeletePortForwardingRuleCmd;15
+listPortForwardingRules=org.apache.cloudstack.api.user.firewall.command.ListPortForwardingRulesCmd;15
+createPortForwardingRule=org.apache.cloudstack.api.user.firewall.command.CreatePortForwardingRuleCmd;15
+deletePortForwardingRule=org.apache.cloudstack.api.user.firewall.command.DeletePortForwardingRuleCmd;15
 #### updatePortForwardingRule=com.cloud.api.commands.UpdatePortForwardingRuleCmd;15
 
 #### NAT commands
@@ -335,9 +335,9 @@ updateProjectInvitation=org.apache.cloudstack.api.user.project.command.UpdatePro
 deleteProjectInvitation=org.apache.cloudstack.api.user.project.command.DeleteProjectInvitationCmd;15
 
 #### 
-createFirewallRule=com.cloud.api.commands.CreateFirewallRuleCmd;15
-deleteFirewallRule=com.cloud.api.commands.DeleteFirewallRuleCmd;15
-listFirewallRules=com.cloud.api.commands.ListFirewallRulesCmd;15
+createFirewallRule=org.apache.cloudstack.api.user.firewall.command.CreateFirewallRuleCmd;15
+deleteFirewallRule=org.apache.cloudstack.api.user.firewall.command.DeleteFirewallRuleCmd;15
+listFirewallRules=org.apache.cloudstack.api.user.firewall.command.ListFirewallRulesCmd;15
 
 #### hypervisor capabilities commands
 updateHypervisorCapabilities=com.cloud.api.commands.UpdateHypervisorCapabilitiesCmd;1

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/25b5aadb/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 9511a9e..f7ee1c7 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -26,9 +26,9 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.user.firewall.command.ListFirewallRulesCmd;
 import org.apache.log4j.Logger;
 
-import com.cloud.api.commands.ListFirewallRulesCmd;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.domain.dao.DomainDao;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/25b5aadb/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 8e44e82..422dae1 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -27,7 +27,7 @@ import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 
-import com.cloud.api.commands.ListPortForwardingRulesCmd;
+import org.apache.cloudstack.api.user.firewall.command.ListPortForwardingRulesCmd;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.event.ActionEvent;


Mime
View raw message