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:44 UTC
[31/50] git commit: CS-9919 Support for Nexus Swiches (Cisco
Vswitches)
CS-9919 Support for Nexus Swiches (Cisco Vswitches)
Description:
Added a new API GetCiscoVSMDetailsCmd. This
API gets all details of a VSM when provided
with the VSM ID.
Resolved Conflicts:
client/tomcatconf/cisconexusvsm_commands.properties.in
Conflicts:
client/tomcatconf/cisconexusvsm_commands.properties.in
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c08716db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c08716db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c08716db
Branch: refs/heads/master
Commit: c08716db0031c6391b5f25e9c30199319f909435
Parents: b793c4c
Author: Vijayendra Bhamidipati <vi...@citrix.com>
Authored: Wed May 16 18:00:43 2012 -0700
Committer: Vijayendra Bhamidipati <vi...@citrix.com>
Committed: Fri May 25 18:06:27 2012 -0700
----------------------------------------------------------------------
api/src/com/cloud/api/ApiConstants.java | 8 ++
.../cloud/api/response/CiscoNexusVSMResponse.java | 95 ++++++++++++---
.../cisconexusvsm_commands.properties.in | 13 +-
.../cloud/api/commands/GetCiscoVSMDetailsCmd.java | 96 +++++++++++++++
.../network/CiscoNexusVSMDeviceManagerImpl.java | 5 +
.../network/element/CiscoNexusVSMElement.java | 31 +++++
.../element/CiscoNexusVSMElementService.java | 21 +++-
7 files changed, 242 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c08716db/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 300c5c1..f678e07 100755
--- a/api/src/com/cloud/api/ApiConstants.java
+++ b/api/src/com/cloud/api/ApiConstants.java
@@ -346,6 +346,14 @@ public class ApiConstants {
public static final String VSM_USERNAME = "vsmusername";
public static final String VSM_PASSWORD = "vsmpassword";
public static final String VSM_IPADDRESS = "vsmipaddress";
+ public static final String VSM_MGMT_VLAN_ID = "vsmmgmtvlanid";
+ public static final String VSM_PKT_VLAN_ID = "vsmpktvlanid";
+ public static final String VSM_CTRL_VLAN_ID = "vsmctrlvlanid";
+ public static final String VSM_STORAGE_VLAN_ID = "vsmstoragevlanid";
+ public static final String VSM_DOMAIN_ID = "vsmdomainid";
+ 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 enum HostDetails {
all, capacity, events, stats, min;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c08716db/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java b/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
index 1b80d31..3bef2ed 100644
--- a/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
+++ b/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
@@ -12,6 +12,8 @@
// Automatically generated by addcopyright.py at 04/02/2012
package com.cloud.api.response;
+import javax.persistence.Column;
+
import com.cloud.api.ApiConstants;
import com.cloud.utils.IdentityProxy;
import com.cloud.serializer.Param;
@@ -20,35 +22,48 @@ import com.google.gson.annotations.SerializedName;
public class CiscoNexusVSMResponse extends BaseResponse {
@SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_ID) @Param(description="device id of the Cisco N1KV VSM device")
- // Do we need a new table name for this? During discussion with Frank, we thought we could just use the host table.
private IdentityProxy id = new IdentityProxy("virtual_supervisor_module");
-
- // A Cisco n1kv vsm could be plumbed in multiple VLANs.. not sure what a physical network id is, so commenting it
- // out for now.
- //@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network to which this netscaler device belongs to")
- //private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
-
- // What's a provider for netscaler? Not sure if we need this for n1kv vsm, so commenting it out.
- //@SerializedName(ApiConstants.PROVIDER) @Param(description="name of the provider")
- //private String providerName;
@SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_NAME) @Param(description="device name")
private String deviceName;
- // Not sure if we need this but we'll keep it for now.. obviously we would want to know when an N1KV VSM is disabled or something.
+ @SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the management IP address of the external Cisco Nexus 1000v Virtual Supervisor Module")
+ private String vsmmgmtIpAddress;
+
@SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_STATE) @Param(description="device state")
private String deviceState;
- // Don't think we need to track the public interface/private interface of a VSM. We'd just need the ip addr.
- //@SerializedName(ApiConstants.PUBLIC_INTERFACE) @Param(description="the public interface of the load balancer")
- //private String publicInterface;
+ @SerializedName(ApiConstants.VCENTER_IP_ADDRESS) @Param(description="ipaddress of vCenter the VSM connects to")
+ private String vcenteripaddress;
+
+ @SerializedName(ApiConstants.VCENTER_DC_NAME) @Param(description="name of the vCenter Data Center the VSM is associated with")
+ private String vcenterdcname;
- //@SerializedName(ApiConstants.PRIVATE_INTERFACE) @Param(description="the private interface of the load balancer")
- //private String privateInterface;
+ @SerializedName(ApiConstants.VSM_MGMT_VLAN_ID) @Param(description="management vlan id of the VSM")
+ private String vsmmgmtvlanid;
- @SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the management IP address of the external Cisco Nexus 1000v Virtual Supervisor Module")
- private String vsmmgmtIpAddress;
+ @SerializedName(ApiConstants.VSM_CTRL_VLAN_ID) @Param(description="control vlan id of the VSM")
+ private int vsmctrlvlanid;
+
+ @SerializedName(ApiConstants.VSM_PKT_VLAN_ID) @Param(description="packet vlan id of the VSM")
+ private int vsmpktvlanid;
+ @SerializedName(ApiConstants.VSM_STORAGE_VLAN_ID) @Param(description="storage vlan id of the VSM")
+ private int vsmstoragevlanid;
+
+ @SerializedName(ApiConstants.VSM_DOMAIN_ID) @Param(description="The VSM is a switch supervisor. This is the VSM's switch domain id")
+ private String vsmdomainid;
+
+ @SerializedName(ApiConstants.VSM_CONFIG_MODE) @Param(description="The mode of the VSM (standalone/HA)")
+ private String vsmconfigmode;
+
+ @SerializedName(ApiConstants.VSM_CONFIG_STATE) @Param(description="The Config State (Primary/Standby) of the VSM")
+ private String vsmconfigstate;
+
+ @SerializedName(ApiConstants.VSM_DEVICE_STATE) @Param(description="The Device State (Enabled/Disabled) of the VSM")
+ private String vsmdevicestate;
+
+ // Setter methods.
public void setId(long vsmDeviceId) {
this.id.setValue(vsmDeviceId);
}
@@ -60,4 +75,48 @@ public class CiscoNexusVSMResponse extends BaseResponse {
public void setMgmtIpAddress(String ipAddress) {
this.vsmmgmtIpAddress = ipAddress;
}
+
+ public void setDeviceState(String deviceState) {
+ this.deviceState = deviceState;
+ }
+
+ public void setvCenterIpAddress(String ipaddress) {
+ this.vcenteripaddress = ipaddress;
+ }
+
+ public void setvCenterDcName(String dcName) {
+ this.vcenterdcname = dcName;
+ }
+
+ public void setVSMMgmtVlanId(String vlanId) {
+ this.vsmmgmtvlanid = vlanId;
+ }
+
+ public void setVSMCtrlVlanId(int vlanId) {
+ this.vsmctrlvlanid = vlanId;
+ }
+
+ public void setVSMPktVlanId(int vlanId) {
+ this.vsmpktvlanid = vlanId;
+ }
+
+ public void setVSMStorageVlanId(int vlanId) {
+ this.vsmstoragevlanid = vlanId;
+ }
+
+ public void setVSMDomainId(String domId) {
+ this.vsmdomainid = domId;
+ }
+
+ public void setVSMConfigMode(String configMode) {
+ this.vsmconfigmode = configMode;
+ }
+
+ public void setVSMConfigState(String configState) {
+ this.vsmconfigstate = configState;
+ }
+
+ public void setVSMDeviceState(String devState) {
+ this.vsmdevicestate = devState;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c08716db/client/tomcatconf/cisconexusvsm_commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/cisconexusvsm_commands.properties.in b/client/tomcatconf/cisconexusvsm_commands.properties.in
index 258f358..aba8e00 100644
--- a/client/tomcatconf/cisconexusvsm_commands.properties.in
+++ b/client/tomcatconf/cisconexusvsm_commands.properties.in
@@ -1,9 +1,10 @@
### bitmap of permissions at the end of each classname, 1 = ADMIN, 2 = RESOURCE_DOMAIN_ADMIN, 4 = DOMAIN_ADMIN, 8 = USER
### Please standardize naming conventions to camel-case (even for acronyms).
-#### Cisco Nexus 1000v Virtual Supervisor Module (VSM) commands
-addCiscoNexusVSM = com.cloud.api.commands.AddCiscoNexusVSMCmd;7
-deleteCiscoNexusVSM = com.cloud.api.commands.DeleteCiscoNexusVSMCmd;7
-enableCiscoNexusVSM = com.cloud.api.commands.EnableCiscoNexusVSMCmd;7
-disableCiscoNexusVSM = com.cloud.api.commands.DisableCiscoNexusVSMCmd;7
-getCiscoVSMByClusterId = com.cloud.api.commands.GetCiscoVSMByClusterIdCmd;7
\ No newline at end of file
+#### Cisco Nexus 1000v Virtual Supervisor Module (VSM) commands
+addCiscoNexusVSM = com.cloud.api.commands.AddCiscoNexusVSMCmd;1
+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
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c08716db/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
new file mode 100755
index 0000000..d36b9ff
--- /dev/null
+++ b/server/src/com/cloud/api/commands/GetCiscoVSMDetailsCmd.java
@@ -0,0 +1,96 @@
+/**
+ * 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.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(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/c08716db/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 ff8da40..e09eee6 100644
--- a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
@@ -304,6 +304,11 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
}
@DB
+ public CiscoNexusVSMDeviceVO getCiscoVSMbyVSMId(long vsmId) {
+ return _ciscoNexusVSMDeviceDao.findById(vsmId);
+ }
+
+ @DB
public CiscoNexusVSMDeviceVO getCiscoVSMbyClusId(long clusterId) {
ClusterVSMMapVO mapVO = _clusterVSMDao.findByClusterId(clusterId);
if (mapVO == null) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c08716db/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 675636b..f0fc362 100644
--- a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
+++ b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java
@@ -26,6 +26,7 @@ import com.cloud.api.commands.ListCiscoNexusVSMCmd;
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.response.CiscoNexusVSMResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao;
@@ -216,6 +217,15 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
}
@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) {
CiscoNexusVSMDeviceVO result = getCiscoVSMbyClusId(cmd.getClusterId());
if (result == null) {
@@ -237,6 +247,27 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
response.setMgmtIpAddress(vsmDeviceVO.getipaddr());
return response;
}
+
+ public CiscoNexusVSMResponse createCiscoNexusVSMDetailedResponse(CiscoNexusVSMDeviceVO vsmDeviceVO) {
+ CiscoNexusVSMResponse response = new CiscoNexusVSMResponse();
+ response.setId(vsmDeviceVO.getId());
+ response.setDeviceName(vsmDeviceVO.getvsmName());
+ response.setDeviceState(vsmDeviceVO.getvsmDeviceState().toString());
+ response.setMgmtIpAddress(vsmDeviceVO.getipaddr());
+ response.setvCenterDcName(vsmDeviceVO.getvCenterDCName());
+ response.setvCenterIpAddress(vsmDeviceVO.getvCenterIPAddr());
+ // The following values can be null, so check for that.
+ if(vsmDeviceVO.getvsmConfigMode() != null)
+ response.setVSMConfigMode(vsmDeviceVO.getvsmConfigMode().toString());
+ if(vsmDeviceVO.getvsmConfigState() != null)
+ response.setVSMConfigState(vsmDeviceVO.getvsmConfigState().toString());
+ if(vsmDeviceVO.getvsmDeviceState() != null)
+ response.setVSMDeviceState(vsmDeviceVO.getvsmDeviceState().toString());
+ response.setVSMCtrlVlanId(vsmDeviceVO.getManagementVlan());
+ response.setVSMPktVlanId(vsmDeviceVO.getPacketVlan());
+ response.setVSMStorageVlanId(vsmDeviceVO.getStorageVlan());
+ return response;
+ }
@Override
public String getPropertiesFile() {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c08716db/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 a0bf1dd..c1c5a07 100644
--- a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
+++ b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
@@ -24,6 +24,7 @@ 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.ListCiscoNexusVSMCmd;
import com.cloud.api.response.CiscoNexusVSMResponse;
import com.cloud.network.CiscoNexusVSMDeviceVO;
@@ -65,10 +66,17 @@ public interface CiscoNexusVSMElementService extends PluggableService {
/**
* Returns a VSM associated with a cluster.
- * @param cmd
- * @return
+ * @param GetCiscoVSMByClusterIdCmd
+ * @return CiscoNexusVSMDeviceVO
*/
- public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(GetCiscoVSMByClusterIdCmd cmd);
+ public CiscoNexusVSMDeviceVO getCiscoNexusVSMByClusId(GetCiscoVSMByClusterIdCmd cmd);
+
+ /**
+ *
+ * @param GetCiscoVSMDetailsCmd
+ * @return CiscoNexusVSMDeviceVO
+ */
+ public CiscoNexusVSMDeviceVO getCiscoNexusVSMDetails(GetCiscoVSMDetailsCmd cmd);
/**
* creates API response object for Cisco Nexus VSMs
@@ -77,4 +85,11 @@ public interface CiscoNexusVSMElementService extends PluggableService {
*/
public CiscoNexusVSMResponse createCiscoNexusVSMResponse(CiscoNexusVSMDeviceVO vsmDeviceVO);
+
+ /**
+ * Creates a detailed API response object for Cisco Nexus VSMs
+ * @param CiscoNexusVSMDeviceVO
+ * @return CiscoNexusVSMResponse
+ */
+ public CiscoNexusVSMResponse createCiscoNexusVSMDetailedResponse(CiscoNexusVSMDeviceVO vsmDeviceVO);
}