cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [2/2] git commit: updated refs/heads/sharednetworkservices to 77c6991
Date Wed, 10 Apr 2013 11:32:19 GMT
Trying to fit both isolated and shared network life cycle with single state
machine may need addtional work. So set network state for shared network explicitly now.


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

Branch: refs/heads/sharednetworkservices
Commit: 77c69918be5f15656a95fc325da9f0c99a08e782
Parents: 365ed73
Author: Murali Reddy <murali.reddy@citrix.com>
Authored: Tue Apr 9 17:16:57 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Wed Apr 10 16:55:46 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |   46 ++++++++++++--
 1 files changed, 39 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77c69918/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 7b67bd3..b62bb73 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -1424,7 +1424,11 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
 
             network.setReservationId(context.getReservationId());
-            stateTransitTo(network, Event.ImplementNetwork);
+            if (isSharedNetworkWithServices(network)) {
+                network.setState(Network.State.Implementing);
+            } else {
+                stateTransitTo(network, Event.ImplementNetwork);
+            }
 
             Network result = guru.implement(network, offering, dest, context);
             network.setCidr(result.getCidr());
@@ -1437,7 +1441,11 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             // implement network elements and re-apply all the network rules
             implementNetworkElementsAndResources(dest, context, network, offering);
 
-            stateTransitTo(network,Event.OperationSucceeded);
+            if (isSharedNetworkWithServices(network)) {
+                network.setState(Network.State.Implemented);
+            } else {
+                stateTransitTo(network,Event.OperationSucceeded);
+            }
 
             network.setRestartRequired(false);
             _networksDao.update(network.getId(), network);
@@ -1450,7 +1458,12 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             if (implemented.first() == null) {
                 s_logger.debug("Cleaning up because we're unable to implement the network
" + network);
                 try {
-                    stateTransitTo(network,Event.OperationFailed);
+                    if (isSharedNetworkWithServices(network)) {
+                        network.setState(Network.State.Shutdown);
+                        _networksDao.update(networkId, network);
+                    } else {
+                        stateTransitTo(network,Event.OperationFailed);
+                    }
                 } catch (NoTransitionException e) {
                     s_logger.error(e.getMessage());
                 }
@@ -2086,6 +2099,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
     @DB
     public boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements)
{
         boolean result = false;
+        Transaction txn = Transaction.currentTxn();
 
         NetworkVO network = _networksDao.lockRow(networkId, true);
         if (network == null) {
@@ -2096,16 +2110,23 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
             s_logger.debug("Network is not implemented: " + network);
             return false;
         }
-        try {
-            stateTransitTo(network, Event.DestroyNetwork);
-        } catch (NoTransitionException e) {
+
+        txn.start();
+        if (isSharedNetworkWithServices(network)) {
             network.setState(Network.State.Shutdown);
             _networksDao.update(network.getId(), network);
+        } else {
+            try {
+                stateTransitTo(network, Event.DestroyNetwork);
+            } catch (NoTransitionException e) {
+                network.setState(Network.State.Shutdown);
+                _networksDao.update(network.getId(), network);
+            }
         }
+        txn.commit();
 
         boolean success = shutdownNetworkElementsAndResources(context, cleanupElements, network);
 
-        Transaction txn = Transaction.currentTxn();
         txn.start();
         if (success) {
             if (s_logger.isDebugEnabled()) {
@@ -2741,6 +2762,17 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         return (UserDataServiceProvider)_networkModel.getElementImplementingProvider(SSHKeyProvider);
     }
 
+    protected boolean isSharedNetworkWithServices(Network network) {
+        assert(network != null);
+        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        if (network.getGuestType() == Network.GuestType.Shared &&
+                zone.getNetworkType() == NetworkType.Advanced &&
+                isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
+            return true;
+        }
+        return false;
+    }
+
     protected boolean isSharedNetworkOfferingWithServices(long networkOfferingId) {
         NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
         if ( (networkOffering.getGuestType()  == Network.GuestType.Shared) && (


Mime
View raw message