cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/hotfix/CLOUDSTACK-7776 to 3811411
Date Thu, 23 Oct 2014 20:54:22 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/hotfix/CLOUDSTACK-7776 5ba7d9734 -> 381141185


CLOUDSTACK-7776 restart sequence extracted

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

Branch: refs/heads/hotfix/CLOUDSTACK-7776
Commit: 381141185308d0aa763c1f80ec00152e389a2400
Parents: 5ba7d97
Author: Daan Hoogland <daan@onecht.net>
Authored: Thu Oct 23 22:53:47 2014 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Thu Oct 23 22:53:47 2014 +0200

----------------------------------------------------------------------
 .../com/cloud/network/NetworkServiceImpl.java   | 38 ++++++++++++++++----
 1 file changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38114118/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 5336a20..6d98387 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1976,20 +1976,17 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
 
         final NetworkVO network = getNetworkIfItExists(networkId);
 
+        setNewFieldsOnNetwork(name, displayText, customId, network);
+
         checkOfferingForVpc(networkOfferingId, network);
 
         checkWhetherNetworkIsUpdatable(network);
 
         _accountMgr.checkAccess(callerAccount, null, true, network);
 
-        setNewFieldsOnNetwork(name, displayText, customId, network);
-
         checkResourceCountUpdate(displayNetwork, network);
 
-        // network offering and domain suffix can be updated for Isolated networks only in
3.0
-        if ((networkOfferingId != null || domainSuffix != null) && network.getGuestType()
!= GuestType.Isolated) {
-            throw new InvalidParameterValueException("NetworkOffering and domain suffix upgrade
can be perfomed for Isolated networks only");
-        }
+        checkForUpgradeIsolatedNetworkFunctionality(domainSuffix, networkOfferingId, network);
 
         final long oldNetworkOfferingId = network.getNetworkOfferingId();
         NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId);
@@ -2009,6 +2006,20 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         changeCidrWhenValid(guestVmCidr, networkOfferingChanged, network);
 
         ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
+
+        shutDownElementsAndCleanupRules(networkId, changeCidr, restartNetwork, network, context);
+
+        updateNetworkVO(networkId, networkOfferingId, restartNetwork, networkOfferingChanged,
network, oldNetworkOfferingId, newSvcProviders);
+
+        reimplementElementsAndRules(changeCidr, restartNetwork, network, context);
+
+        implementNetworkIfNeeded(networkOfferingChanged, network, oldNtwkOff, networkOffering,
context);
+
+        return getNetwork(network.getId());
+    }
+
+    private void shutDownElementsAndCleanupRules(final long networkId, Boolean changeCidr,
boolean restartNetwork, final NetworkVO network, ReservationContext context)
+            throws CloudRuntimeException {
         // 1) Shutdown all the elements and cleanup all the rules. Don't allow to shutdown
network in intermediate
         // states - Shutdown and Implementing
         boolean validStateToShutdown = (network.getState() == Network.State.Implemented ||
network.getState() == Network.State.Setup || network.getState() == Network.State.Allocated);
@@ -2051,7 +2062,10 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
                 throw ex;
             }
         }
+    }
 
+    private void updateNetworkVO(final long networkId, final Long networkOfferingId, boolean
restartNetwork, boolean networkOfferingChanged, final NetworkVO network,
+            final long oldNetworkOfferingId, final Map<String, String> newSvcProviders)
throws CloudRuntimeException {
         // 2) Only after all the elements and rules are shutdown properly, update the network
VO
         // get updated network
         Network.State networkState = _networksDao.findById(networkId).getState();
@@ -2098,7 +2112,9 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         }   else {
             _networksDao.update(networkId, network);
         }
+    }
 
+    private void reimplementElementsAndRules(Boolean changeCidr, boolean restartNetwork,
final NetworkVO network, ReservationContext context) throws CloudRuntimeException {
         // 3) Implement the elements and rules again
         if (restartNetwork) {
             if (network.getState() != Network.State.Allocated) {
@@ -2118,7 +2134,10 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
                 }
             }
         }
+    }
 
+    private void implementNetworkIfNeeded(boolean networkOfferingChanged, final NetworkVO
network, NetworkOffering oldNtwkOff, NetworkOfferingVO networkOffering,
+            ReservationContext context) throws CloudRuntimeException {
         // 4) if network has been upgraded from a non persistent ntwk offering to a persistent
ntwk offering,
         // implement the network if its not already
         if (networkOfferingChanged && !oldNtwkOff.getIsPersistent() && networkOffering.getIsPersistent())
{
@@ -2134,8 +2153,13 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
                 }
             }
         }
+    }
 
-        return getNetwork(network.getId());
+    private void checkForUpgradeIsolatedNetworkFunctionality(String domainSuffix, final Long
networkOfferingId, final NetworkVO network) throws InvalidParameterValueException {
+        // network offering and domain suffix can be updated for Isolated networks only in
3.0
+        if ((networkOfferingId != null || domainSuffix != null) && network.getGuestType()
!= GuestType.Isolated) {
+            throw new InvalidParameterValueException("NetworkOffering and domain suffix upgrade
can be perfomed for Isolated networks only");
+        }
     }
 
     private void checkOfferingForVpc(final Long networkOfferingId, final NetworkVO network)
{


Mime
View raw message