vmware-base: get vsessiontimeout from client class Signed-off-by: Rohit Yadav <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4d9a94ce Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4d9a94ce Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4d9a94ce Branch: refs/heads/4.5 Commit: 4d9a94ce6956e61882b0fd7f15c1ec66d6419135 Parents: 8e15070 Author: Rohit Yadav <[email protected]> Authored: Mon Apr 13 15:37:13 2015 +0530 Committer: Rohit Yadav <[email protected]> Committed: Mon Apr 13 15:44:10 2015 +0530 ---------------------------------------------------------------------- .../hypervisor/vmware/mo/VirtualMachineMO.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d9a94ce/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index c48bfe9..51ddd75 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -458,6 +458,7 @@ public class VirtualMachineMO extends BaseMO { public boolean createSnapshot(String snapshotName, String snapshotDescription, boolean dumpMemory, boolean quiesce) throws Exception { + long apiTimeout = _context.getVimClient().getVcenterSessionTimeout(); ManagedObjectReference morTask = _context.getService().createSnapshotTask(_mor, snapshotName, snapshotDescription, dumpMemory, quiesce); boolean result = _context.getVimClient().waitForTask(morTask); @@ -467,7 +468,7 @@ public class VirtualMachineMO extends BaseMO { ManagedObjectReference morSnapshot = null; // We still need to wait until the object appear in vCenter long startTick = System.currentTimeMillis(); - while (System.currentTimeMillis() - startTick < 10000) { + while (System.currentTimeMillis() - startTick < apiTimeout) { morSnapshot = getSnapshotMor(snapshotName); if (morSnapshot != null) { break; @@ -479,9 +480,11 @@ public class VirtualMachineMO extends BaseMO { } } - if (morSnapshot == null) - 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?!"); - + if (morSnapshot == null) { + 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?!"); + return false; + } + s_logger.debug("Waited for " + (System.currentTimeMillis() - startTick) + " seconds for snapshot object [" + snapshotName + "] to appear in vCenter."); return true; } else { s_logger.error("VMware createSnapshot_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask)); @@ -1753,8 +1756,15 @@ public class VirtualMachineMO extends BaseMO { } } + public String getGuestId() throws Exception { + return (String)_context.getVimClient().getDynamicProperty(_mor, "config.guestId"); + } + public GuestOsDescriptor getGuestOsDescriptor(String guestOsId) throws Exception { GuestOsDescriptor guestOsDescriptor = null; + if (guestOsId == null) { + guestOsId = getGuestId(); + } ManagedObjectReference vmEnvironmentBrowser = _context.getVimClient().getMoRefProp(_mor, "environmentBrowser"); VirtualMachineConfigOption vmConfigOption = _context.getService().queryConfigOption(vmEnvironmentBrowser, null, null); List<GuestOsDescriptor> guestDescriptors = vmConfigOption.getGuestOSDescriptor();
