mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11162: merge fix from 2.2.10 premium
This commit is contained in:
parent
97a7dddf7d
commit
9ace681547
@ -181,7 +181,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
workerVMName = UUID.randomUUID().toString().replaceAll("-", "");
|
workerVMName = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
|
||||||
//attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
|
//attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
|
||||||
if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, VirtualMachineGuestOsIdentifier._otherGuest.toString(), morDs, false)) {
|
if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier._otherGuest.toString(), morDs, false)) {
|
||||||
String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
|
String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
|
|||||||
@ -238,9 +238,13 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
protected String _privateNetworkVSwitchName;
|
protected String _privateNetworkVSwitchName;
|
||||||
protected String _publicNetworkVSwitchName;
|
protected String _publicNetworkVSwitchName;
|
||||||
protected String _guestNetworkVSwitchName;
|
protected String _guestNetworkVSwitchName;
|
||||||
|
|
||||||
protected float _cpuOverprovisioningFactor = 1;
|
protected float _cpuOverprovisioningFactor = 1;
|
||||||
protected boolean _reserveCpu = false;
|
protected boolean _reserveCpu = false;
|
||||||
|
|
||||||
|
protected float _memOverprovisioningFactor = 1;
|
||||||
|
protected boolean _reserveMem = false;
|
||||||
|
|
||||||
protected ManagedObjectReference _morHyperHost;
|
protected ManagedObjectReference _morHyperHost;
|
||||||
protected VmwareContext _serviceContext;
|
protected VmwareContext _serviceContext;
|
||||||
protected String _hostName;
|
protected String _hostName;
|
||||||
@ -1099,7 +1103,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
assert (vmSpec.getSpeed() != null) && (rootDiskDataStoreDetails != null);
|
assert (vmSpec.getSpeed() != null) && (rootDiskDataStoreDetails != null);
|
||||||
if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
||||||
getReserveCpuMHz(vmSpec.getSpeed().intValue()), vmSpec.getLimitCpuUse(), ramMb,
|
getReserveCpuMHz(vmSpec.getSpeed().intValue()), vmSpec.getLimitCpuUse(), ramMb, getReserveMemMB(ramMb),
|
||||||
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), rootDiskDataStoreDetails.first(), false)) {
|
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), rootDiskDataStoreDetails.first(), false)) {
|
||||||
throw new Exception("Failed to create VM. vmName: " + vmName);
|
throw new Exception("Failed to create VM. vmName: " + vmName);
|
||||||
}
|
}
|
||||||
@ -1131,7 +1135,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
|
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
|
||||||
int ramMb = (int) (vmSpec.getMinRam() / (1024 * 1024));
|
int ramMb = (int) (vmSpec.getMinRam() / (1024 * 1024));
|
||||||
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
||||||
getReserveCpuMHz(vmSpec.getSpeed().intValue()), ramMb,
|
getReserveCpuMHz(vmSpec.getSpeed().intValue()), ramMb, getReserveMemMB(ramMb),
|
||||||
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), vmSpec.getLimitCpuUse());
|
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), vmSpec.getLimitCpuUse());
|
||||||
|
|
||||||
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
|
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
|
||||||
@ -1322,6 +1326,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getReserveMemMB(int memMB) {
|
||||||
|
if(this._reserveMem) {
|
||||||
|
return (int)(memMB / this._memOverprovisioningFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private NicTO[] sortNicsByDeviceId(NicTO[] nics) {
|
private NicTO[] sortNicsByDeviceId(NicTO[] nics) {
|
||||||
|
|
||||||
List<NicTO> listForSort = new ArrayList<NicTO>();
|
List<NicTO> listForSort = new ArrayList<NicTO>();
|
||||||
@ -3660,6 +3672,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
if(value != null && value.equalsIgnoreCase("true"))
|
if(value != null && value.equalsIgnoreCase("true"))
|
||||||
_reserveCpu = true;
|
_reserveCpu = true;
|
||||||
|
|
||||||
|
value = (String) params.get("mem.overprovisioning.factor");
|
||||||
|
if(value != null)
|
||||||
|
_memOverprovisioningFactor = Float.parseFloat(value);
|
||||||
|
|
||||||
|
value = (String) params.get("vmware.reserve.mem");
|
||||||
|
if(value != null && value.equalsIgnoreCase("true"))
|
||||||
|
_reserveMem = true;
|
||||||
|
|
||||||
String[] tokens = _guid.split("@");
|
String[] tokens = _guid.split("@");
|
||||||
_vCenterAddress = tokens[1];
|
_vCenterAddress = tokens[1];
|
||||||
_morHyperHost = new ManagedObjectReference();
|
_morHyperHost = new ManagedObjectReference();
|
||||||
|
|||||||
1
deps/.classpath
vendored
1
deps/.classpath
vendored
@ -51,7 +51,6 @@
|
|||||||
<classpathentry exported="true" kind="lib" path="vmware-lib-xml-apis.jar"/>
|
<classpathentry exported="true" kind="lib" path="vmware-lib-xml-apis.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="vmware-vim.jar"/>
|
<classpathentry exported="true" kind="lib" path="vmware-vim.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="vmware-vim25.jar"/>
|
<classpathentry exported="true" kind="lib" path="vmware-vim25.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="cloud-charva.jar"/>
|
|
||||||
<classpathentry exported="true" kind="lib" path="cloud-jnetpcap.jar"/>
|
<classpathentry exported="true" kind="lib" path="cloud-jnetpcap.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="cloud-junit.jar"/>
|
<classpathentry exported="true" kind="lib" path="cloud-junit.jar"/>
|
||||||
<classpathentry exported="true" kind="lib" path="cloud-selenium-java-client-driver.jar"/>
|
<classpathentry exported="true" kind="lib" path="cloud-selenium-java-client-driver.jar"/>
|
||||||
|
|||||||
@ -124,6 +124,9 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
String _cpuOverprovisioningFactor = "1";
|
String _cpuOverprovisioningFactor = "1";
|
||||||
String _reserveCpu = "false";
|
String _reserveCpu = "false";
|
||||||
|
|
||||||
|
String _memOverprovisioningFactor = "1";
|
||||||
|
String _reserveMem = "false";
|
||||||
|
|
||||||
Map<String, String> _storageMounts = new HashMap<String, String>();
|
Map<String, String> _storageMounts = new HashMap<String, String>();
|
||||||
|
|
||||||
Random _rand = new Random(System.currentTimeMillis());
|
Random _rand = new Random(System.currentTimeMillis());
|
||||||
@ -235,9 +238,16 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
|
if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
|
||||||
_cpuOverprovisioningFactor = "1";
|
_cpuOverprovisioningFactor = "1";
|
||||||
|
|
||||||
|
_memOverprovisioningFactor = configDao.getValue(Config.MemOverprovisioningFactor.key());
|
||||||
|
if(_memOverprovisioningFactor == null || _memOverprovisioningFactor.isEmpty())
|
||||||
|
_memOverprovisioningFactor = "1";
|
||||||
|
|
||||||
_reserveCpu = configDao.getValue(Config.VmwareReserveCpu.key());
|
_reserveCpu = configDao.getValue(Config.VmwareReserveCpu.key());
|
||||||
if(_reserveCpu == null || _reserveCpu.isEmpty())
|
if(_reserveCpu == null || _reserveCpu.isEmpty())
|
||||||
_reserveCpu = "false";
|
_reserveCpu = "false";
|
||||||
|
_reserveMem = configDao.getValue(Config.VmwareReserveMem.key());
|
||||||
|
if(_reserveMem == null || _reserveMem.isEmpty())
|
||||||
|
_reserveMem = "false";
|
||||||
|
|
||||||
s_logger.info("Additional VNC port allocation range is settled at " + _additionalPortRangeStart + " to " + (_additionalPortRangeStart + _additionalPortRangeSize));
|
s_logger.info("Additional VNC port allocation range is settled at " + _additionalPortRangeStart + " to " + (_additionalPortRangeStart + _additionalPortRangeSize));
|
||||||
|
|
||||||
@ -461,6 +471,8 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
params.put("management.portgroup.name", _managemetPortGroupName);
|
params.put("management.portgroup.name", _managemetPortGroupName);
|
||||||
params.put("cpu.overprovisioning.factor", _cpuOverprovisioningFactor);
|
params.put("cpu.overprovisioning.factor", _cpuOverprovisioningFactor);
|
||||||
params.put("vmware.reserve.cpu", _reserveCpu);
|
params.put("vmware.reserve.cpu", _reserveCpu);
|
||||||
|
params.put("mem.overprovisioning.factor", _memOverprovisioningFactor);
|
||||||
|
params.put("vmware.reserve.mem", _reserveMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -255,7 +255,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
public boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
|
||||||
String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
||||||
|
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
@ -264,7 +264,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.get_value() + ", snapshotDirToParent: " + snapshotDirToParent);
|
+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.get_value() + ", snapshotDirToParent: " + snapshotDirToParent);
|
||||||
|
|
||||||
boolean result = HypervisorHostHelper.createBlankVm(this, vmName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
|
boolean result = HypervisorHostHelper.createBlankVm(this, vmName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
|
||||||
memoryMB, guestOsIdentifier, morDs, snapshotDirToParent);
|
memoryMB, memoryReserveMB, guestOsIdentifier, morDs, snapshotDirToParent);
|
||||||
|
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createBlankVm() done");
|
s_logger.trace("vCenter API trace - createBlankVm() done");
|
||||||
|
|||||||
@ -664,7 +664,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
public boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
|
||||||
String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
||||||
|
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
@ -673,7 +673,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.get_value() + ", snapshotDirToParent: " + snapshotDirToParent);
|
+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.get_value() + ", snapshotDirToParent: " + snapshotDirToParent);
|
||||||
|
|
||||||
boolean result = HypervisorHostHelper.createBlankVm(this, vmName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
|
boolean result = HypervisorHostHelper.createBlankVm(this, vmName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
|
||||||
memoryMB, guestOsIdentifier, morDs, snapshotDirToParent);
|
memoryMB, memoryReserveMB, guestOsIdentifier, morDs, snapshotDirToParent);
|
||||||
|
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createBlankVm() done");
|
s_logger.trace("vCenter API trace - createBlankVm() done");
|
||||||
|
|||||||
@ -398,7 +398,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean createBlankVm(VmwareHypervisorHost host, String vmName,
|
public static boolean createBlankVm(VmwareHypervisorHost host, String vmName,
|
||||||
int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, String guestOsIdentifier,
|
int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier,
|
||||||
ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
||||||
|
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled())
|
||||||
@ -407,7 +407,7 @@ public class HypervisorHostHelper {
|
|||||||
// VM config basics
|
// VM config basics
|
||||||
VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
|
VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
|
||||||
vmConfig.setName(vmName);
|
vmConfig.setName(vmName);
|
||||||
VmwareHelper.setBasicVmConfig(vmConfig, cpuCount, cpuSpeedMHz, cpuReservedMHz, memoryMB, guestOsIdentifier, limitCpuUse);
|
VmwareHelper.setBasicVmConfig(vmConfig, cpuCount, cpuSpeedMHz, cpuReservedMHz, memoryMB, memoryReserveMB, guestOsIdentifier, limitCpuUse);
|
||||||
|
|
||||||
// Scsi controller
|
// Scsi controller
|
||||||
VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
|
VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
|
||||||
|
|||||||
@ -1377,7 +1377,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
HostMO hostMo = getRunningHost();
|
HostMO hostMo = getRunningHost();
|
||||||
VirtualMachineConfigInfo vmConfigInfo = getConfigInfo();
|
VirtualMachineConfigInfo vmConfigInfo = getConfigInfo();
|
||||||
|
|
||||||
hostMo.createBlankVm(clonedVmName, 1, cpuSpeedMHz, 0, false, memoryMb, vmConfigInfo.getGuestId(), morDs, false);
|
hostMo.createBlankVm(clonedVmName, 1, cpuSpeedMHz, 0, false, memoryMb, 0, vmConfigInfo.getGuestId(), morDs, false);
|
||||||
VirtualMachineMO clonedVmMo = hostMo.findVmOnHyperHost(clonedVmName);
|
VirtualMachineMO clonedVmMo = hostMo.findVmOnHyperHost(clonedVmName);
|
||||||
|
|
||||||
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
|
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public interface VmwareHypervisorHost {
|
|||||||
VirtualMachineMO findVmOnPeerHyperHost(String name) throws Exception;
|
VirtualMachineMO findVmOnPeerHyperHost(String name) throws Exception;
|
||||||
|
|
||||||
boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception;
|
boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception;
|
||||||
boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
boolean createBlankVm(String vmName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB, int memoryReserveMB,
|
||||||
String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception;
|
String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception;
|
||||||
void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception;
|
void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception;
|
||||||
|
|
||||||
|
|||||||
@ -407,7 +407,7 @@ public class VmwareHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz,
|
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz,
|
||||||
int memoryMB, String guestOsIdentifier, boolean limitCpuUse) {
|
int memoryMB, int memoryReserveMB, String guestOsIdentifier, boolean limitCpuUse) {
|
||||||
|
|
||||||
// VM config basics
|
// VM config basics
|
||||||
vmConfig.setMemoryMB((long)memoryMB);
|
vmConfig.setMemoryMB((long)memoryMB);
|
||||||
@ -425,7 +425,7 @@ public class VmwareHelper {
|
|||||||
|
|
||||||
ResourceAllocationInfo memInfo = new ResourceAllocationInfo();
|
ResourceAllocationInfo memInfo = new ResourceAllocationInfo();
|
||||||
memInfo.setLimit((long)memoryMB);
|
memInfo.setLimit((long)memoryMB);
|
||||||
memInfo.setReservation((long)memoryMB);
|
memInfo.setReservation((long)memoryReserveMB);
|
||||||
vmConfig.setMemoryAllocation(memInfo);
|
vmConfig.setMemoryAllocation(memInfo);
|
||||||
|
|
||||||
vmConfig.setGuestId(guestOsIdentifier);
|
vmConfig.setGuestId(guestOsIdentifier);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user