incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [2/5] git commit: Revert "CLOUDSTACK-70: Improve Network Restart Behaviour for Basic Zone: Restarting Network Fails"
Date Mon, 10 Sep 2012 23:56:55 GMT
Revert "CLOUDSTACK-70: Improve Network Restart Behaviour for Basic Zone: Restarting Network
Fails"

This reverts commit ecd1ac214c34007214557c4191a803a55ded29f5.


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

Branch: refs/heads/4.0
Commit: d6b652995180b6842545cd8b4798504b563a414c
Parents: 176c340
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Sep 10 14:45:39 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Sep 10 16:34:21 2012 -0700

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |   54 ++++-----------
 server/src/com/cloud/vm/dao/DomainRouterDao.java   |    9 +--
 .../src/com/cloud/vm/dao/DomainRouterDaoImpl.java  |    7 --
 server/src/com/cloud/vm/dao/VMInstanceDao.java     |    9 +--
 server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java |   10 +---
 ui/scripts/network.js                              |   12 +++-
 6 files changed, 26 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6b65299/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 aee9a41..292a259 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -68,7 +68,6 @@ import com.cloud.dc.AccountVlanMapVO;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
 import com.cloud.dc.Pod;
 import com.cloud.dc.PodVlanMapVO;
 import com.cloud.dc.Vlan;
@@ -78,7 +77,6 @@ import com.cloud.dc.dao.AccountVlanMapDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.PodVlanMapDao;
 import com.cloud.dc.dao.VlanDao;
-import com.cloud.dc.dao.HostPodDao;
 import com.cloud.deploy.DataCenterDeployment;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.deploy.DeploymentPlan;
@@ -204,7 +202,6 @@ import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.Ip;
 import com.cloud.utils.net.NetUtils;
-import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.Nic;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
@@ -235,8 +232,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
     @Inject
     DataCenterDao _dcDao = null;
     @Inject
-    HostPodDao _podDao = null;
-    @Inject
     VlanDao _vlanDao = null;
     @Inject
     IPAddressDao _ipAddressDao = null;
@@ -245,8 +240,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
     @Inject
     DomainDao _domainDao = null;
     @Inject
-    DomainRouterDao _domainRouterDao = null;
-    @Inject
     UserStatisticsDao _userStatsDao = null;
     @Inject
     EventDao _eventDao = null;
@@ -3814,6 +3807,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
             throw new InvalidParameterValueException("Network is not in the right state to
be restarted. Correct states are: " + Network.State.Implemented + ", " + Network.State.Setup);
         }
 
