You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2013/12/28 03:42:06 UTC

git commit: updated refs/heads/master to db99146

Updated Branches:
  refs/heads/master f6b063de7 -> db9914618


CLOUDSTACK-5661 [VMware] DetachIsoCmd succeeds even though cdrom is locked by VM as cdrom is mounted

DetachISO is succeeding even though detach opeartion is failing as cdrom is locked by VM as it was mounted inside VM.
Detect if cdrom is locked or not. If locked fail detach operation and warn user to unmount before detaching the iso/cdrom device.

Signed-off-by: Sateesh Chodapuneedi <sa...@apache.org>

Conflicts:

	plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
	plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
	vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/db991461
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/db991461
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/db991461

Branch: refs/heads/master
Commit: db99146187802ad84ed5e483ea69bffccaf86786
Parents: f6b063d
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Sat Dec 28 02:36:53 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Sat Dec 28 02:36:53 2013 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResource.java      |  9 ++++++---
 .../cloud/storage/resource/VmwareStorageProcessor.java  |  8 +++++---
 .../cloud/hypervisor/vmware/mo/VirtualMachineMO.java    | 12 +++++++++++-
 3 files changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/db991461/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index ade46d2..37ed055 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -4945,9 +4945,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                     if (cmd.isAttach()) {
                         vmMo.mountToolsInstaller();
                     } else {
-                        try {
-                            vmMo.unmountToolsInstaller();
-                        } catch (Throwable e) {
+                        try{
+                            if (!vmMo.unmountToolsInstaller()) {
+                                return new Answer(cmd, false,
+                                        "Failed to unmount vmware-tools installer ISO as the corresponding CDROM device is locked by VM. Please unmount the CDROM device inside the VM and ret-try.");
+                            }
+                        }catch(Throwable e){
                             vmMo.detachIso(null);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/db991461/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index abb6733..e13362d 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1263,9 +1263,11 @@ public class VmwareStorageProcessor implements StorageProcessor {
                     if (isAttach) {
                         vmMo.mountToolsInstaller();
                     } else {
-                        try {
-                            vmMo.unmountToolsInstaller();
-                        } catch (Throwable e) {
+                        try{
+                            if (!vmMo.unmountToolsInstaller()) {
+                                return new AttachAnswer("Failed to unmount vmware-tools installer ISO as the corresponding CDROM device is locked by VM. Please unmount the CDROM device inside the VM and ret-try.");
+                            }
+                        } catch(Throwable e){
                             vmMo.detachIso(null);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/db991461/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 b23b0ff..8c5f0a6 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -2345,11 +2345,13 @@ public class VirtualMachineMO extends BaseMO {
         _context.getService().mountToolsInstaller(_mor);
     }
 
-    public void unmountToolsInstaller() throws Exception {
+    public boolean unmountToolsInstaller() throws Exception {
         int i = 1;
         // Monitor VM questions
         final Boolean[] flags = {false};
         final VirtualMachineMO vmMo = this;
+        final boolean[] encounterQuestion = new boolean[1];
+        encounterQuestion[0] = false;
         Future<?> future = MonitorServiceExecutor.submit(new Runnable() {
             @Override
             public void run() {
@@ -2360,6 +2362,7 @@ public class VirtualMachineMO extends BaseMO {
                         VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
                         VirtualMachineQuestionInfo question = runtimeInfo.getQuestion();
                         if (question != null) {
+                            encounterQuestion[0] = true;
                             if (s_logger.isTraceEnabled()) {
                                 s_logger.trace("Question id: " + question.getId());
                                 s_logger.trace("Question text: " + question.getText());
@@ -2425,6 +2428,13 @@ public class VirtualMachineMO extends BaseMO {
             flags[0] = true;
             future.cancel(true);
         }
+        if (encounterQuestion[0]) {
+            s_logger.warn("cdrom is locked by VM. Failed to detach the ISO.");
+            return false;
+        } else {
+            s_logger.info("Successfully unmounted tools installer from VM.");
+            return true;
+        }
     }
 
     public void redoRegistration(ManagedObjectReference morHost) throws Exception {