You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2013/12/26 11:36:27 UTC
git commit: updated refs/heads/4.3 to fd831ff
Updated Branches:
refs/heads/4.3 93ea31c6e -> fd831ff2c
CLOUDSTACK-5193 [Hyper-V] VHDs not deleted post VM destroy and expunge
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fd831ff2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fd831ff2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fd831ff2
Branch: refs/heads/4.3
Commit: fd831ff2cab6e70eff8f2b3f435cbf18784aa03e
Parents: 93ea31c
Author: Rajesh Battala <ra...@citrix.com>
Authored: Thu Dec 26 16:10:49 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Dec 26 16:10:49 2013 +0530
----------------------------------------------------------------------
.../HypervResource/HypervResourceController.cs | 58 ++++++++++++++++++++
1 file changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd831ff2/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
index 0bbec16..d4d7e47 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -419,6 +419,64 @@ namespace HypervResource
}
}
+ // POST api/HypervResource/DeleteCommand
+ [HttpPost]
+ [ActionName(CloudStackTypes.DeleteCommand)]
+ public JContainer DeleteCommand([FromBody]dynamic cmd)
+ {
+ using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+ {
+ logger.Info(CloudStackTypes.DestroyCommand + cmd.ToString());
+
+ string details = null;
+ bool result = false;
+
+ try
+ {
+ // Assert
+ String errMsg = "No 'volume' details in " + CloudStackTypes.DestroyCommand + " " + cmd.ToString();
+ VolumeObjectTO destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.data);
+
+ if (destVolumeObjectTO.name == null)
+ {
+ logger.Error(errMsg);
+ throw new ArgumentException(errMsg);
+ }
+
+ String path = destVolumeObjectTO.FullFileName;
+ if (!File.Exists(path))
+ {
+ logger.Info(CloudStackTypes.DestroyCommand + ", but volume at pass already deleted " + path);
+ }
+
+ string vmName = (string)cmd.vmName;
+ if (!string.IsNullOrEmpty(vmName) && File.Exists(path))
+ {
+ // Make sure that this resource is removed from the VM
+ wmiCallsV2.DetachDisk(vmName, path);
+ }
+
+ File.Delete(path);
+ result = true;
+ }
+ catch (Exception sysEx)
+ {
+ details = CloudStackTypes.DestroyCommand + " failed due to " + sysEx.Message;
+ logger.Error(details, sysEx);
+ }
+
+ object ansContent = new
+ {
+ result = result,
+ details = details,
+ contextMap = contextMap
+ };
+
+ return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
+ }
+ }
+
+
private static JArray ReturnCloudStackTypedJArray(object ansContent, string ansType)
{
JObject ansObj = Utils.CreateCloudStackObject(ansType, ansContent);