cloudstack-commits mailing list archives

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

Description:

	More changes incorporating Alena's review comments:

	  1. Changed id to clusterId for better naming.

	  2. Changed the name of GetCiscoVSMByClusterIdCmd
	     to ListCiscoVSMDetailsCmd.

	  3. Removed the GetCiscoVSMDetailsCmd command.

	  4. Removed catch{} blocks in each of the Nexus
	     related APIs since the exceptions raised in
	     the API implementations will be caught in the
   	     command dispatcher.

	  5. Added ActionEvent annotation to
	     deleteCiscoNexusVSM() function.

	  6. Modified each Nexus API command's
	     getEntityOwnerId() to return
	     Account.ACCOUNT_ID_SYSTEM.


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

Branch: refs/heads/master
Commit: ffaa8cc20ada47eb3c94cc309feb0dc91014dc4c
Parents: e724684
Author: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Authored: Mon May 21 21:10:56 2012 -0700
Committer: Vijayendra Bhamidipati <vijayendra.bhamidipati@citrix.com>
Committed: Fri May 25 18:23:51 2012 -0700

----------------------------------------------------------------------
 .../cisconexusvsm_commands.properties.in           |    3 +-
 .../cloud/api/commands/DeleteCiscoNexusVSMCmd.java |   25 ++---
 .../api/commands/DisableCiscoNexusVSMCmd.java      |   25 ++---
 .../cloud/api/commands/EnableCiscoNexusVSMCmd.java |   25 ++---
 .../api/commands/GetCiscoVSMByClusterIdCmd.java    |   99 ---------------
 .../cloud/api/commands/GetCiscoVSMDetailsCmd.java  |   95 --------------
 .../cloud/api/commands/ListCiscoVSMDetailsCmd.java |   91 +++++++++++++
 .../network/element/CiscoNexusVSMElement.java      |   19 +--
 .../element/CiscoNexusVSMElementService.java       |   12 +--
 9 files changed, 128 insertions(+), 266 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/client/tomcatconf/cisconexusvsm_commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/cisconexusvsm_commands.properties.in b/client/tomcatconf/cisconexusvsm_commands.properties.in
index f689460..8732357 100644
--- a/client/tomcatconf/cisconexusvsm_commands.properties.in
+++ b/client/tomcatconf/cisconexusvsm_commands.properties.in
@@ -5,5 +5,4 @@
 deleteCiscoNexusVSM = com.cloud.api.commands.DeleteCiscoNexusVSMCmd;1
 enableCiscoNexusVSM = com.cloud.api.commands.EnableCiscoNexusVSMCmd;1
 disableCiscoNexusVSM = com.cloud.api.commands.DisableCiscoNexusVSMCmd;1
-getCiscoVSMByClusterId = com.cloud.api.commands.GetCiscoVSMByClusterIdCmd;1
-getCiscoVSMDetails = com.cloud.api.commands.GetCiscoVSMDetailsCmd;1
+listCiscoVSMDetails = com.cloud.api.commands.ListCiscoVSMDetailsCmd;1

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/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 886ef1b..e684703 100644
--- a/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
+++ b/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
@@ -31,12 +31,11 @@ import com.cloud.api.response.SuccessResponse;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.element.CiscoNexusVSMElementService;
+import com.cloud.user.Account;
 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 BaseAsyncCmd {
@@ -67,19 +66,13 @@ public class DeleteCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException {
-        try {
-            boolean result = _ciscoNexusVSMService.deleteCiscoNexusVSM(this);
-            if (result) {
-                SuccessResponse response = new SuccessResponse(getCommandName());
-                response.setResponseName(getCommandName());
-                this.setResponseObject(response);
-            } else {
-                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to delete
Cisco Nexus VSM device");
-            }
-        }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
-        } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
+    	boolean result = _ciscoNexusVSMService.deleteCiscoNexusVSM(this);
+        if (result) {
+        	SuccessResponse response = new SuccessResponse(getCommandName());
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+        	throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to delete Cisco
Nexus VSM device");
         }
     }
 
