incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke4...@apache.org
Subject [24/50] git commit: CS-9919 Support for Nexus Swiches (Cisco Vswitches)
Date Sun, 27 May 2012 22:30:44 GMT
CS-9919 Support for Nexus Swiches (Cisco Vswitches)

Description:

	Modified the following commands to be Async:
		a. EnableCiscoNexusVSM
		b. DisableCiscoNexusVSM
		c. DeleteCiscoNexusVSM

	Cleaned up miscellaneous code.


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

Branch: refs/heads/master
Commit: b28568a2215a9b35792f1633554cc0240d0d7717
Parents: b3e05a7
Author: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Authored: Fri May 18 17:32:17 2012 -0700
Committer: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Committed: Fri May 25 18:11:04 2012 -0700

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java            |    5 +++-
 .../cloud/api/commands/DeleteCiscoNexusVSMCmd.java |   19 ++++++++++---
 .../api/commands/DisableCiscoNexusVSMCmd.java      |   21 +++++++++++---
 .../cloud/api/commands/EnableCiscoNexusVSMCmd.java |   19 ++++++++++---
 .../cloud/api/commands/GetCiscoVSMDetailsCmd.java  |    3 +-
 .../network/CiscoNexusVSMDeviceManagerImpl.java    |    6 ++--
 .../com/cloud/network/PortProfileManagerImpl.java  |    4 +--
 7 files changed, 53 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index ea3cb3e..eedf546 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -247,7 +247,10 @@ public class EventTypes {
     // external switch management device events (E.g.: Cisco Nexus 1000v Virtual Supervisor
Module.
     public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ADD = "SWITCH.MGMT.ADD";
     public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DELETE = "SWITCH.MGMT.DELETE";
-    public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_CONFIGURE = "SWITCH.MGMT.CONFIGURE";
   		
+    public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_CONFIGURE = "SWITCH.MGMT.CONFIGURE";
+    public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ENABLE = "SWITCH.MGMT.ENABLE";
+    public static final String EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DISABLE = "SWITCH.MGMT.DISABLE";
+
     		
     public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_ADD = "PHYSICAL.FIREWALL.ADD";
     public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE = "PHYSICAL.FIREWALL.DELETE";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java b/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
index aca0dc8..886ef1b 100644
--- a/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
+++ b/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
@@ -22,7 +22,6 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiConstants;
 import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
@@ -40,7 +39,7 @@ import com.cloud.user.UserContext;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @Implementation(responseObject=SuccessResponse.class, description=" delete a Cisco Nexus
VSM device")
-public class DeleteCiscoNexusVSMCmd extends BaseCmd {
+public class DeleteCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     public static final Logger s_logger = Logger.getLogger(DeleteCiscoNexusVSMCmd.class.getName());
     private static final String s_name = "deletecisconexusvsmresponse";
@@ -75,12 +74,12 @@ public class DeleteCiscoNexusVSMCmd extends BaseCmd {
                 response.setResponseName(getCommandName());
                 this.setResponseObject(response);
             } else {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete Cisco
Nexus VSM device");
+                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to delete
Cisco Nexus VSM device");
             }
         }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
+            throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
+            throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
         }
     }
 
