You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/05/28 00:30:43 UTC

[12/50] git commit: CS-9919: Support for Nexus Swiches (Cisco Vswitches)

CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Updating the checks for VSM parameter validation while adding cluster.

Conflicts:

	server/src/com/cloud/resource/ResourceManagerImpl.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/70fbee2c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/70fbee2c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/70fbee2c

Branch: refs/heads/master
Commit: 70fbee2cf256b2b69af847c656ff133b771cacf1
Parents: 63de97e
Author: Sateesh Chodapuneedi <sa...@citrix.com>
Authored: Wed May 23 16:24:07 2012 +0530
Committer: Vijayendra Bhamidipati <vi...@citrix.com>
Committed: Fri May 25 18:31:49 2012 -0700

----------------------------------------------------------------------
 .../com/cloud/resource/ResourceManagerImpl.java    |  107 +++++++++------
 1 files changed, 65 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70fbee2c/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 4add897..6daffab 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -431,51 +431,74 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
         clusterId = cluster.getId();
         result.add(cluster);
         
-        if (cmd.getAddVSMFlag() != null && cmd.getAddVSMFlag().equalsIgnoreCase("true")) {
-
+        if (hypervisorType == HypervisorType.VMware &&
+        		Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) {
         	String vsmIp = cmd.getVSMIpaddress();
-        	String vsmUser = cmd.getVSMUsername();
-        	String vsmPassword = cmd.getVSMPassword();
-        	String vCenterIpaddr = cmd.getvCenterIPAddr();
-        	String vCenterDcName = cmd.getvCenterDCName();
-
-        	if (vsmIp != null && vsmUser != null && vsmPassword != null && vCenterIpaddr != null && vCenterDcName != null) {
-        		NetconfHelper netconfClient;
-        		try {
-        			netconfClient = new NetconfHelper(vsmIp, vsmUser, vsmPassword);
-        			netconfClient.disconnect();
-        		} catch (CloudRuntimeException e) {
-        			String msg = "Invalid credentials supplied for user " + vsmUser + " for Cisco Nexus 1000v VSM at " + vsmIp;
-        			s_logger.error(msg);
-        			throw new CloudRuntimeException(msg);
-        		}
-        		// persist credentials in database
-        		CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword, vCenterIpaddr, vCenterDcName);
-            
-        		Transaction txn = Transaction.currentTxn();
-        		try {
-        			txn.start();
-        			vsm = _vsmDao.persist(vsm);
-        			txn.commit();
-        		} catch (Exception e) {
-        			txn.rollback();
-        			s_logger.error("Failed to persist VSM details to database. Exception: " + e.getMessage());
-        			throw new CloudRuntimeException(e.getMessage());
+            String vsmUser = cmd.getVSMUsername();
+            String vsmPassword = cmd.getVSMPassword();
+            String vCenterIpaddr = cmd.getvCenterIPAddr();
+            String vCenterDcName = cmd.getvCenterDCName();
+
+        	if(vsmIp != null && vsmUser != null && vsmPassword != null) {
+	            NetconfHelper netconfClient;
+	            try {
+	                netconfClient = new NetconfHelper(vsmIp, vsmUser, vsmPassword);
+	                netconfClient.disconnect();
+	            } catch (CloudRuntimeException e) {
+	                String msg = "Invalid credentials supplied for user " + vsmUser + " for Cisco Nexus 1000v VSM at " + vsmIp;
+	                s_logger.error(msg);
+		            _clusterDao.remove(clusterId);
+	                throw new CloudRuntimeException(msg);
+	            }
+	            // persist credentials to database
+	            CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword, vCenterIpaddr, vCenterDcName);
+	            
+	            Transaction txn = Transaction.currentTxn();
+	            try {
+	                txn.start();
+	                vsm = _vsmDao.persist(vsm);
+	                txn.commit();
+	            } catch (Exception e) {
+	                txn.rollback();	                
+	                s_logger.error("Failed to persist Cisco Nexus 1000v VSM details to database. Exception: " + e.getMessage());
+	                // Removing the cluster record which was added already because the persistence of Nexus VSM credentials has failed. 
+		            _clusterDao.remove(clusterId);
+	                throw new CloudRuntimeException(e.getMessage());
+	            }
+	            
+	            ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
+	            txn = Transaction.currentTxn();
+	            try {
+	                txn.start();
+	                _clusterVSMDao.persist(connectorObj);
+	                txn.commit();
+	            } catch (Exception e) {
+	                txn.rollback();
+	                s_logger.error("Failed to associate Cisco Nexus 1000v VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
+	                _clusterDao.remove(clusterId);
+	                throw new CloudRuntimeException(e.getMessage());
+	            }
+        	} else {
+        		String msg;
+        		msg = "The global parameter " + Config.VmwareUseNexusVSwitch.toString() + 
+        				" is set to \"true\". Following mandatory parameters are not specified. ";
+        		if(vsmIp == null) {
+        			msg += "vsmipaddress: Management IP address of Cisco Nexus 1000v dvSwitch. "; 
+        		} 
+        		if(vsmUser == null) {
+        			msg += "vsmusername: Name of a user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
         		}
-            
-        		ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
-        		txn = Transaction.currentTxn();
-        		try {
-        			txn.start();
-        			_clusterVSMDao.persist(connectorObj);
-        			txn.commit();
-        		} catch (Exception e) {
-        			txn.rollback();
-        			s_logger.error("Failed to associate VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
-        			throw new CloudRuntimeException(e.getMessage());
+        		if(vsmPassword == null) {
+        			if(vsmUser != null) {
+        				msg += "vsmpassword: Password of user account " + vsmUser + ". ";
+        			} else {
+        				msg += "vsmpassword: Password of user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";        				
+        			}
         		}
-        	} else {
-        		throw new CloudRuntimeException("All required parameters for VSM not specified");
+        		s_logger.error(msg);
+        		// Cleaning up the cluster record as addCluster operation failed because Nexus dvSwitch credentials are supplied.
+	            _clusterDao.remove(clusterId);
+        		throw new CloudRuntimeException(msg);
         	}
         }