incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chirad...@apache.org
Subject [2/39] git commit: Rationalize the interface by injecting ipDeployers. This is step 1 and includes 2 service providers - Remote AccessVPN and S2S VPN
Date Fri, 18 Jan 2013 01:01:23 GMT
Rationalize the interface by injecting ipDeployers. This is step 1 and includes 2 service providers
- Remote AccessVPN and S2S VPN

Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>


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

Branch: refs/heads/master
Commit: 3529c472489fc9008b2107afad169dfdb1e1440d
Parents: b0a1a47
Author: Chiradeep Vittal <chiradeep@apache.org>
Authored: Thu Jan 3 23:56:55 2013 -0800
Committer: Chiradeep Vittal <chiradeep@apache.org>
Committed: Fri Jan 4 15:08:55 2013 -0800

----------------------------------------------------------------------
 .../element/RemoteAccessVPNServiceProvider.java    |    5 +--
 .../element/Site2SiteVpnServiceProvider.java       |    4 +-
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |   24 ++++++++++----
 .../cloud/network/vpn/Site2SiteVpnManagerImpl.java |   12 +++----
 4 files changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3529c472/api/src/com/cloud/network/element/RemoteAccessVPNServiceProvider.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/element/RemoteAccessVPNServiceProvider.java b/api/src/com/cloud/network/element/RemoteAccessVPNServiceProvider.java
index d799b0b..2eb0389 100644
--- a/api/src/com/cloud/network/element/RemoteAccessVPNServiceProvider.java
+++ b/api/src/com/cloud/network/element/RemoteAccessVPNServiceProvider.java
@@ -22,13 +22,12 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.RemoteAccessVpn;
 import com.cloud.network.VpnUser;
+import com.cloud.utils.component.Adapter;
 
