6868 PortForwardingServiceProvider .class , IpDeployer .class })
6969public class OvsElement extends AdapterBase implements NetworkElement ,
7070 OvsElementService , ConnectivityProvider , ResourceStateAdapter ,
71- SourceNatServiceProvider , PortForwardingServiceProvider ,
71+ PortForwardingServiceProvider ,
7272 StaticNatServiceProvider , IpDeployer {
7373 @ Inject
7474 OvsTunnelManager _ovsTunnelMgr ;
@@ -228,12 +228,6 @@ public boolean verifyServicesCombination(Set<Service> services) {
228228 return false ;
229229 }
230230
231- // if ((services.contains(Service.PortForwarding) || services
232- // .contains(Service.StaticNat))
233- // && !services.contains(Service.SourceNat)) {
234- // s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
235- // return false;
236- // }
237231 return true ;
238232 }
239233
@@ -243,7 +237,6 @@ private static Map<Service, Map<Capability, String>> setCapabilities() {
243237 // L2 Support : SDN provisioning
244238 capabilities .put (Service .Connectivity , null );
245239
246- // TODO: we need L3 support for coding L3 services in next period
247240 // L3 Support : Generic?
248241 // capabilities.put(Service.Gateway, null);
249242
@@ -256,7 +249,7 @@ private static Map<Service, Map<Capability, String>> setCapabilities() {
256249 // capabilities.put(Service.SourceNat, sourceNatCapabilities);
257250
258251 // L3 Support : Port Forwarding
259- // capabilities.put(Service.PortForwarding, null);
252+ capabilities .put (Service .PortForwarding , null );
260253
261254 // L3 support : StaticNat
262255 capabilities .put (Service .StaticNat , null );
@@ -296,7 +289,6 @@ public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
296289 return new DeleteHostAnswer (true );
297290 }
298291
299- // TODO: Adding L3 services below
300292 @ Override
301293 public IpDeployer getIpDeployer (Network network ) {
302294 return this ;
@@ -331,8 +323,7 @@ public boolean applyIps(Network network,
331323 }
332324
333325 @ Override
334- public boolean applyStaticNats (Network network ,
335- List <? extends StaticNat > rules )
326+ public boolean applyStaticNats (Network network , List <? extends StaticNat > rules )
336327 throws ResourceUnavailableException {
337328 if (!canHandle (network , Service .StaticNat )) {
338329 return false ;
@@ -351,7 +342,17 @@ public boolean applyStaticNats(Network network,
351342 @ Override
352343 public boolean applyPFRules (Network network , List <PortForwardingRule > rules )
353344 throws ResourceUnavailableException {
354- // TODO Auto-generated method stub
355- return false ;
345+ if (!canHandle (network , Service .PortForwarding )) {
346+ return false ;
347+ }
348+ List <DomainRouterVO > routers = _routerDao .listByNetworkAndRole (
349+ network .getId (), Role .VIRTUAL_ROUTER );
350+ if (routers == null || routers .isEmpty ()) {
351+ s_logger .debug ("Ovs element doesn't need to apply firewall rules on the backend; virtual "
352+ + "router doesn't exist in the network " + network .getId ());
353+ return true ;
354+ }
355+
356+ return _routerMgr .applyFirewallRules (network , rules , routers );
356357 }
357358}
0 commit comments