@@ -90,7 +83,7 @@ public class DeleteCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return Account.ACCOUNT_ID_SYSTEM;
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/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 bef7ef4..8700086 100644
--- a/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
+++ b/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
@@ -30,12 +30,11 @@ import com.cloud.api.ServerApiException;
 import com.cloud.api.response.SuccessResponse;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.element.CiscoNexusVSMElementService;
+import com.cloud.user.Account;
 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")
@@ -67,19 +66,13 @@ public class DisableCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException {
-        try {
-            boolean result = _ciscoNexusVSMService.disableCiscoNexusVSM(this);
-            if (result) {
-                SuccessResponse response = new SuccessResponse(getCommandName());
-                response.setResponseName(getCommandName());
-                this.setResponseObject(response);
-            } else {
-                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to disable
Cisco Nexus VSM device");
-            }
-        }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
-        } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
+    	boolean result = _ciscoNexusVSMService.disableCiscoNexusVSM(this);
+        if (result) {
+        	SuccessResponse response = new SuccessResponse(getCommandName());
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+        	throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to disable Cisco
Nexus VSM device");
         }
     }
 
@@ -90,7 +83,7 @@ public class DisableCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return Account.ACCOUNT_ID_SYSTEM;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/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 0f216d6..af85a86 100644
--- a/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
+++ b/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
@@ -31,12 +31,11 @@ import com.cloud.api.response.SuccessResponse;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.element.CiscoNexusVSMElementService;
+import com.cloud.user.Account;
 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 BaseAsyncCmd {
@@ -67,19 +66,13 @@ public class EnableCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException {
-        try {
-            boolean result = _ciscoNexusVSMService.enableCiscoNexusVSM(this);
-            if (result) {
-                SuccessResponse response = new SuccessResponse(getCommandName());
-                response.setResponseName(getCommandName());
-                this.setResponseObject(response);
-            } else {
-                throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to enable
Cisco Nexus VSM device");
-            }
-        }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseAsyncCmd.PARAM_ERROR, invalidParamExcp.getMessage());
-        } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
+    	boolean result = _ciscoNexusVSMService.enableCiscoNexusVSM(this);
+        if (result) {
+        	SuccessResponse response = new SuccessResponse(getCommandName());
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+        	throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to enable Cisco
Nexus VSM device");
         }
     }
 
