Skip to content

Commit 205f4a2

Browse files
Sateesh ChodapuneediVijayendra Bhamidipati
authored andcommitted
CS-9919 - Support for Nexus Swiches (Cisco Vswitches)
Description: Code changes to manage Cisco Nexus 1000v in CloudStack. VmwareResource has been modified to leverage Nexus vSwitch. Providing following global configuration parameters, vmware.use.nexus.vswitch - This would decide whether Nexus vSwitch in the VMware cluster environment would be used/managed by CloudStack for it's network infrastructure needs. vmware.guest.network.vswitch.type - This setting would enable CloudStack to use Nexus vSwitch in the VMware cluster environment for guest traffic. vmware.private.network.vswitch.type - This setting would enable CloudStack to use Nexus vSwitch in the VMware cluster environment for private traffic. vmware.public.network.vswitch.type - This setting would enable CloudStack to use Nexus vSwitch in the VMware cluster environment for private traffic. Functional Specification - http://wiki.cloudstack.org/display/RelOps/Cisco+Nexus+1000v+Support+in+CloudStack+-+Functional+Specification Documentation / README for usage instructions - http://wiki.cloudstack.org/display/RelOps/Configuration+instructions+for+CloudStack+Deployment+with+Nexus+vSwitch Conflicts: core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
1 parent 0e293b7 commit 205f4a2

9 files changed

Lines changed: 848 additions & 384 deletions

File tree

core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, l
6060

6161
boolean beginExclusiveOperation(int timeOutSeconds);
6262
void endExclusiveOperation();
63+
64+
Map<String, String> getNexusVSMCredentials(String hostGuid);
6365
}

core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 141 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
import com.cloud.hypervisor.vmware.mo.NetworkDetails;
162162
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
163163
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
164+
import com.cloud.hypervisor.vmware.mo.VirtualSwitchType;
164165
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
165166
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
166167
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostResourceSummary;
@@ -258,14 +259,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
258259
protected String _privateNetworkVSwitchName;
259260
protected String _publicNetworkVSwitchName;
260261
protected String _guestNetworkVSwitchName;
261-
262+
protected VirtualSwitchType _privateNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
263+
protected VirtualSwitchType _publicNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
264+
protected VirtualSwitchType _guestNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
265+
protected boolean _nexusVSwitch = false;
266+
262267
protected float _cpuOverprovisioningFactor = 1;
263268
protected boolean _reserveCpu = false;
264269

265270
protected float _memOverprovisioningFactor = 1;
266271
protected boolean _reserveMem = false;
267272
protected boolean _recycleHungWorker = false;
268-
protected DiskControllerType _rootDiskController = DiskControllerType.ide;
273+
protected DiskControllerType _rootDiskController = DiskControllerType.ide;
269274

270275
protected ManagedObjectReference _morHyperHost;
271276
protected VmwareContext _serviceContext;
@@ -787,27 +792,35 @@ protected void assignPublicIpAddress(VirtualMachineMO vmMo, final String vmName,
787792
int nicMasks = Integer.parseInt(nicMasksStr);
788793
nicMasks &= ~(1 << publicNicInfo.first().intValue());
789794
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMasks));
790-
791-
HostMO hostMo = vmMo.getRunningHost();
792-
List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
793-
for (NetworkDetails netDetails : networks) {
794-
if (netDetails.getGCTag() != null && netDetails.getGCTag().equalsIgnoreCase("true")) {
795-
if (netDetails.getVMMorsOnNetwork() == null || netDetails.getVMMorsOnNetwork().length == 1) {
796-
cleanupNetwork(hostMo, netDetails);
797-
}
798-
}
799-
}
800-
}
801-
802-
if (s_logger.isInfoEnabled()) {
803-
s_logger.info("ipassoc command on domain router " + privateIpAddress + " completed");
804-
}
805-
}
806795

