From a48a3bbfbde218d64238d5f6cf2aef6d45349d27 Mon Sep 17 00:00:00 2001 From: Vijayendra Bhamidipati Date: Wed, 23 May 2012 16:44:50 -0700 Subject: [PATCH] CS-9919: Support for Nexus Swiches (Cisco Vswitches) Description: Removed the vcenter_dc_name and vcenter_ipaddr fields from the virtual_supervisor_module table, the CiscoNexusVSMDeviceVO, addClusterCmd, and all other references to these two fields. Fixing null pointer exceptions when checking for nexus related global parameter values in addClusterCmd. --- api/src/com/cloud/api/ApiConstants.java | 2 - .../com/cloud/api/commands/AddClusterCmd.java | 14 ------- .../api/response/CiscoNexusVSMResponse.java | 14 ------- .../cloud/network/CiscoNexusVSMDevice.java | 4 -- .../vmware/VmwareServerDiscoverer.java | 6 +-- .../CiscoNexusVSMDeviceManagerImpl.java | 2 +- .../cloud/network/CiscoNexusVSMDeviceVO.java | 39 +------------------ .../network/element/CiscoNexusVSMElement.java | 2 - .../cloud/resource/ResourceManagerImpl.java | 4 +- setup/db/create-schema.sql | 2 - setup/db/db/schema-302to303.sql | 2 - 11 files changed, 7 insertions(+), 84 deletions(-) diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 4b2b2e5362f..d9d31cd1a5a 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -339,8 +339,6 @@ public class ApiConstants { public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate"; // Would we need to have a capacity field for Cisco N1KV VSM? Max hosts managed by it perhaps? May remove this later. public static final String EXTERNAL_SWITCH_MGMT_DEVICE_CAPACITY = "vsmdevicecapacity"; - public static final String VCENTER_IP_ADDRESS = "vcenteripaddr"; - public static final String VCENTER_DC_NAME = "vcenterdcname"; public static final String CISCO_NEXUS_VSM_NAME = "vsmname"; public static final String VSM_USERNAME = "vsmusername"; public static final String VSM_PASSWORD = "vsmpassword"; diff --git a/api/src/com/cloud/api/commands/AddClusterCmd.java b/api/src/com/cloud/api/commands/AddClusterCmd.java index 17d1b32910c..181da8661ce 100755 --- a/api/src/com/cloud/api/commands/AddClusterCmd.java +++ b/api/src/com/cloud/api/commands/AddClusterCmd.java @@ -73,20 +73,6 @@ 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/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java b/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java index 3bef2ed5817..1bc880e78d7 100644 --- a/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java +++ b/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java @@ -32,12 +32,6 @@ public class CiscoNexusVSMResponse extends BaseResponse { @SerializedName(ApiConstants.EXTERNAL_SWITCH_MGMT_DEVICE_STATE) @Param(description="device state") private String deviceState; - - @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.VSM_MGMT_VLAN_ID) @Param(description="management vlan id of the VSM") private String vsmmgmtvlanid; @@ -80,14 +74,6 @@ public class CiscoNexusVSMResponse extends BaseResponse { 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; } diff --git a/api/src/com/cloud/network/CiscoNexusVSMDevice.java b/api/src/com/cloud/network/CiscoNexusVSMDevice.java index 66315daeb10..7b9ba9f12b2 100644 --- a/api/src/com/cloud/network/CiscoNexusVSMDevice.java +++ b/api/src/com/cloud/network/CiscoNexusVSMDevice.java @@ -46,10 +46,6 @@ public interface CiscoNexusVSMDevice { public String getipaddr(); - public String getvCenterIPAddr(); - - public String getvCenterDCName(); - public int getManagementVlan(); public int getControlVlan(); diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index c0a6ca3900d..db8ad872260 100755 --- a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -114,7 +114,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer String guestTrafficLabel = null; Map vsmCredentials = null; if (_vmwareMgr.getNexusVSwitchGlobalParameter()) { - if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { + if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter() != null && _vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { // Get physical network label privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware); if (privateTrafficLabel != null) { @@ -125,7 +125,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer DataCenterVO zone = _dcDao.findById(dcId); NetworkType zoneType = zone.getNetworkType(); - if (zoneType != NetworkType.Basic && _vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { + if (zoneType != NetworkType.Basic && _vmwareMgr.getPublicVSwitchTypeGlobalParameter() != null && _vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { // Get physical network label publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware); if (publicTrafficLabel != null) { @@ -136,7 +136,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer s_logger.info("Skipping detection of public traffic label as zone type is Basic."); } - if (_vmwareMgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { + if (_vmwareMgr.getGuestVSwitchTypeGlobalParameter() != null && _vmwareMgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) { // Get physical network label guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware); if (guestTrafficLabel != null) { diff --git a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java index 2d7ef7663bf..fec8a4af916 100644 --- a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java +++ b/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java @@ -131,7 +131,7 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase { if (VSMObj == null) { // Create the VSM record. For now, we aren't using the vsmName field. - VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password, vCenterIpaddr, vCenterDcName); + VSMObj = new CiscoNexusVSMDeviceVO(ipaddress, username, password); Transaction txn = Transaction.currentTxn(); try { txn.start(); diff --git a/server/src/com/cloud/network/CiscoNexusVSMDeviceVO.java b/server/src/com/cloud/network/CiscoNexusVSMDeviceVO.java index b1f195480c3..6165ec17953 100644 --- a/server/src/com/cloud/network/CiscoNexusVSMDeviceVO.java +++ b/server/src/com/cloud/network/CiscoNexusVSMDeviceVO.java @@ -64,13 +64,6 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice, Identity{ @Column(name = "ipaddr") private String ipaddr; - @Column(name = "vcenter_ipaddr") - private String vCenterIPAddr; - - // Name of the DataCenter (as seen in vCenter) that this VSM manages. - @Column(name = "vcenter_dc_name") - private String vCenterDCName; - @Column(name = "management_vlan") private int managementVlan; @@ -120,14 +113,6 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice, Identity{ return ipaddr; } - public String getvCenterIPAddr() { - return vCenterIPAddr; - } - - public String getvCenterDCName() { - return vCenterDCName; - } - public int getManagementVlan() { return managementVlan; } @@ -186,14 +171,6 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice, Identity{ this.ipaddr = ipaddr; } - public void setvCenterIPAddr(String ipaddr) { - this.vCenterIPAddr = ipaddr; - } - - public void setvCenterDCName(String dcname) { - this.vCenterDCName = dcname; - } - public void setManagementVlan(int vlan) { this.managementVlan = vlan; } @@ -227,21 +204,9 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice, Identity{ } - // Constructor methods. + // Constructors. - public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password, String vCenterIpaddr, String vCenterDcName) { - // Set all the VSM's properties here. - this.uuid = UUID.randomUUID().toString(); - this.setMgmtIpAddr(vsmIpAddr); - this.setVsmUserName(username); - this.setVsmPassword(password); - this.setvCenterIPAddr(vCenterIpaddr); - this.setvCenterDCName(vCenterDcName); - // By default, enable a VSM. - this.setVsmDeviceState(VSMDeviceState.Enabled); - } - - public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password, long dummy) { + public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password) { // Set all the VSM's properties here. this.uuid = UUID.randomUUID().toString(); this.setMgmtIpAddr(vsmIpAddr); diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java index 844d125f5b4..1156a26e88c 100644 --- a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java +++ b/server/src/com/cloud/network/element/CiscoNexusVSMElement.java @@ -216,8 +216,6 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme 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()); diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 77ca50a9980..478ae6f2df3 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -420,8 +420,6 @@ 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; @@ -435,7 +433,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma throw new CloudRuntimeException(msg); } // persist credentials to database - CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword, vCenterIpaddr, vCenterDcName); + CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword); Transaction txn = Transaction.currentTxn(); try { diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 51e4bf503e6..d7cd2d64549 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -2097,8 +2097,6 @@ CREATE TABLE `cloud`.`virtual_supervisor_module` ( `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `ipaddr` varchar(80) NOT NULL, - `vcenter_ipaddr` varchar(80), - `vcenter_dc_name` varchar(255), `management_vlan` int(32), `control_vlan` int(32), `packet_vlan` int(32), diff --git a/setup/db/db/schema-302to303.sql b/setup/db/db/schema-302to303.sql index 998d1c909f0..7573b94ebfd 100755 --- a/setup/db/db/schema-302to303.sql +++ b/setup/db/db/schema-302to303.sql @@ -145,8 +145,6 @@ CREATE TABLE `cloud`.`virtual_supervisor_module` ( `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `ipaddr` varchar(80) NOT NULL, - `vcenter_ipaddr` varchar(80), - `vcenter_dc_name` varchar(255), `management_vlan` int(32), `control_vlan` int(32), `packet_vlan` int(32),