@@ -90,7 +83,7 @@ public class EnableCiscoNexusVSMCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
+        return Account.ACCOUNT_ID_SYSTEM;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/server/src/com/cloud/api/commands/GetCiscoVSMByClusterIdCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/GetCiscoVSMByClusterIdCmd.java b/server/src/com/cloud/api/commands/GetCiscoVSMByClusterIdCmd.java
deleted file mode 100755
index e46cd7e..0000000
--- a/server/src/com/cloud/api/commands/GetCiscoVSMByClusterIdCmd.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- *  Copyright (C) 2011 Citrix Systems, Inc.  All rights reserved.
- * 
- * This software is licensed under the GNU General Public License v3 or later.
- * 
- * It is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- * 
- */
-
-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;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.CiscoNexusVSMResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.CiscoNexusVSMDevice;
-import com.cloud.network.element.CiscoNexusVSMElementService;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=CiscoNexusVSMResponse.class, description="Retrieves a Cisco
Nexus 1000v Virtual Switch Manager device associated with a Cluster")
-public class GetCiscoVSMByClusterIdCmd extends BaseCmd {
-
-    public static final Logger s_logger = Logger.getLogger(GetCiscoVSMByClusterIdCmd.class.getName());
-    private static final String s_name = "getciscovsmbyclusteridcmdresponse";
-    @PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="cluster")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required = true, description="Id
of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.")
-    private long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-    
-    public long getClusterId() {
-    	return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    // NOTE- The uuid that is sent in during the invocation of the API AddCiscoNexusVSM()
-    // automagically gets translated to the corresponding db id before this execute() method
-    // is invoked. That's the reason why we don't have any uuid-dbid translation code here.
-    @Override
-    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException {
-        try {
-            CiscoNexusVSMDevice vsmDevice = _ciscoNexusVSMService.getCiscoNexusVSMByClusId(this);
-            if (vsmDevice != null) {
-                CiscoNexusVSMResponse response = _ciscoNexusVSMService.createCiscoNexusVSMResponse(vsmDevice);
-                response.setObjectName("cisconexusvsm");
-                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.");
-            }
-        }  catch (InvalidParameterValueException invalidParamExcp) {
-            throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
-        } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
-        }
-    }
- 
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/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
deleted file mode 100755
index 37a8892..0000000
--- a/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *  Copyright (C) 2011 Citrix Systems, Inc.  All rights reserved.
- * 
- * This software is licensed under the GNU General Public License v3 or later.
- * 
- * It is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- * 
- */
-
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.CiscoNexusVSMResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.CiscoNexusVSMDeviceVO;
-import com.cloud.network.element.CiscoNexusVSMElementService;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=CiscoNexusVSMResponse.class, description="Retrieves details
of a Cisco Nexus 1000v Virtual Switch Manager ")
-public class GetCiscoVSMDetailsCmd extends BaseCmd {
-
-    public static final Logger s_logger = Logger.getLogger(GetCiscoVSMDetailsCmd.class.getName());
-    private static final String s_name = "getciscovsmdetailscmdresponse";
-    @PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="virtual_supervisor_module")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required = true, description="Id
of the Cisco Nexus VSM appliance.")
-    private long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-    
-    public long getVSMId() {
-    	return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException {
-        try {
-            CiscoNexusVSMDeviceVO vsmDeviceVO = _ciscoNexusVSMService.getCiscoNexusVSMDetails(this);
-            if (vsmDeviceVO != null) {
-                CiscoNexusVSMResponse response = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(vsmDeviceVO);
-                response.setObjectName("cisconexusvsm");
-                response.setResponseName(getCommandName());
-                this.setResponseObject(response);
-            } else {
-                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());
-        } catch (CloudRuntimeException runtimeExcp) {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
-        }
-    }
- 
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return UserContext.current().getCaller().getId();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java b/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java
new file mode 100755
index 0000000..5a9c049
--- /dev/null
+++ b/server/src/com/cloud/api/commands/ListCiscoVSMDetailsCmd.java
@@ -0,0 +1,91 @@
+/**
+ *  Copyright (C) 2011 Citrix Systems, Inc.  All rights reserved.
+ * 
+ * This software is licensed under the GNU General Public License v3 or later.
+ * 
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * 
+ */
+
+package com.cloud.api.commands;
+
+import org.apache.log4j.Logger;
+import com.cloud.api.ApiConstants;
+import com.cloud.api.BaseCmd;
+import com.cloud.api.IdentityMapper;
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.PlugService;
+import com.cloud.api.ServerApiException;
+import com.cloud.api.response.CiscoNexusVSMResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.CiscoNexusVSMDevice;
+import com.cloud.network.element.CiscoNexusVSMElementService;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(responseObject=CiscoNexusVSMResponse.class, description="Retrieves a Cisco
Nexus 1000v Virtual Switch Manager device associated with a Cluster")
+public class ListCiscoVSMDetailsCmd extends BaseCmd {
+
+    public static final Logger s_logger = Logger.getLogger(ListCiscoVSMDetailsCmd.class.getName());
+    private static final String s_name = "listciscovsmdetailscmdresponse";
+    @PlugService CiscoNexusVSMElementService _ciscoNexusVSMService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required = true, description="Id
of the CloudStack cluster in which the Cisco Nexus 1000v VSM appliance.")
+    private long clusterId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+    
+    public long getClusterId() {
+    	return clusterId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    // NOTE- The uuid that is sent in during the invocation of the API AddCiscoNexusVSM()
+    // automagically gets translated to the corresponding db id before this execute() method
+    // is invoked. That's the reason why we don't have any uuid-dbid translation code here.
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+    	CiscoNexusVSMDevice vsmDevice = _ciscoNexusVSMService.getCiscoNexusVSMByClusId(this);
+        if (vsmDevice != null) {
+        	CiscoNexusVSMResponse response = _ciscoNexusVSMService.createCiscoNexusVSMDetailedResponse(vsmDevice);
+        	response.setObjectName("cisconexusvsm");
+        	response.setResponseName(getCommandName());
+        	this.setResponseObject(response);
+        } else {
+        	throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to retrieve Cisco Nexus
Virtual Switch Manager for the specified cluster due to an internal error.");
+        }
+    }
+ 
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
index bc89caf..0e60fdd 100644
--- a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
+++ b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
@@ -23,13 +23,14 @@ import com.cloud.agent.AgentManager;
 import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
 import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
 import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
-import com.cloud.api.commands.GetCiscoVSMByClusterIdCmd;
-import com.cloud.api.commands.GetCiscoVSMDetailsCmd;
+import com.cloud.api.commands.ListCiscoVSMDetailsCmd;
 import com.cloud.api.response.CiscoNexusVSMResponse;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
+import com.cloud.event.ActionEvent;
+import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
@@ -55,6 +56,7 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.network.element.NetworkElement;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.utils.component.Manager;
+import com.cloud.utils.db.DB;
 import com.cloud.exception.ResourceInUseException;
 import com.cloud.utils.exception.CloudRuntimeException;
 
@@ -159,7 +161,9 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl
impleme
     	return true;
     }
 
+
     @Override
+    @ActionEvent(eventType = EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DELETE, eventDescription
= "deleting VSM", async = true)   
     public boolean deleteCiscoNexusVSM(DeleteCiscoNexusVSMCmd cmd) {
     	boolean result;
     	try {
@@ -185,18 +189,9 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl
impleme
     	result = disableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
     	return result;
     }
-
-    @Override
-    public CiscoNexusVSMDeviceVO getCiscoNexusVSMDetails(GetCiscoVSMDetailsCmd cmd) {
-    	CiscoNexusVSMDeviceVO result = getCiscoVSMbyVSMId(cmd.getVSMId());
-    	if (result == null) {
-    		throw new CloudRuntimeException("Cisco VSM with specified Id found");
-    	}
-    	return result;
-    }
     
     @Override
-    public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(GetCiscoVSMByClusterIdCmd cmd)
{
+    public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(ListCiscoVSMDetailsCmd cmd) {
     	CiscoNexusVSMDeviceVO result = getCiscoVSMbyClusId(cmd.getClusterId());
     	if (result == null) {
     		throw new CloudRuntimeException("No Cisco VSM associated with specified Cluster Id");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ffaa8cc2/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
index 45a6263..b806e7b 100644
--- a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
+++ b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
@@ -21,8 +21,7 @@ package com.cloud.network.element;
 import com.cloud.api.commands.DeleteCiscoNexusVSMCmd;
 import com.cloud.api.commands.EnableCiscoNexusVSMCmd;
 import com.cloud.api.commands.DisableCiscoNexusVSMCmd;
-import com.cloud.api.commands.GetCiscoVSMByClusterIdCmd;
-import com.cloud.api.commands.GetCiscoVSMDetailsCmd;
+import com.cloud.api.commands.ListCiscoVSMDetailsCmd;
 import com.cloud.api.response.CiscoNexusVSMResponse;
 import com.cloud.network.CiscoNexusVSMDeviceVO;
 import com.cloud.network.CiscoNexusVSMDevice;
@@ -52,14 +51,7 @@ public interface CiscoNexusVSMElementService extends PluggableService {
      * @param GetCiscoVSMByClusterIdCmd
      * @return CiscoNexusVSMDeviceVO
      */
-    public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(GetCiscoVSMByClusterIdCmd cmd);
-    
-    /**
-     * 
-     * @param GetCiscoVSMDetailsCmd
-     * @return CiscoNexusVSMDeviceVO
-     */
-    public CiscoNexusVSMDeviceVO getCiscoNexusVSMDetails(GetCiscoVSMDetailsCmd cmd);
+    public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(ListCiscoVSMDetailsCmd cmd);
     
     /**
      * creates API response object for Cisco Nexus VSMs


Mime
View raw message