From 74b105b9d216fdd858cfec0dda6e07affb929de9 Mon Sep 17 00:00:00 2001 From: Vijayendra Bhamidipati Date: Wed, 16 May 2012 19:46:10 -0700 Subject: [PATCH] CS-9919 Support for Nexus Swiches (Cisco Vswitches) Description: Didn't stage all modified files in previous commit by mistake. Checking in the rest of the changes in this commit. Please refer to immediate previous commit for CS-9919 for details on what changes went in with this commit. --- .../com/cloud/api/commands/AddClusterCmd.java | 14 ++++++++++ .../cisconexusvsm_commands.properties.in | 1 - .../CiscoNexusVSMDeviceManagerImpl.java | 1 + .../network/element/CiscoNexusVSMElement.java | 28 ------------------- .../element/CiscoNexusVSMElementService.java | 9 ------ .../cloud/resource/ResourceManagerImpl.java | 4 ++- 6 files changed, 18 insertions(+), 39 deletions(-) diff --git a/api/src/com/cloud/api/commands/AddClusterCmd.java b/api/src/com/cloud/api/commands/AddClusterCmd.java index 0535989cf37..17d1b32910c 100755 --- a/api/src/com/cloud/api/commands/AddClusterCmd.java +++ b/api/src/com/cloud/api/commands/AddClusterCmd.java @@ -72,7 +72,21 @@ public class AddClusterCmd extends BaseCmd { @Parameter(name = ApiConstants.VSM_IPADDRESS, type = CommandType.STRING, required = false, description = "the ipaddress of the VSM associated with this cluster") private String vsmipaddress; + + @Parameter(name = ApiConstants.VCENTER_IP_ADDRESS, type = CommandType.STRING, required = false, description = "the ipaddress of the vCenter the VSM associated with this cluster will connect to") + private String vcenteripaddr; + + @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; + + public String getvCenterDCName() { + return vcenterdcname; + } + public String getvCenterIPAddr() { + return vcenteripaddr; + } + public String getVSMIpaddress() { return vsmipaddress; } diff --git a/client/tomcatconf/cisconexusvsm_commands.properties.in b/client/tomcatconf/cisconexusvsm_commands.properties.in index 9f35bf6940b..25f957f391e 100644 --- a/client/tomcatconf/cisconexusvsm_commands.properties.in +++ b/client/tomcatconf/cisconexusvsm_commands.properties.in @@ -2,7 +2,6 @@ ### Please standardize naming conventions to camel-case (even for acronyms). #### 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 diff --git a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java index e09eee68e9d..64d8dc32f84 100644 --- a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java +++ b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java @@ -215,6 +215,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase { if (hosts != null && hosts.size() > 0) { for (Host host: hosts) { if (host.getType() == Host.Type.Routing) { + s_logger.info("Non-empty cluster with id" + clusterId + "still has a host that uses this VSM. Please empty the cluster first"); throw new ResourceInUseException("Non-empty cluster with id" + clusterId + "still has a host that uses this VSM. Please empty the cluster first"); } } diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java index f0fc3622c05..5bcbb7b5846 100644 --- a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java +++ b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java @@ -20,7 +20,6 @@ import javax.ejb.Local; import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; -import com.cloud.api.commands.AddCiscoNexusVSMCmd; import com.cloud.api.commands.DeleteCiscoNexusVSMCmd; import com.cloud.api.commands.ListCiscoNexusVSMCmd; import com.cloud.api.commands.EnableCiscoNexusVSMCmd; @@ -160,33 +159,6 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme public boolean verifyServicesCombination(List services) { return true; } - - @Override - public CiscoNexusVSMDeviceVO addCiscoNexusVSM(AddCiscoNexusVSMCmd cmd) { - - // This function essentially prepares all the parameters we need to send - // to the addCiscoNexusVSM() function defined in CiscoNexusVSMDeviceManagerImpl.java. - - // We have this separation of functionality between CiscoNexusVSMElement.java - // to address multiple versions of Cisco Nexus Switches in future. This is the - // function/layer that will parse multiple versions and accordingly prepare - // different parameters to pass to to the CiscoNexusVSMDeviceManagerImpl functions - // which will in turn talk to the right resource via the appropriate manager. - - String vsmipaddress = cmd.getIpAddr(); - String vsmusername = cmd.getUsername(); - String vsmpassword = cmd.getPassword(); - String vCenterIpaddr = cmd.getvCenterIpaddr(); - String vCenterDcName = cmd.getvCenterDcName(); - long clusterId = cmd.getClusterId(); - - // Invoke the addCiscoNexusVSM() function defined in the upper layer (DeviceMgrImpl). - // The upper layer function will create a resource of type "host" to represent this VSM. - // It will add this VSM to the db. - //CiscoNexusVSMDeviceVO vsmDeviceVO = addCiscoNexusVSM(clusterId, vsmipaddress, vsmusername, vsmpassword, (ServerResource) new CiscoNexusVSMResource(), vsmName); - CiscoNexusVSMDeviceVO vsmDeviceVO = addCiscoNexusVSM(clusterId, vsmipaddress, vsmusername, vsmpassword, vCenterIpaddr, vCenterDcName); - return vsmDeviceVO; - } @Override public boolean deleteCiscoNexusVSM(DeleteCiscoNexusVSMCmd cmd) { diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java index c1c5a07f950..1810c3e6ca6 100644 --- a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java +++ b/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java @@ -19,7 +19,6 @@ package com.cloud.network.element; import java.util.List; -import com.cloud.api.commands.AddCiscoNexusVSMCmd; import com.cloud.api.commands.DeleteCiscoNexusVSMCmd; import com.cloud.api.commands.EnableCiscoNexusVSMCmd; import com.cloud.api.commands.DisableCiscoNexusVSMCmd; @@ -31,14 +30,6 @@ import com.cloud.network.CiscoNexusVSMDeviceVO; import com.cloud.utils.component.PluggableService; public interface CiscoNexusVSMElementService extends PluggableService { - - /** - * adds a Cisco Nexus VSM - * @param AddCiscoNexusVSMCmd - * @return CiscoNexusVSMDeviceVO object for the device added - */ - public CiscoNexusVSMDeviceVO addCiscoNexusVSM(AddCiscoNexusVSMCmd cmd); - /** * removes a Cisco Nexus VSM * @param DeleteCiscoNexusVSMCmd diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 56298ddc0b5..b143931a4f1 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -418,6 +418,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma 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; @@ -430,7 +432,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma throw new CloudRuntimeException(msg); } // persist credentials in database - CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword, "", ""); + CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword, vCenterIpaddr, vCenterDcName); Transaction txn = Transaction.currentTxn(); try {