tuna add port forwarding support

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

Branch: refs/heads/master
Commit: 9c702ff388b859d5d212f0a932d80a2012ebf912
Parents: d935d38
Author: tuna <[email protected]>
Authored: Tue Aug 13 10:46:21 2013 +0700
Committer: tuna <[email protected]>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 .../com/cloud/network/element/OvsElement.java   | 29 ++++++++++----------
 1 file changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9c702ff3/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git 
a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java 
b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 06965e8..9af708c 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -68,7 +68,7 @@ import com.cloud.vm.dao.DomainRouterDao;
                PortForwardingServiceProvider.class, IpDeployer.class })
 public class OvsElement extends AdapterBase implements NetworkElement,
                OvsElementService, ConnectivityProvider, ResourceStateAdapter,
-               SourceNatServiceProvider, PortForwardingServiceProvider,
+               PortForwardingServiceProvider,
                StaticNatServiceProvider, IpDeployer {
        @Inject
        OvsTunnelManager _ovsTunnelMgr;
@@ -228,12 +228,6 @@ public class OvsElement extends AdapterBase implements 
NetworkElement,
                        return false;
                }
 
-               // if ((services.contains(Service.PortForwarding) || services
-               // .contains(Service.StaticNat))
-               // && !services.contains(Service.SourceNat)) {
-               // s_logger.warn("Unable to provide StaticNat and/or 
PortForwarding without the SourceNat service");
-               // return false;
-               // }
                return true;
        }
 
@@ -243,7 +237,6 @@ public class OvsElement extends AdapterBase implements 
NetworkElement,
                // L2 Support : SDN provisioning
                capabilities.put(Service.Connectivity, null);
 
-               // TODO: we need L3 support for coding L3 services in next 
period
                // L3 Support : Generic?
                // capabilities.put(Service.Gateway, null);
 
@@ -256,7 +249,7 @@ public class OvsElement extends AdapterBase implements 
NetworkElement,
                // capabilities.put(Service.SourceNat, sourceNatCapabilities);
 
                // L3 Support : Port Forwarding
-               // capabilities.put(Service.PortForwarding, null);
+                capabilities.put(Service.PortForwarding, null);
 
                // L3 support : StaticNat
                capabilities.put(Service.StaticNat, null);
@@ -296,7 +289,6 @@ public class OvsElement extends AdapterBase implements 
NetworkElement,
                return new DeleteHostAnswer(true);
        }
 
-       // TODO: Adding L3 services below
        @Override
        public IpDeployer getIpDeployer(Network network) {
                return this;
@@ -331,8 +323,7 @@ public class OvsElement extends AdapterBase implements 
NetworkElement,
        }
 
        @Override
-       public boolean applyStaticNats(Network network,
-                       List<? extends StaticNat> rules)
+       public boolean applyStaticNats(Network network, List<? extends 
StaticNat> rules)
                        throws ResourceUnavailableException {
                if (!canHandle(network, Service.StaticNat)) {
                        return false;
@@ -351,7 +342,17 @@ public class OvsElement extends AdapterBase implements 
NetworkElement,
        @Override
        public boolean applyPFRules(Network network, List<PortForwardingRule> 
rules)
                        throws ResourceUnavailableException {
-               // TODO Auto-generated method stub
-               return false;
+               if (!canHandle(network, Service.PortForwarding)) {
+                       return false;
+               }
+               List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
+                               network.getId(), Role.VIRTUAL_ROUTER);
+               if (routers == null || routers.isEmpty()) {
+                       s_logger.debug("Ovs element doesn't need to apply 
firewall rules on the backend; virtual "
+                                       + "router doesn't exist in the network 
" + network.getId());
+                       return true;
+               }
+
+               return _routerMgr.applyFirewallRules(network, rules, routers);
        }
 }

Reply via email to