mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description: Instance configuration to join distributed vNetwork. Conflicts: core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
This commit is contained in:
parent
7838b3fed6
commit
9709774b4b
@ -16,6 +16,7 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
@ -71,4 +72,10 @@ public interface VmwareManager {
|
|||||||
String getPublicVSwitchTypeGlobalParameter();
|
String getPublicVSwitchTypeGlobalParameter();
|
||||||
|
|
||||||
String getGuestVSwitchTypeGlobalParameter();
|
String getGuestVSwitchTypeGlobalParameter();
|
||||||
|
|
||||||
|
String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType);
|
||||||
|
|
||||||
|
String getPublicVSwitchName(long dcId, HypervisorType hypervisorType);
|
||||||
|
|
||||||
|
String getGuestVSwitchName(long dcId, HypervisorType hypervisorType);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,7 +156,6 @@ import com.cloud.hypervisor.vmware.mo.DatastoreMO;
|
|||||||
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
|
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
|
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostVirtualNicType;
|
|
||||||
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
||||||
import com.cloud.hypervisor.vmware.mo.NetworkDetails;
|
import com.cloud.hypervisor.vmware.mo.NetworkDetails;
|
||||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||||
@ -1475,6 +1474,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String switchUuid;
|
||||||
|
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
|
||||||
|
DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
|
||||||
|
|
||||||
VirtualDevice nic;
|
VirtualDevice nic;
|
||||||
int nicMask = 0;
|
int nicMask = 0;
|
||||||
int nicCount = 0;
|
int nicCount = 0;
|
||||||
@ -1483,6 +1486,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
||||||
|
|
||||||
|
ManagedObjectReference dvsMor = dataCenterMo.getDvSwitchMor(networkInfo.first());
|
||||||
|
switchUuid = dataCenterMo.getDvSwitchUuid(dvsMor);
|
||||||
|
s_logger.info("Preparing NIC device on dvSwitch : " + switchUuid);
|
||||||
|
|
||||||
nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), nicTo.getMac(), i, i + 1, true, true);
|
nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), nicTo.getMac(), i, i + 1, true, true);
|
||||||
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
|
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
|
||||||
deviceConfigSpecArray[i].setDevice(nic);
|
deviceConfigSpecArray[i].setDevice(nic);
|
||||||
@ -4025,13 +4032,22 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
VmwareHypervisorHost hostMo = this.getHyperHost(context);
|
VmwareHypervisorHost hostMo = this.getHyperHost(context);
|
||||||
_hostName = hostMo.getHyperHostName();
|
_hostName = hostMo.getHyperHostName();
|
||||||
|
_privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
||||||
|
_publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
||||||
|
_guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.error("Unexpected Exception ", e);
|
s_logger.error("Unexpected Exception ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
_privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name");
|
if(_privateNetworkVSwitchName == null) {
|
||||||
_publicNetworkVSwitchName = (String) params.get("public.network.vswitch.name");
|
_privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name");
|
||||||
_guestNetworkVSwitchName = (String) params.get("guest.network.vswitch.name");
|
}
|
||||||
|
if(_publicNetworkVSwitchName == null) {
|
||||||
|
_publicNetworkVSwitchName = (String) params.get("public.network.vswitch.name");
|
||||||
|
}
|
||||||
|
if(_guestNetworkVSwitchName == null) {
|
||||||
|
_guestNetworkVSwitchName = (String) params.get("guest.network.vswitch.name");
|
||||||
|
}
|
||||||
|
|
||||||
String value = (String) params.get("cpu.overprovisioning.factor");
|
String value = (String) params.get("cpu.overprovisioning.factor");
|
||||||
if(value != null)
|
if(value != null)
|
||||||
|
|||||||
@ -380,6 +380,21 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
return UUID.randomUUID().toString().replace("-", "");
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType) {
|
||||||
|
return _netMgr.getDefaultManagementTrafficLabel(dcId, hypervisorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPublicVSwitchName(long dcId, HypervisorType hypervisorType) {
|
||||||
|
return _netMgr.getDefaultPublicTrafficLabel(dcId, hypervisorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGuestVSwitchName(long dcId, HypervisorType hypervisorType) {
|
||||||
|
return _netMgr.getDefaultGuestTrafficLabel(dcId, hypervisorType);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
|
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
|
||||||
String hostInventoryPath) throws Exception {
|
String hostInventoryPath) throws Exception {
|
||||||
|
|||||||
@ -395,7 +395,7 @@ public class DatacenterMO extends BaseMO {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManagedObjectReference getDvSwitchMor(ManagedObjectReference morDatacenter, ManagedObjectReference dvPortGroupMor) throws Exception {
|
public ManagedObjectReference getDvSwitchMor(ManagedObjectReference dvPortGroupMor) throws Exception {
|
||||||
String dvPortGroupKey = null;
|
String dvPortGroupKey = null;
|
||||||
ManagedObjectReference dvSwitchMor = null;
|
ManagedObjectReference dvSwitchMor = null;
|
||||||
PropertySpec pSpec = new PropertySpec();
|
PropertySpec pSpec = new PropertySpec();
|
||||||
@ -408,7 +408,7 @@ public class DatacenterMO extends BaseMO {
|
|||||||
datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
|
datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
|
||||||
|
|
||||||
ObjectSpec oSpec = new ObjectSpec();
|
ObjectSpec oSpec = new ObjectSpec();
|
||||||
oSpec.setObj(morDatacenter);
|
oSpec.setObj(_mor);
|
||||||
oSpec.setSkip(Boolean.TRUE);
|
oSpec.setSkip(Boolean.TRUE);
|
||||||
oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
|
oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// Automatically generated by addcopyright.py at 04/03/2012
|
// Automatically generated by addcopyright.py at 04/03/2012
|
||||||
|
|
||||||
package com.cloud.hypervisor.vmware.util;
|
package com.cloud.hypervisor.vmware.util;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -32,6 +33,7 @@ import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
|
|||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.Ternary;
|
import com.cloud.utils.Ternary;
|
||||||
import com.cloud.utils.exception.ExceptionUtil;
|
import com.cloud.utils.exception.ExceptionUtil;
|
||||||
|
import com.vmware.vim25.DistributedVirtualSwitchPortConnection;
|
||||||
import com.vmware.vim25.DynamicProperty;
|
import com.vmware.vim25.DynamicProperty;
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
import com.vmware.vim25.MethodFault;
|
import com.vmware.vim25.MethodFault;
|
||||||
@ -53,6 +55,7 @@ import com.vmware.vim25.VirtualDiskSparseVer1BackingInfo;
|
|||||||
import com.vmware.vim25.VirtualDiskSparseVer2BackingInfo;
|
import com.vmware.vim25.VirtualDiskSparseVer2BackingInfo;
|
||||||
import com.vmware.vim25.VirtualE1000;
|
import com.vmware.vim25.VirtualE1000;
|
||||||
import com.vmware.vim25.VirtualEthernetCard;
|
import com.vmware.vim25.VirtualEthernetCard;
|
||||||
|
import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
|
||||||
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
|
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
|
||||||
import com.vmware.vim25.VirtualMachineConfigSpec;
|
import com.vmware.vim25.VirtualMachineConfigSpec;
|
||||||
import com.vmware.vim25.VirtualMachineSnapshotTree;
|
import com.vmware.vim25.VirtualMachineSnapshotTree;
|
||||||
@ -101,12 +104,59 @@ public class VmwareHelper {
|
|||||||
nic.setAddressType("Manual");
|
nic.setAddressType("Manual");
|
||||||
nic.setConnectable(connectInfo);
|
nic.setConnectable(connectInfo);
|
||||||
nic.setMacAddress(macAddress);
|
nic.setMacAddress(macAddress);
|
||||||
|
|
||||||
nic.setUnitNumber(deviceNumber);
|
nic.setUnitNumber(deviceNumber);
|
||||||
nic.setKey(-contextNumber);
|
nic.setKey(-contextNumber);
|
||||||
return nic;
|
return nic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VirtualDevice prepareDvNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType,
|
||||||
|
String dvPortGroupName, String dvSwitchUuid, String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
|
||||||
|
|
||||||
|
VirtualEthernetCard nic;
|
||||||
|
switch (deviceType) {
|
||||||
|
case E1000:
|
||||||
|
nic = new VirtualE1000();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCNet32:
|
||||||
|
nic = new VirtualPCNet32();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Vmxnet2:
|
||||||
|
nic = new VirtualVmxnet2();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Vmxnet3:
|
||||||
|
nic = new VirtualVmxnet3();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert (false);
|
||||||
|
nic = new VirtualE1000();
|
||||||
|
}
|
||||||
|
|
||||||
|
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
|
||||||
|
final DistributedVirtualSwitchPortConnection dvPortConnection = new DistributedVirtualSwitchPortConnection();
|
||||||
|
final VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo();
|
||||||
|
|
||||||
|
dvPortConnection.setSwitchUuid(dvSwitchUuid);
|
||||||
|
dvPortConnection.setPortgroupKey(morNetwork.get_value());
|
||||||
|
dvPortBacking.setPort(dvPortConnection);
|
||||||
|
nic.setBacking(dvPortBacking);
|
||||||
|
nic.setKey(30);
|
||||||
|
|
||||||
|
connectInfo.setAllowGuestControl(true);
|
||||||
|
connectInfo.setConnected(conntected);
|
||||||
|
connectInfo.setStartConnected(connectOnStart);
|
||||||
|
nic.setAddressType("Manual");
|
||||||
|
nic.setConnectable(connectInfo);
|
||||||
|
nic.setMacAddress(macAddress);
|
||||||
|
|
||||||
|
nic.setUnitNumber(deviceNumber);
|
||||||
|
nic.setKey(-contextNumber);
|
||||||
|
return nic;
|
||||||
|
}
|
||||||
|
|
||||||
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
||||||
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath,
|
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath,
|
||||||
int sizeInMb, ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception {
|
int sizeInMb, ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user