Merge remote-tracking branch 'origin/4.14'

Conflicts:
	engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2020-08-05 14:46:13 +05:30
commit db665fa8df
5 changed files with 35 additions and 11 deletions

View File

@ -1134,6 +1134,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
try { try {
resetVmNicsDeviceId(vm.getId());
_networkMgr.prepare(vmProfile, new DeployDestination(dest.getDataCenter(), dest.getPod(), null, null, dest.getStorageForDisks()), ctx); _networkMgr.prepare(vmProfile, new DeployDestination(dest.getDataCenter(), dest.getPod(), null, null, dest.getStorageForDisks()), ctx);
if (vm.getHypervisorType() != HypervisorType.BareMetal) { if (vm.getHypervisorType() != HypervisorType.BareMetal) {
volumeMgr.prepare(vmProfile, dest); volumeMgr.prepare(vmProfile, dest);
@ -1353,6 +1354,26 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
} }
private void resetVmNicsDeviceId(Long vmId) {
final List<NicVO> nics = _nicsDao.listByVmId(vmId);
Collections.sort(nics, new Comparator<NicVO>() {
@Override
public int compare(NicVO nic1, NicVO nic2) {
Long nicDevId1 = Long.valueOf(nic1.getDeviceId());
Long nicDevId2 = Long.valueOf(nic2.getDeviceId());
return nicDevId1.compareTo(nicDevId2);
}
});
int deviceId = 0;
for (final NicVO nic : nics) {
if (nic.getDeviceId() != deviceId) {
nic.setDeviceId(deviceId);
_nicsDao.update(nic.getId(),nic);
}
deviceId ++;
}
}
// Add extra config data to the vmTO as a Map // Add extra config data to the vmTO as a Map
private void addExtraConfig(VirtualMachineTO vmTO) { private void addExtraConfig(VirtualMachineTO vmTO) {
Map<String, String> details = vmTO.getDetails(); Map<String, String> details = vmTO.getDetails();

View File

@ -3798,7 +3798,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VolumeStatsEntry vse = statEntry.get(chainInfo); VolumeStatsEntry vse = statEntry.get(chainInfo);
if (vse != null) { if (vse != null) {
vse.setPhysicalSize(vse.getPhysicalSize() + physicalsize); vse.setPhysicalSize(vse.getPhysicalSize() + physicalsize);
vse.setVirtualSize(vse.getVirtualSize() + virtualsize);
} }
} else { } else {
VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize); VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize);

View File

@ -268,7 +268,7 @@ public class ViewResponseHelper {
public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) { public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>(); Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.0%");
for (VolumeJoinVO vr : volumes) { for (VolumeJoinVO vr : volumes) {
VolumeResponse vrData = vrDataList.get(vr.getId()); VolumeResponse vrData = vrDataList.get(vr.getId());
if (vrData == null) { if (vrData == null) {

View File

@ -190,10 +190,9 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
hostResponse.setHypervisorVersion(host.getHypervisorVersion()); hostResponse.setHypervisorVersion(host.getHypervisorVersion());
Float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()); float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)) + "%"; hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
hostResponse.setCpuAllocated(cpuAlloc); hostResponse.setCpuWithOverprovisioning(Float.toString(cpuWithOverprovisioning));
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
} }
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) { if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
@ -317,7 +316,7 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) { if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
// set allocated capacities // set allocated capacities
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity(); Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
Long cpu = host.getCpuReservedCapacity() + host.getCpuReservedCapacity(); Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();
hostResponse.setMemoryTotal(host.getTotalMemory()); hostResponse.setMemoryTotal(host.getTotalMemory());
Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId()); Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
@ -340,10 +339,9 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
hostResponse.setHypervisorVersion(host.getHypervisorVersion()); hostResponse.setHypervisorVersion(host.getHypervisorVersion());
Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId())); float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)).toString() + "%"; hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
hostResponse.setCpuAllocated(cpuAlloc); hostResponse.setCpuWithOverprovisioning(Float.toString(cpuWithOverprovisioning));
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
} }
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) { if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
@ -471,4 +469,9 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
return listBy(sc); return listBy(sc);
} }
private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) {
DecimalFormat decimalFormat = new DecimalFormat("#.##");
return decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%";
}
} }

View File

@ -356,6 +356,7 @@ public class DatastoreMO extends BaseMO {
FileQueryFlags fqf = new FileQueryFlags(); FileQueryFlags fqf = new FileQueryFlags();
fqf.setFileSize(true); fqf.setFileSize(true);
fqf.setFileOwner(true); fqf.setFileOwner(true);
fqf.setFileType(true);
fqf.setModification(true); fqf.setModification(true);
searchSpec.setDetails(fqf); searchSpec.setDetails(fqf);
searchSpec.setSearchCaseInsensitive(false); searchSpec.setSearchCaseInsensitive(false);