@@ -93,4 +92,14 @@ public class DeleteCiscoNexusVSMCmd extends BaseCmd {
     public long getEntityOwnerId() {
         return UserContext.current().getCaller().getId();
     }
+    
+    @Override
+    public String getEventType() {
+    	return EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+    	return "Deleting a Cisco Nexus VSM device";
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java b/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
index 79de955..bef7ef4 100644
--- a/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
+++ b/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
@@ -21,7 +21,7 @@ package com.cloud.api.commands;
 import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
+import com.cloud.api.BaseAsyncCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
@@ -36,9 +36,10 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.element.CiscoNexusVSMElementService;
 import com.cloud.user.UserContext;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.event.EventTypes;
 
 @Implementation(responseObject=SuccessResponse.class, description="disable a Cisco Nexus
VSM device")
-public class DisableCiscoNexusVSMCmd extends BaseCmd {
+public class DisableCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     public static final Logger s_logger = Logger.getLogger(DisableCiscoNexusVSMCmd.class.getName());
     private static final String s_name = "disablecisconexusvsmresponse";
@@ -73,12 +74,12 @@ public class DisableCiscoNexusVSMCmd extends BaseCmd {
                 response.setResponseName(getCommandName());
                 this.setResponseObject(response);
             } else {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disable Cisco
Nexus VSM device");
+                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to disable
Cisco Nexus VSM device");
             }
         }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
+            throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
+            throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
         }
     }
 
@@ -91,4 +92,14 @@ public class DisableCiscoNexusVSMCmd extends BaseCmd {
     public long getEntityOwnerId() {
         return UserContext.current().getCaller().getId();
     }
+
+    @Override
+    public String getEventDescription() {
+    	return "Disabling a Cisco Nexus VSM device";
+    }
+
+    @Override
+    public String getEventType() {
+    	return EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DISABLE;
+    }    
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java b/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
index 15e06d7..0f216d6 100644
--- a/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
+++ b/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
@@ -22,7 +22,6 @@ import org.apache.log4j.Logger;
 
 import com.cloud.api.ApiConstants;
 import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
 import com.cloud.api.Parameter;
@@ -40,7 +39,7 @@ import com.cloud.user.UserContext;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @Implementation(responseObject=SuccessResponse.class, description="Enable a Cisco Nexus VSM
device")
-public class EnableCiscoNexusVSMCmd extends BaseCmd {
+public class EnableCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     public static final Logger s_logger = Logger.getLogger(EnableCiscoNexusVSMCmd.class.getName());
     private static final String s_name = "enablecisconexusvsmresponse";
@@ -75,12 +74,12 @@ public class EnableCiscoNexusVSMCmd extends BaseCmd {
                 response.setResponseName(getCommandName());
                 this.setResponseObject(response);
             } else {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable Cisco
Nexus VSM device");
+                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to enable
Cisco Nexus VSM device");
             }
         }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
+            throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
+            throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
         }
     }
 
@@ -93,4 +92,14 @@ public class EnableCiscoNexusVSMCmd extends BaseCmd {
     public long getEntityOwnerId() {
         return UserContext.current().getCaller().getId();
     }
+
+    @Override
+    public String getEventDescription() {
+    	return "Enabling a Cisco Nexus VSM device";
+    }
+
+    @Override
+    public String getEventType() {
+    	return EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ENABLE;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java b/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java
index d36b9ff..37a8892 100755
--- a/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java
+++ b/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java
@@ -20,7 +20,6 @@ package com.cloud.api.commands;
 
 import org.apache.log4j.Logger;
 import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
 import com.cloud.api.BaseCmd;
 import com.cloud.api.IdentityMapper;
 import com.cloud.api.Implementation;
@@ -75,7 +74,7 @@ public class GetCiscoVSMDetailsCmd extends BaseCmd {
                 response.setResponseName(getCommandName());
                 this.setResponseObject(response);
             } else {
-                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to retrieve
Cisco Nexus Virtual Switch Manager for the specified cluster due to an internal error.");
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to retrieve
Cisco Nexus Virtual Switch Manager for the specified cluster due to an internal error.");
             }
         }  catch (InvalidParameterValueException invalidParamExcp) {
             throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
index 64d8dc3..2d7ef76 100644
--- a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
@@ -109,6 +109,8 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase
{
     		throw new CloudRuntimeException(msg);
     	}
 
+    	// Disconnect from the VSM. A VSM has a default of 8 maximum parallel connections that
it allows.
+    	netconfClient.disconnect();
 
     	// Now, go ahead and associate the cluster with this VSM.
     	// First, check if VSM already exists in the table "virtual_supervisor_module".
@@ -126,9 +128,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase
{
     	} catch (Exception e) {
     		throw new CloudRuntimeException(e.getMessage());
     	}
-    	
-    	//CiscoNexusVSMDeviceVO VSMObj = _ciscoNexusVSMDeviceDao.getVSMbyDomainId(1);
-    	
+
     	if (VSMObj == null) {    		
     		// Create the VSM record. For now, we aren't using the vsmName field.
     		VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password, vCenterIpaddr, vCenterDcName);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b28568a2/server/src/com/cloud/network/PortProfileManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/PortProfileManagerImpl.java b/server/src/com/cloud/network/PortProfileManagerImpl.java
index 4771865..e7c6b36 100644
--- a/server/src/com/cloud/network/PortProfileManagerImpl.java
+++ b/server/src/com/cloud/network/PortProfileManagerImpl.java
@@ -35,15 +35,13 @@ public class PortProfileManagerImpl {
     @DB    
     public PortProfileVO addPortProfile(String portProfName, long vsmId, int vlanId, PortType
pType, BindingType bType) {
 
-    	// In this function, we create a port profile record in the port_profile table.
-    	s_logger.info("Inside addPortProfile.. name --> " + portProfName + " vsmId -->
" + vsmId + " vlan id --> " + vlanId + " pType --> " + pType + "btype --> " + bType);
+    	// In this function, we create a port profile record in the port_profile table.    

     	// First, check if a port profile with the given name already exists. If it does, throw
an exception.
     	
     	if (_portProfileDao.findByName(portProfName) != null) {
     		s_logger.info("Port Profile with specified name: " + portProfName + " already exists");
     		throw new InvalidParameterValueException("Port Profile with specified name: " + portProfName
+ " already exists");
     	}
-    	s_logger.info("Ok didn't find a portprofile by name " + portProfName);
     	// Check if the VSM id is a valid one.
     	
     	// TODO: Should we also check whether a port profile for the specified vlanId already
exists, and if so,


Mime
View raw message