incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke4...@apache.org
Subject [15/50] git commit: CS-15055: DB exception when creating n1kv VSM when adding a cluster via the latest management server GUI.
Date Sun, 27 May 2012 22:30:43 GMT
CS-15055: DB exception when creating n1kv VSM when adding a cluster via the latest management
server GUI.

Description:

	Adding an optional flag to the addCluster command,
	"addvsmflag". If this is set to true, the API will
	throw an exception if any VSM parameter is missed
	out. The above bug was running into a DB exception
	because the vCenter ipaddress wasn't passed in and
	the API didn't catch it.


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

Branch: refs/heads/master
Commit: 82ffddc7b8ceee55b76be73f8877f07104c46458
Parents: ed0ba1a
Author: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Authored: Tue May 22 17:54:32 2012 -0700
Committer: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Committed: Fri May 25 18:28:10 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/api/ApiConstants.java            |    1 +
 api/src/com/cloud/api/commands/AddClusterCmd.java  |    7 ++
 .../com/cloud/resource/ResourceManagerImpl.java    |   85 ++++++++-------
 3 files changed, 53 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/82ffddc7/api/src/com/cloud/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java
index f678e07..6ef4b32 100755
--- a/api/src/com/cloud/api/ApiConstants.java
+++ b/api/src/com/cloud/api/ApiConstants.java
@@ -354,6 +354,7 @@ public class ApiConstants {
     public static final String VSM_CONFIG_MODE = "vsmconfigmode";
     public static final String VSM_CONFIG_STATE = "vsmconfigstate";
     public static final String VSM_DEVICE_STATE = "vsmdevicestate";
+    public static final String ADD_VSM_FLAG = "addvsmflag";
     
     public enum HostDetails {
         all, capacity, events, stats, min;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/82ffddc7/api/src/com/cloud/api/commands/AddClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AddClusterCmd.java b/api/src/com/cloud/api/commands/AddClusterCmd.java
index c8f7eae..cb2df87 100755
--- a/api/src/com/cloud/api/commands/AddClusterCmd.java
+++ b/api/src/com/cloud/api/commands/AddClusterCmd.java
@@ -81,6 +81,13 @@ public class AddClusterCmd extends BaseCmd {
     @Parameter(name = ApiConstants.VCENTER_DC_NAME, type = CommandType.STRING, required =
false, description = "the name of the vCenter Data Center the VSM associated with this cluster
will serve")
     private String vcenterdcname;
     
+    @Parameter(name = ApiConstants.ADD_VSM_FLAG, type = CommandType.STRING, required = false,
description = "flag that indicates a Cisco Nexus 1000v VSM is being associated with this cluster")
+    private String addVSMFlag;
+    
+    public String getAddVSMFlag() {
+    	return addVSMFlag;
+    }
+    
     public String getvCenterDCName() {
     	return vcenterdcname;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/82ffddc7/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 62653c0..22700fc 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -430,48 +430,53 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService,
Ma
         }
         clusterId = cluster.getId();
         result.add(cluster);
-
-        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) {
-            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);
+        
+        if (cmd.getAddVSMFlag().equalsIgnoreCase("true")) {
+
+        	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());
-            }
+        		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());
+        		}
             
-            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());
-            }
+        		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());
+        		}
+        	} else {
+        		throw new CloudRuntimeException("All required parameters for VSM not specified");
+        	}
         }
 
         if (clusterType == Cluster.ClusterType.CloudManaged) {


Mime
View raw message