Skip to content

Commit 04dccda

Browse files
committed
vmware-base: get vsessiontimeout from client class
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit 4d9a94c) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent a70947f commit 04dccda

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public VirtualMachineSnapshotInfo getSnapshotInfo() throws Exception {
458458

459459
public boolean createSnapshot(String snapshotName, String snapshotDescription, boolean dumpMemory, boolean quiesce) throws Exception {
460460

461+
long apiTimeout = _context.getVimClient().getVcenterSessionTimeout();
461462
ManagedObjectReference morTask = _context.getService().createSnapshotTask(_mor, snapshotName, snapshotDescription, dumpMemory, quiesce);
462463

463464
boolean result = _context.getVimClient().waitForTask(morTask);
@@ -467,7 +468,7 @@ public boolean createSnapshot(String snapshotName, String snapshotDescription, b
467468
ManagedObjectReference morSnapshot = null;
468469
// We still need to wait until the object appear in vCenter
469470
long startTick = System.currentTimeMillis();
470-
while (System.currentTimeMillis() - startTick < 10000) {
471+
while (System.currentTimeMillis() - startTick < apiTimeout) {
471472
morSnapshot = getSnapshotMor(snapshotName);
472473
if (morSnapshot != null) {
473474
break;
@@ -479,9 +480,11 @@ public boolean createSnapshot(String snapshotName, String snapshotDescription, b
479480
}
480481
}
481482

482-
if (morSnapshot == null)
483-
s_logger.error("We've been waiting for over 10 seconds for snapshot MOR to be appearing in vCenter after CreateSnapshot task is done, but it is still not there?!");
484-
483+
if (morSnapshot == null) {
484+
s_logger.error("We've been waiting for over " + apiTimeout + " milli seconds for snapshot MOR to be appearing in vCenter after CreateSnapshot task is done, but it is still not there?!");
485+
return false;
486+
}
487+
s_logger.debug("Waited for " + (System.currentTimeMillis() - startTick) + " seconds for snapshot object [" + snapshotName + "] to appear in vCenter.");
485488
return true;
486489
} else {
487490
s_logger.error("VMware createSnapshot_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
@@ -1751,8 +1754,15 @@ public VirtualMachineMO cloneFromDiskChain(String clonedVmName, int cpuSpeedMHz,
17511754
}
17521755
}
17531756

1757+
public String getGuestId() throws Exception {
1758+
return (String)_context.getVimClient().getDynamicProperty(_mor, "config.guestId");
1759+
}
1760+
17541761
public GuestOsDescriptor getGuestOsDescriptor(String guestOsId) throws Exception {
17551762
GuestOsDescriptor guestOsDescriptor = null;
1763+
if (guestOsId == null) {
1764+
guestOsId = getGuestId();
1765+
}
17561766
ManagedObjectReference vmEnvironmentBrowser = _context.getVimClient().getMoRefProp(_mor, "environmentBrowser");
17571767
VirtualMachineConfigOption vmConfigOption = _context.getService().queryConfigOption(vmEnvironmentBrowser, null, null);
17581768
List<GuestOsDescriptor> guestDescriptors = vmConfigOption.getGuestOSDescriptor();

0 commit comments

Comments
 (0)