807-
private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final String vifMacAddress) throws Exception {
796+
HostMO hostMo = vmMo.getRunningHost();
797+
List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
798+
for (NetworkDetails netDetails : networks) {
799+
if (netDetails.getGCTag() != null && netDetails.getGCTag().equalsIgnoreCase("true")) {
800+
if (netDetails.getVMMorsOnNetwork() == null || netDetails.getVMMorsOnNetwork().length == 1) {
801+
cleanupNetwork(hostMo, netDetails);
802+
}
803+
}
804+
}
805+
}
806+
807+
if (s_logger.isInfoEnabled()) {
808+
s_logger.info("ipassoc command on domain router " + privateIpAddress + " completed");
809+
}
810+
}
811+
812+
private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final String vifMacAddress) throws Exception {
808813
// TODO : probably need to set traffic shaping
809-
Pair<ManagedObjectReference, String> networkInfo = HypervisorHostHelper.prepareNetwork(this._publicNetworkVSwitchName, "cloud.public",
810-
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true);
814+
Pair<ManagedObjectReference, String> networkInfo = null;
815+
816+
if(!_nexusVSwitch) {
817+
networkInfo = HypervisorHostHelper.prepareNetwork(this._publicNetworkVSwitchName, "cloud.public",
818+
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true);
819+
}
820+
else {
821+
networkInfo = HypervisorHostHelper.prepareNetwork(this._publicNetworkVSwitchName, "cloud.public",
822+
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout);
823+
}
811824

812825
int nicIndex = allocPublicNicIndex(vmMo);
813826

@@ -1674,11 +1687,21 @@ private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO ho
16741687

16751688
Pair<String, String> switchName = getTargetSwitch(nicTo);
16761689
String namePrefix = getNetworkNamePrefix(nicTo);
1690+
Pair<ManagedObjectReference, String> networkInfo = null;
1691+
1692+
s_logger.info("Prepare network on vSwitch: " + switchName + " with name prefix: " + namePrefix);
16771693

1678-
s_logger.info("Prepare network on vSwitch: " + switchName.first() + " with name prefix: " + namePrefix);
1679-
return HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
1680-
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
1681-
!namePrefix.startsWith("cloud.private"));
1694+
if(!_nexusVSwitch) {
1695+
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
1696+
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
1697+
!namePrefix.startsWith("cloud.private"));
1698+
}
1699+
else {
1700+
networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
1701+
nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
1702+
}
1703+
1704+
return networkInfo;
16821705
}
16831706

16841707
// return Pair<switch name, vlan tagging>
@@ -4009,7 +4032,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
40094032
_privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name");
40104033
_publicNetworkVSwitchName = (String) params.get("public.network.vswitch.name");
40114034
_guestNetworkVSwitchName = (String) params.get("guest.network.vswitch.name");
4012-
4035+
40134036
String value = (String) params.get("cpu.overprovisioning.factor");
40144037
if(value != null)
40154038
_cpuOverprovisioningFactor = Float.parseFloat(value);
@@ -4036,42 +4059,70 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
40364059
else
40374060
_rootDiskController = DiskControllerType.ide;
40384061

