Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2456B10F73 for ; Fri, 27 Dec 2013 09:49:26 +0000 (UTC) Received: (qmail 13035 invoked by uid 500); 27 Dec 2013 09:48:59 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 12817 invoked by uid 500); 27 Dec 2013 09:48:48 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 12534 invoked by uid 99); 27 Dec 2013 09:48:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Dec 2013 09:48:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CD6B681A918; Fri, 27 Dec 2013 09:48:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rajeshbattala@apache.org To: commits@cloudstack.apache.org Date: Fri, 27 Dec 2013 09:48:51 -0000 Message-Id: In-Reply-To: <306acc9bdfd74b80b525769261d64845@git.apache.org> References: <306acc9bdfd74b80b525769261d64845@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/12] git commit: updated refs/heads/master to ea09c04 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/ea09c043 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ea09c043 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ea09c043 Branch: refs/heads/master Commit: ea09c0435f50af42aa3ec2916484ce2a8a7e1f49 Parents: 31969e9 Author: Rajesh Battala Authored: Thu Dec 26 16:10:49 2013 +0530 Committer: Rajesh Battala Committed: Fri Dec 27 14:59:57 2013 +0530 ---------------------------------------------------------------------- .../HypervResource/HypervResourceController.cs | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ea09c043/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 c24e177..287f9f2 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);