+        // don't allow clenaup=true for the network in Basic zone
+        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        if (zone.getNetworkType() == NetworkType.Basic && cleanup) {
+            throw new InvalidParameterValueException("Cleanup can't be true when restart
network in Basic zone");
+        }
+
         _accountMgr.checkAccess(callerAccount, null, true, network);
 
         boolean success = restartNetwork(networkId, callerAccount, callerUser, cleanup);
@@ -3858,6 +3857,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
         ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
 
         if (cleanup) {
+            if (network.getGuestType() != GuestType.Isolated) {
+                s_logger.warn("Only support clean up network for isolated network!");
+                return false;
+            }
             // shutdown the network
             s_logger.debug("Shutting down the network id=" + networkId + " as a part of network
restart");
 
@@ -3870,43 +3873,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
             s_logger.debug("Skip the shutting down of network id=" + networkId);
         }
 
+        // implement the network elements and rules again
+        DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()),
null, null, null);
+
         s_logger.debug("Implementing the network " + network + " elements and resources as
a part of network restart");
         NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
 
         try {
-            DataCenter dc = _dcDao.findById(network.getDataCenterId());
-            //Pod based network restart for basic network, one VR per pod
-            if (dc.getNetworkType() == NetworkType.Basic) {
-                //Loop through all pods with running user vms and restart network
-                for (HostPodVO pod: _podDao.listByDataCenterId(dc.getId())) {
-                    s_logger.debug("Trying to restart network for Pod: " + pod.getName()
+ ", id=" + pod.getId());
-                    //If cleanup is false, don't implement network on running VRs
-                    List<DomainRouterVO> virtualRouters = _domainRouterDao.listByPodId(pod.getId());
-                    Boolean podHasSingleVR = (virtualRouters.size() == 1);
-                    if (!podHasSingleVR) {
-                        s_logger.warn("Pod should have only one VR in Basic Zone, please
check!");
-                    }
-                    if (!cleanup && virtualRouters != null && podHasSingleVR
-                            && virtualRouters.get(0).getState() == VirtualMachine.State.Running)
{
-                        s_logger.debug("Cleanup=false: Found a running VR, skipping network
implementation for the pod");
-                        continue;
-                    }
-                    //Implement network only if there are running user vms in 'pod'
-                    List<VMInstanceVO> vms = _vmDao.listByPodId(pod.getId());
-                    for (VMInstanceVO vm: vms) {
-                        // implement the network elements and rules again
-                        if (vm.getType() == Type.User && vm.getState() == VirtualMachine.State.Running)
{
-                            DeployDestination dest = new DeployDestination(dc, pod, null,
null);
-                            implementNetworkElementsAndResources(dest, context, network,
offering);
-                            break;
-                        }
-                    }
-                }
-            } else {
-                // implement the network elements and rules again
-                DeployDestination dest = new DeployDestination(dc, null, null, null);
-                implementNetworkElementsAndResources(dest, context, network, offering);
-            }
+            implementNetworkElementsAndResources(dest, context, network, offering);
             setRestartRequired(network, true);
         } catch (Exception ex) {
             s_logger.warn("Failed to implement network " + network + " elements and resources
as a part of network restart due to ", ex);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6b65299/server/src/com/cloud/vm/dao/DomainRouterDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/DomainRouterDao.java b/server/src/com/cloud/vm/dao/DomainRouterDao.java
index d8e8cd8..01e3258 100755
--- a/server/src/com/cloud/vm/dao/DomainRouterDao.java
+++ b/server/src/com/cloud/vm/dao/DomainRouterDao.java
@@ -61,14 +61,7 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO,
Long> {
      */
     public List<DomainRouterVO> listByHostId(Long hostId);
     public List<DomainRouterVO> listByLastHostId(Long hostId);
-
-    /**
-     * virtual machine routers.
-     * @param podId id of the pod.  null if to get all.
-     * @return list of DomainRouterVO
-     */
-    public List<DomainRouterVO> listByPodId(Long podId);
-
+    
     /**
      * list virtual machine routers by host id.
      * pass in null to get all

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6b65299/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
index 2948500..175d3f2 100755
--- a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
@@ -178,13 +178,6 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO,
Long> im
     }
 
     @Override
-    public List<DomainRouterVO> listByPodId(Long podId) {
-        SearchCriteria<DomainRouterVO> sc = AllFieldsSearch.create();
-        sc.setParameters("podId", podId);
-       return listBy(sc);
-    }
-
-    @Override
     public List<DomainRouterVO> listIsolatedByHostId(Long hostId) {
         SearchCriteria<DomainRouterVO> sc = HostUpSearch.create();
         if (hostId != null) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6b65299/server/src/com/cloud/vm/dao/VMInstanceDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/VMInstanceDao.java b/server/src/com/cloud/vm/dao/VMInstanceDao.java
index 9a261aa..2cf3d75 100644
--- a/server/src/com/cloud/vm/dao/VMInstanceDao.java
+++ b/server/src/com/cloud/vm/dao/VMInstanceDao.java
@@ -46,14 +46,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>,
StateDao<
 	 * @return list of VMInstanceVO in the specified zone
 	 */
 	List<VMInstanceVO> listByZoneId(long zoneId);
-
-    /**
-     * List VMs by pod ID
-     * @param podId
-     * @return list of VMInstanceVO in the specified pod
-     */
-    List<VMInstanceVO> listByPodId(long podId);
-
+	
 	/**
 	 * Lists non-expunged VMs by zone ID and templateId
 	 * @param zoneId

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6b65299/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index 7f1c5b2..571b5d1 100644
--- a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -127,7 +127,6 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO,
Long> implem
         AllFieldsSearch.and("lastHost", AllFieldsSearch.entity().getLastHostId(), Op.EQ);
         AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
         AllFieldsSearch.and("zone", AllFieldsSearch.entity().getDataCenterIdToDeployIn(),
Op.EQ);
-        AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodIdToDeployIn(), Op.EQ);
         AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), Op.EQ);
         AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
         AllFieldsSearch.done();
@@ -231,14 +230,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO,
Long> implem
 
         return listBy(sc);
     }
-
-    @Override
-    public List<VMInstanceVO> listByPodId(long podId) {
-        SearchCriteria<VMInstanceVO> sc = AllFieldsSearch.create();
-        sc.setParameters("pod", podId);
-        return listBy(sc);
-    }
-
+    
     @Override
     public List<VMInstanceVO> listByClusterId(long clusterId) {
         SearchCriteria<VMInstanceVO> sc = VMClusterSearch.create();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6b65299/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index d239cad..d0f65c4 100644
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -604,9 +604,15 @@
 											success: function(json){											  
 											  zoneObj = json.listzonesresponse.zone[0];												
 											}
-                                        });
-                                        args.$form.find('.form-item[rel=cleanup]').find('input').attr('checked',
'checked'); //checked
-                                        args.$form.find('.form-item[rel=cleanup]').css('display',
'inline-block'); //shown
+										});																				
+										if(zoneObj.networktype == "Basic") {										  								
+											args.$form.find('.form-item[rel=cleanup]').find('input').removeAttr('checked');
//unchecked
+											args.$form.find('.form-item[rel=cleanup]').hide(); //hidden
+										}
+										else {										  												
+											args.$form.find('.form-item[rel=cleanup]').find('input').attr('checked', 'checked');
//checked											
+											args.$form.find('.form-item[rel=cleanup]').css('display', 'inline-block'); //shown
+                    }											
 									},
 									fields: {
                     cleanup: {


Mime
View raw message