Skip to content

Commit db665fa

Browse files
committed
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>
2 parents 2237486 + a529470 commit db665fa

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
11341134
}
11351135

11361136
try {
1137+
resetVmNicsDeviceId(vm.getId());
11371138
_networkMgr.prepare(vmProfile, new DeployDestination(dest.getDataCenter(), dest.getPod(), null, null, dest.getStorageForDisks()), ctx);
11381139
if (vm.getHypervisorType() != HypervisorType.BareMetal) {
11391140
volumeMgr.prepare(vmProfile, dest);
@@ -1353,6 +1354,26 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
13531354
}
13541355
}
13551356

1357+
private void resetVmNicsDeviceId(Long vmId) {
1358+
final List<NicVO> nics = _nicsDao.listByVmId(vmId);
1359+
Collections.sort(nics, new Comparator<NicVO>() {
1360+
@Override
1361+
public int compare(NicVO nic1, NicVO nic2) {
1362+
Long nicDevId1 = Long.valueOf(nic1.getDeviceId());
1363+
Long nicDevId2 = Long.valueOf(nic2.getDeviceId());
1364+
return nicDevId1.compareTo(nicDevId2);
1365+
}
1366+
});
1367+
int deviceId = 0;
1368+
for (final NicVO nic : nics) {
1369+
if (nic.getDeviceId() != deviceId) {
1370+
nic.setDeviceId(deviceId);
1371+
_nicsDao.update(nic.getId(),nic);
1372+
}
1373+
deviceId ++;
1374+
}
1375+
}
1376+
13561377
// Add extra config data to the vmTO as a Map
13571378
private void addExtraConfig(VirtualMachineTO vmTO) {
13581379
Map<String, String> details = vmTO.getDetails();

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3798,7 +3798,6 @@ protected GetVolumeStatsAnswer execute(GetVolumeStatsCommand cmd) {
37983798
VolumeStatsEntry vse = statEntry.get(chainInfo);
37993799
if (vse != null) {
38003800
vse.setPhysicalSize(vse.getPhysicalSize() + physicalsize);
3801-
vse.setVirtualSize(vse.getVirtualSize() + virtualsize);
38023801
}
38033802
} else {
38043803
VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize);

server/src/main/java/com/cloud/api/query/ViewResponseHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public static List<HostForMigrationResponse> createHostForMigrationResponse(Enum
268268

269269
public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
270270
Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
271-
DecimalFormat df = new DecimalFormat("0.00");
271+
DecimalFormat df = new DecimalFormat("0.0%");
272272
for (VolumeJoinVO vr : volumes) {
273273
VolumeResponse vrData = vrDataList.get(vr.getId());
274274
if (vrData == null) {

server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
190190

191191
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
192192

193-
Float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
194-
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)) + "%";
195-
hostResponse.setCpuAllocated(cpuAlloc);
196-
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
193+
float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
194+
hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
195+
hostResponse.setCpuWithOverprovisioning(Float.toString(cpuWithOverprovisioning));
197196
}
198197

199198
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
@@ -317,7 +316,7 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu
317316
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
318317
// set allocated capacities
319318
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
320-
Long cpu = host.getCpuReservedCapacity() + host.getCpuReservedCapacity();
319+
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();
321320

322321
hostResponse.setMemoryTotal(host.getTotalMemory());
323322
Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
@@ -340,10 +339,9 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu
340339

341340
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
342341

343-
Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()));
344-
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)).toString() + "%";
345-
hostResponse.setCpuAllocated(cpuAlloc);
346-
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
342+
float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
343+
hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
344+
hostResponse.setCpuWithOverprovisioning(Float.toString(cpuWithOverprovisioning));
347345
}
348346

349347
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
@@ -471,4 +469,9 @@ public List<HostJoinVO> findByClusterId(Long clusterId, Host.Type type) {
471469
return listBy(sc);
472470
}
473471

472+
private String calculateResourceAllocatedPercentage(float resource, float resourceWithOverProvision) {
473+
DecimalFormat decimalFormat = new DecimalFormat("#.##");
474+
return decimalFormat.format(((float)resource / resourceWithOverProvision * 100.0f)) + "%";
475+
}
476+
474477
}

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/DatastoreMO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ public long fileDiskSize(String fileFullPath) throws Exception {
356356
FileQueryFlags fqf = new FileQueryFlags();
357357
fqf.setFileSize(true);
358358
fqf.setFileOwner(true);
359+
fqf.setFileType(true);
359360
fqf.setModification(true);
360361
searchSpec.setDetails(fqf);
361362
searchSpec.setSearchCaseInsensitive(false);

0 commit comments

Comments
 (0)