cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject git commit: updated refs/heads/4.2 to 2e0ad8e
Date Fri, 16 Aug 2013 09:11:52 GMT
Updated Branches:
  refs/heads/4.2 25f15bd35 -> 2e0ad8e57


CLOUDSTACK-4352. In VMWare, to resize an offline volume we create a worker vm. When a volume
is being shrinked or when it is resized to the same size delete the vm before returning.


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

Branch: refs/heads/4.2
Commit: 2e0ad8e57335ab509ea6bfcb94433751fe4a2096
Parents: 25f15bd
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Fri Aug 16 14:02:19 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Fri Aug 16 14:36:32 2013 +0530

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2e0ad8e5/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 1ce3d8e..1c5e7b6 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
@@ -657,6 +657,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             }
             VirtualDisk disk = vdisk.first();
             long oldSize = disk.getCapacityInKB();
+            if (newSize <= oldSize && useWorkerVm == true) {
+                deleteWorkerVm(vmMo, vmdkDataStorePath);
+            }
             if (newSize < oldSize){
                 throw new Exception("VMware doesn't support shrinking volume from larger
size: " + oldSize+ " MB to a smaller size: " + newSize + " MB");
             } else if(newSize == oldSize){
@@ -671,14 +674,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
             if (!vmMo.configureVm(vmConfigSpec)) {
                 if (useWorkerVm == true) {
-                    vmMo.detachDisk(vmdkDataStorePath, false);
-                    vmMo.destroy();
+                    deleteWorkerVm(vmMo, vmdkDataStorePath);
                 }
                 throw new Exception("Failed to configure VM to resize disk. vmName: " + vmName);
             }
             if (useWorkerVm == true) {
-                vmMo.detachDisk(vmdkDataStorePath, false);
-                vmMo.destroy();
+                deleteWorkerVm(vmMo, vmdkDataStorePath);
             }
             return new ResizeVolumeAnswer(cmd, true, "success", newSize*1024);
         } catch (Exception e) {
@@ -688,6 +689,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
     }
 
+    private void deleteWorkerVm(VirtualMachineMO vmMo, String vmdkDataStorePath) {
+        try {
+            if (vmMo != null) {
+                s_logger.info("Delete worker VM " + vmMo.getVmName());
+                vmMo.detachDisk(vmdkDataStorePath, false);
+                vmMo.destroy();
+            }
+        } catch (Exception e) {
+            s_logger.error("Unable to destroy worker vm", e);
+        }
+    }
+
     protected Answer execute(CheckNetworkCommand cmd) {
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource CheckNetworkCommand " + _gson.toJson(cmd));


Mime
View raw message