cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject git commit: updated refs/heads/master to f43f3bb
Date Thu, 08 Aug 2013 13:49:24 GMT
Updated Branches:
  refs/heads/master 320663df7 -> f43f3bb95


CLOUDSTACK-2558 Nexus configuration cleanup is not done when there is a failure while adding
the Nexus enabled VMWARE cluster which is causing for NPE while readding the cluster with
same configuration details

If cluster addition fails then cleaning up the Nexus VSM related to the cluster.

Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>


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

Branch: refs/heads/master
Commit: f43f3bb95e20431dd793477c24b9632eed8feb28
Parents: 320663d
Author: Sateesh Chodapuneedi <sateesh@apache.org>
Authored: Thu Aug 8 13:46:59 2013 +0530
Committer: Sateesh Chodapuneedi <sateesh@apache.org>
Committed: Thu Aug 8 13:49:11 2013 +0530

----------------------------------------------------------------------
 .../vmware/VmwareServerDiscoverer.java          | 19 +++++++----
 .../network/element/CiscoNexusVSMElement.java   | 36 ++++++++++++--------
 .../element/CiscoNexusVSMElementService.java    |  7 ++--
 3 files changed, 37 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f43f3bb9/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index 33bc3e8..5d48dee 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -27,12 +27,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
-
-import com.vmware.vim25.ClusterDasConfigInfo;
-import com.vmware.vim25.ManagedObjectReference;
-
 import org.apache.cloudstack.api.ApiConstants;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
@@ -79,7 +75,10 @@ import com.cloud.storage.Storage.TemplateType;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.Account;
+import com.cloud.utils.Pair;
 import com.cloud.utils.UriUtils;
+import com.vmware.vim25.ClusterDasConfigInfo;
+import com.vmware.vim25.ManagedObjectReference;
 
 
 @Local(value = Discoverer.class)
@@ -291,7 +290,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
 		if (privateTrafficLabel != null) {
             s_logger.info("Detected private network label : " + privateTrafficLabel);
 		}
-
+        Pair<Boolean, Long> vsmInfo = new Pair<Boolean, Long>(false, 0L);
         if (nexusDVS) {
 			if (zoneType != NetworkType.Basic) {
                 publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware);
@@ -309,7 +308,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
             String vsmPassword = _urlParams.get("vsmpassword");
             String clusterName = cluster.getName();
             try {
-                _nexusElement.validateVsmCluster(vsmIp, vsmUser, vsmPassword, clusterId,
clusterName);
+                vsmInfo = _nexusElement.validateAndAddVsm(vsmIp, vsmUser, vsmPassword, clusterId,
clusterName);
             } catch(ResourceInUseException ex) {
                 DiscoveryException discEx = new DiscoveryException(ex.getLocalizedMessage()
+ ". The resource is " + ex.getResourceName());
                 throw discEx;
@@ -435,6 +434,12 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
 		} finally {
 			if (context != null)
 				context.close();
+            if (vsmInfo.first()) {
+                try {
+                    _nexusElement.deleteCiscoNexusVSM(vsmInfo.second().longValue());
+                } catch(Exception e) {
+                }
+            }
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f43f3bb9/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
index e1f4a27..6c6ce55 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
@@ -17,11 +17,9 @@
 
 package com.cloud.network.element;
 
-import java.lang.Class;
-import java.lang.String;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.ArrayList;
 import java.util.Set;
 
 import javax.ejb.Local;
@@ -30,8 +28,8 @@ import javax.inject.Inject;
 import org.apache.log4j.Logger;
 
 import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
-import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
 import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
+import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
 import com.cloud.api.commands.ListCiscoNexusVSMsCmd;
 import com.cloud.api.response.CiscoNexusVSMResponse;
 import com.cloud.configuration.Config;
@@ -44,29 +42,30 @@ import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceInUseException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.CiscoNexusVSMDeviceVO;
 import com.cloud.network.CiscoNexusVSMDevice;
 import com.cloud.network.CiscoNexusVSMDeviceManagerImpl;
+import com.cloud.network.CiscoNexusVSMDeviceVO;
 import com.cloud.network.Network;
-import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
+import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.org.Cluster;
+import com.cloud.server.ManagementService;
+import com.cloud.utils.Pair;
 import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
-import com.cloud.exception.ResourceInUseException;
 import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.server.ManagementService;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = NetworkElement.class)
 public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl implements CiscoNexusVSMElementService,
NetworkElement, Manager {
@@ -261,7 +260,10 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl
impleme
     }
 
     @DB
-    public boolean validateVsmCluster(String vsmIp, String vsmUser, String vsmPassword, long
clusterId, String clusterName) throws ResourceInUseException {
+    public Pair<Boolean, Long> validateAndAddVsm(String vsmIp, String vsmUser, String
vsmPassword, long clusterId, String clusterName) throws ResourceInUseException {
+        CiscoNexusVSMDeviceVO vsm = null;
+        boolean vsmAdded = false;
+        Long vsmId = 0L;
         if(vsmIp != null && vsmUser != null && vsmPassword != null) {
             NetconfHelper netconfClient;
             try {
@@ -277,7 +279,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl
impleme
             Transaction txn;
 
             // If VSM already exists and is mapped to a cluster, fail this operation.
-            CiscoNexusVSMDeviceVO vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
+            vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
             if(vsm != null) {
                 List<ClusterVSMMapVO> clusterList = _clusterVSMDao.listByVSMId(vsm.getId());
                 if (clusterList != null && !clusterList.isEmpty()) {
@@ -343,6 +345,10 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl
impleme
             _clusterDao.remove(clusterId);
             throw new CloudRuntimeException(msg);
         }
-        return true;
+        if (vsm != null) {
+            vsmAdded = true;
+            vsmId = vsm.getId();
+        }
+        return new Pair<Boolean, Long>(vsmAdded, vsmId);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f43f3bb9/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
index e90581a..7d1618c 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
@@ -20,13 +20,14 @@ package com.cloud.network.element;
 import java.util.List;
 
 import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
-import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
 import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
+import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
 import com.cloud.api.commands.ListCiscoNexusVSMsCmd;
 import com.cloud.api.response.CiscoNexusVSMResponse;
 import com.cloud.exception.ResourceInUseException;
-import com.cloud.network.CiscoNexusVSMDeviceVO;
 import com.cloud.network.CiscoNexusVSMDevice;
+import com.cloud.network.CiscoNexusVSMDeviceVO;
+import com.cloud.utils.Pair;
 import com.cloud.utils.component.PluggableService;
 
 public interface CiscoNexusVSMElementService extends PluggableService {
@@ -74,5 +75,5 @@ public interface CiscoNexusVSMElementService extends PluggableService {
      * Validate Cisco Nexus VSM before associating with cluster
      *
      */
-    public boolean validateVsmCluster(String vsmIp, String vsmUser, String vsmPassword, long
clusterId, String clusterName) throws ResourceInUseException;
+    public Pair<Boolean, Long> validateAndAddVsm(String vsmIp, String vsmUser, String
vsmPassword, long clusterId, String clusterName) throws ResourceInUseException;
 }


Mime
View raw message