cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/3] git commit: VPC: plug guest nic on guest network implement, and unplug on shutdown
Date Tue, 19 Jun 2012 17:09:50 GMT
Updated Branches:
  refs/heads/vpc 03fe667b7 -> 19f648f1a


VPC: plug guest nic on guest network implement, and unplug on shutdown

Conflicts:

	server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java


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

Branch: refs/heads/vpc
Commit: 19f648f1aa36e107368da26b3e6f8567d6f0a3b7
Parents: 89d7e54
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Jun 19 09:41:30 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Jun 19 10:09:46 2012 -0700

----------------------------------------------------------------------
 .../network/element/VpcVirtualRouterElement.java   |   64 ++++++++++-----
 .../router/VirtualNetworkApplianceManagerImpl.java |    2 -
 2 files changed, 43 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/19f648f1/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index e5ae27e..794503b 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -149,6 +149,17 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements
Vpc
                    DataCenter.class, network.getDataCenterId());
        }
        
+       for (VirtualRouter router : routers) {
+           //Add router to guest network
+           if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
+               if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(router, network, false)) {
+                   throw new CloudRuntimeException("Failed to add VPC router " + router +
" to guest network " + network);
+               } else {
+                   s_logger.debug("Successfully added VPC router " + router + " to guest
network " + network);
+               }
+           }
+       }
+       
        return true;       
     }
     
@@ -169,28 +180,16 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements
Vpc
             return false;
         }
         
-        Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param,
Object>(1);
-        params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
-        
-        List<DomainRouterVO> routers = _vpcRouterMgr.deployVirtualRouterInVpc(vpc,
dest, 
-                _accountMgr.getAccount(vpc.getAccountId()), params);
-        if ((routers == null) || (routers.size() == 0)) {
-            throw new ResourceUnavailableException("Can't find at least one running router!",
-                    DataCenter.class, network.getDataCenterId());
-        }
-        
         if (vm.getType() == Type.User) {
-            for (VirtualRouter router : routers) {
-                //Add router to guest network
-                if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
-                    if (!_vpcRouterMgr.addVpcRouterToGuestNetwork(router, network, false))
{
-                        throw new CloudRuntimeException("Failed to add VPC router " + router
+ " to guest network " + network);
-                    } else {
-                        s_logger.debug("Successfully added VPC router " + router + " to guest
network " + network);
-                    }
-                } 
+            Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param,
Object>(1);
+            params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
+            List<DomainRouterVO> routers = _vpcRouterMgr.deployVirtualRouterInVpc(vpc,
dest, 
+                    _accountMgr.getAccount(vpc.getAccountId()), params);
+            if ((routers == null) || (routers.size() == 0)) {
+                throw new ResourceUnavailableException("Can't find at least one running router!",
+                        DataCenter.class, network.getDataCenterId());
             }
-        } 
+        }
        
         return true;
     }
@@ -198,7 +197,30 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements
Vpc
     @Override
     public boolean shutdown(Network network, ReservationContext context, boolean cleanup)

             throws ConcurrentOperationException, ResourceUnavailableException {
-        return true;
+        boolean success = true;
+        Long vpcId = network.getVpcId();
+        if (vpcId == null) {
+            s_logger.debug("Network " + network + " doesn't belong to any vpc, so skipping
unplug nic part");
+            return success;
+        }
+        
+        List<? extends VirtualRouter> routers = _routerDao.listRoutersByVpcId(vpcId);
+        for (VirtualRouter router : routers) {
+            //1) Check if router is already a part of the network
+            if (!_ntwkService.isVmPartOfNetwork(router.getId(), network.getId())) {
+                s_logger.debug("Router " + router + " is not a part the network " + network);
+                continue;
+            }
+            //2) Call unplugNics in the network service
+            success = success && _vpcRouterMgr.removeRouterFromGuestNetwork(router,
network, false);
+            if (!success) {
+                s_logger.warn("Failed to unplug nic in network " + network + " for virtual
router " + router);
+            } else {
+                s_logger.debug("Successfully unplugged nic in network " + network + " for
virtual router " + router);
+            }
+        }
+        
+        return success;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/19f648f1/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index c64067b..ee13718 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1254,8 +1254,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                 return null;
             }
             
-    
-            
             Long offeringId = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId();
             if (offeringId == null) {
                 offeringId = _offering.getId();


Mime
View raw message