4039-
s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: "
4040-
+ _guestNetworkVSwitchName);
4041-
4042-
return true;
4043-
}
4044-
4045-
@Override
4046-
public String getName() {
4047-
return _name;
4048-
}
4049-
4050-
@Override
4051-
public boolean start() {
4052-
return true;
4053-
}
4054-
4055-
@Override
4056-
public boolean stop() {
4057-
return true;
4058-
}
4059-
4060-
private VmwareContext getServiceContext() {
4061-
return getServiceContext(null);
4062-
}
4063-
4064-
private void invalidateServiceContext() {
4065-
invalidateServiceContext(null);
4066-
}
4067-
4068-
private VmwareHypervisorHost getHyperHost(VmwareContext context) {
4069-
return getHyperHost(context, null);
4070-
}
4071-
4072-
@Override
4073-
public synchronized VmwareContext getServiceContext(Command cmd) {
4074-
if (_serviceContext == null) {
4062+
value = params.get("vmware.use.nexus.vswitch").toString();
4063+
if(value != null && value.equalsIgnoreCase("true"))
4064+
_nexusVSwitch = true;
4065+
4066+
value = (String)params.get("private.network.vswitch.type");
4067+
if(value != null && value.equalsIgnoreCase("standard"))
4068+
_privateNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
4069+
else if(value != null && value.equalsIgnoreCase("nexus"))
4070+
_privateNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch;
4071+
else
4072+
_privateNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch;
4073+
4074+
value = (String)params.get("public.network.vswitch.type");
4075+
if(value != null && value.equalsIgnoreCase("standard"))
4076+
_publicNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
4077+
else if(value != null && value.equalsIgnoreCase("nexus"))
4078+
_publicNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch;
4079+
else
4080+
_publicNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch;
4081+
4082+
value = (String)params.get("guest.network.vswitch.type");
4083+
if(value != null && value.equalsIgnoreCase("standard"))
4084+
_guestNetworkVSwitchType = VirtualSwitchType.StandardVirtualSwitch;
4085+
else if(value != null && value.equalsIgnoreCase("nexus"))
4086+
_guestNetworkVSwitchType = VirtualSwitchType.NexusDistributedVirtualSwitch;
4087+
else
4088+
_guestNetworkVSwitchType = VirtualSwitchType.VMwareDistributedVirtualSwitch;
4089+
4090+
s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: "
4091+
+ _guestNetworkVSwitchName);
4092+
4093+
return true;
4094+
}
4095+
4096+
@Override
4097+
public String getName() {
4098+
return _name;
4099+
}
4100+
4101+
@Override
4102+
public boolean start() {
4103+
return true;
4104+
}
4105+
4106+
@Override
4107+
public boolean stop() {
4108+
return true;
4109+
}
4110+
4111+
private VmwareContext getServiceContext() {
4112+
return getServiceContext(null);
4113+
}
4114+
4115+
private void invalidateServiceContext() {
4116+
invalidateServiceContext(null);
4117+
}
4118+
4119+
private VmwareHypervisorHost getHyperHost(VmwareContext context) {
4120+
return getHyperHost(context, null);
4121+
}
4122+
4123+
@Override
4124+
public synchronized VmwareContext getServiceContext(Command cmd) {
4125+
if (_serviceContext == null) {
40754126
try {
40764127
_serviceContext = VmwareContextFactory.create(_vCenterAddress, _username, _password);
40774128
VmwareHypervisorHost hyperHost = getHyperHost(_serviceContext, cmd);
@@ -4096,24 +4147,35 @@ public synchronized VmwareContext getServiceContext(Command cmd) {
40964147
if(bRefresh)
40974148
firewallMo.refreshFirewall();
40984149
}
4099-
} catch (Exception e) {
4100-
s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
4101-
throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
4150+
} catch (Exception e) {
4151+
s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
4152+
throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
41024153
}
4103-
}
4104-
4105-
return _serviceContext;
4106-
}
4107-
4108-
@Override
4109-
public synchronized void invalidateServiceContext(VmwareContext context) {
4110-
if (_serviceContext == null) {
4111-
_serviceContext.close();
4112-
}
4113-
_serviceContext = null;
4114-
}
4115-
4116-
@Override
4154+
if(_nexusVSwitch)
4155+
{
4156+
VmwareManager mgr = _serviceContext.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
4157+
Map<String, String> nexusVSwitchCredentials = mgr.getNexusVSMCredentials(_guid);
4158+
if(nexusVSwitchCredentials != null)
4159+
{
4160+
_serviceContext.registerStockObject("vsmcredentials", nexusVSwitchCredentials);
4161+
//_serviceContext.registerStockObject("vsmip", nexusVSwitchCredentials.get("vsmip"));
4162+
//_serviceContext.registerStockObject("vsmusername", nexusVSwitchCredentials.get("vsmusername"));
4163+
//_serviceContext.registerStockObject("vsmpassword", nexusVSwitchCredentials.get("vsmpassword"));
4164+
}
4165+
}
4166+
}
4167+
return _serviceContext;
4168+
}
4169+
4170+
@Override
4171+
public synchronized void invalidateServiceContext(VmwareContext context) {
4172+
if (_serviceContext == null) {
4173+
_serviceContext.close();
4174+
}
4175+
_serviceContext = null;
4176+
}
4177+
4178+
@Override
41174179
public VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd) {
41184180
if (_morHyperHost.getType().equalsIgnoreCase("HostSystem")) {
41194181
return new HostMO(context, _morHyperHost);

server/src/com/cloud/configuration/Config.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ public enum Config {
242242
VmwarePrivateNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.private.vswitch", null, "Specify the vSwitch on host for private network", null),
243243
VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null),
244244
VmwareGuestNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.guest.vswitch", null, "Specify the vSwitch on host for guest network", null),
245+
VmwareUseNexusVSwitch("Network", ManagementServer.class, Boolean.class, "vmware.use.nexus.vswitch", "false", "Enable/Disable Cisco Nexus 1000v vSwitch in VMware environment", null),
246+
VmwarePrivateNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.private.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for private traffic", null),
247+
VmwarePublicNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.public.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for public traffic", null),
248+
VmwareGuestNetworkVSwitchType("Advanced", ManagementServer.class, String.class, "vmware.guest.network.vswitch.type", null, "Specify type of (standard/nexus) virtual switch designated for guest traffic", null),
245249
VmwareServiceConsole("Advanced", ManagementServer.class, String.class, "vmware.service.console", "Service Console", "Specify the service console network name(for ESX hosts)", null),
246250
VmwareManagementPortGroup("Advanced", ManagementServer.class, String.class, "vmware.management.portgroup", "Management Network", "Specify the management network name(for ESXi hosts)", null),
247251
VmwareAdditionalVncPortRangeStart("Advanced", ManagementServer.class, Integer.class, "vmware.additional.vnc.portrange.start", "50000", "Start port number of additional VNC port range", null),

0 commit comments

Comments
 (0)