-public interface RemoteAccessVPNServiceProvider extends NetworkElement {
+public interface RemoteAccessVPNServiceProvider extends Adapter {
     String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users) throws
ResourceUnavailableException;
 
     boolean startVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
     
     boolean stopVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
-    
-    IpDeployer getIpDeployer(Network network);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3529c472/api/src/com/cloud/network/element/Site2SiteVpnServiceProvider.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/element/Site2SiteVpnServiceProvider.java b/api/src/com/cloud/network/element/Site2SiteVpnServiceProvider.java
index 8063cbb..eadf801 100644
--- a/api/src/com/cloud/network/element/Site2SiteVpnServiceProvider.java
+++ b/api/src/com/cloud/network/element/Site2SiteVpnServiceProvider.java
@@ -17,10 +17,10 @@
 package com.cloud.network.element;
 
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.Network;
 import com.cloud.network.Site2SiteVpnConnection;
+import com.cloud.utils.component.Adapter;
 
-public interface Site2SiteVpnServiceProvider extends NetworkElement {
+public interface Site2SiteVpnServiceProvider extends Adapter {
     boolean startSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException;
     
     boolean stopSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3529c472/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index a134591..45b5d19 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -17,6 +17,7 @@
 package com.cloud.network.vpn;
 
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
 
@@ -52,6 +53,7 @@ import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.RemoteAccessVpnDao;
 import com.cloud.network.dao.VpnUserDao;
+import com.cloud.network.element.NetworkElement;
 import com.cloud.network.element.RemoteAccessVPNServiceProvider;
 import com.cloud.network.rules.FirewallManager;
 import com.cloud.network.rules.FirewallRule;
@@ -68,6 +70,7 @@ import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
 import com.cloud.utils.Ternary;
+import com.cloud.utils.component.Adapters;
 import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -97,6 +100,9 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService,
Manag
     @Inject FirewallRulesDao _rulesDao;
     @Inject FirewallManager _firewallMgr;
     @Inject UsageEventDao _usageEventDao;
+    @Inject(adapter = RemoteAccessVPNServiceProvider.class) 
+    Adapters<RemoteAccessVPNServiceProvider> _vpnServiceProviders;
+
     
     int _userLimit;
     int _pskLength;
@@ -227,10 +233,9 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService,
Manag
         _remoteAccessVpnDao.update(vpn.getServerAddressId(), vpn);
         
         
-        List<? extends RemoteAccessVPNServiceProvider> elements = _networkMgr.getRemoteAccessVpnElements();
         boolean success = false;
         try {
-            for (RemoteAccessVPNServiceProvider element : elements) {
+            for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) {
                 if (element.stopVpn(network, vpn)) {
                     success = true;
                     break;
@@ -374,7 +379,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService,
Manag
 
         Network network = _networkMgr.getNetwork(vpn.getNetworkId());
 
-        List<? extends RemoteAccessVPNServiceProvider > elements = _networkMgr.getRemoteAccessVpnElements();
         boolean started = false;
         try {
             boolean firewallOpened = true;
@@ -383,7 +387,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService,
Manag
             }
             
             if (firewallOpened) {
-                for (RemoteAccessVPNServiceProvider element : elements) {
+                for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) {
                     if (element.startVpn(network, vpn)) {
                         started = true;
                         break;
@@ -432,12 +436,10 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService,
Manag
             }
         }
         
-        List<? extends RemoteAccessVPNServiceProvider> elements = _networkMgr.getRemoteAccessVpnElements();
-
         boolean success = true;
 
         boolean[] finals = new boolean[users.size()];
-        for (RemoteAccessVPNServiceProvider element : elements) {
+        for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) {
             s_logger.debug("Applying vpn access to " + element.getName());
             for (RemoteAccessVpnVO vpn : vpns) {
                 try {
@@ -630,4 +632,12 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService,
Manag
         return _remoteAccessVpnDao.findById(vpnId);
     }
 
+    public List<RemoteAccessVPNServiceProvider> getRemoteAccessVPNServiceProviders()
{
+    	List<RemoteAccessVPNServiceProvider> result = new ArrayList<RemoteAccessVPNServiceProvider>();
+    	for (Enumeration<RemoteAccessVPNServiceProvider> e = _vpnServiceProviders.enumeration();
e.hasMoreElements();) {
+    		result.add(e.nextElement());
+    	}
+    		
+    	return result;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3529c472/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
index da993d0..9d0f89f 100644
--- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
@@ -44,7 +44,6 @@ import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.IPAddressVO;
-import com.cloud.network.NetworkManager;
 import com.cloud.network.Site2SiteCustomerGateway;
 import com.cloud.network.Site2SiteCustomerGatewayVO;
 import com.cloud.network.Site2SiteVpnConnection;
@@ -65,10 +64,10 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.UserContext;
 import com.cloud.user.dao.AccountDao;
-import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
+import com.cloud.utils.component.Adapters;
 import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.component.Inject;
 import com.cloud.utils.component.Manager;
@@ -85,10 +84,11 @@ import com.cloud.vm.DomainRouterVO;
 public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
     private static final Logger s_logger = Logger.getLogger(Site2SiteVpnManagerImpl.class);
 
+    @Inject (adapter = Site2SiteVpnServiceProvider.class)
+    Adapters<Site2SiteVpnServiceProvider> _s2sProviders;
     @Inject Site2SiteCustomerGatewayDao _customerGatewayDao;
     @Inject Site2SiteVpnGatewayDao _vpnGatewayDao;
     @Inject Site2SiteVpnConnectionDao _vpnConnectionDao;
-    @Inject NetworkManager _networkMgr;
     @Inject VpcDao _vpcDao;
     @Inject IPAddressDao _ipAddressDao;
     @Inject AccountDao _accountDao;
@@ -328,9 +328,8 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager
{
             conn.setState(State.Pending);
             _vpnConnectionDao.persist(conn);
 
-            List <? extends Site2SiteVpnServiceProvider> elements = _networkMgr.getSite2SiteVpnElements();
             boolean result = true;
-            for (Site2SiteVpnServiceProvider element : elements) {
+            for (Site2SiteVpnServiceProvider element : _s2sProviders) {
                 result = result & element.startSite2SiteVpn(conn);
             }
 
@@ -528,9 +527,8 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager
{
             conn.setState(State.Disconnected);
             _vpnConnectionDao.persist(conn);
             
-            List <? extends Site2SiteVpnServiceProvider> elements = _networkMgr.getSite2SiteVpnElements();
             boolean result = true;
-            for (Site2SiteVpnServiceProvider element : elements) {
+            for (Site2SiteVpnServiceProvider element : _s2sProviders) {
                 result = result & element.stopSite2SiteVpn(conn);
             }
 


Mime
View raw message