Updated Branches:
  refs/heads/hyperv cce0a27e2 -> 92a66dfdd

If a VM is already running, deploy virtual machine shouldn't fail and throw an 
exception.


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

Branch: refs/heads/hyperv
Commit: 92a66dfddb61a5e2d8e7e1fcf2a9288c98a52dd2
Parents: cce0a27
Author: Donal Lafferty <[email protected]>
Authored: Thu Oct 31 12:19:15 2013 +0530
Committer: Devdeep Singh <[email protected]>
Committed: Thu Oct 31 12:20:35 2013 +0530

----------------------------------------------------------------------
 .../DotNet/ServerResource/HypervResource/WmiCallsV2.cs   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/92a66dfd/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs 
b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
index 4b44a23..71c75d3 100644
--- 
a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ 
b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -235,10 +235,17 @@ namespace HypervResource
                     logger.InfoFormat("Deleting existing VM with name {0}, 
before we go on to create a VM with the same name", vmName);
                     DestroyVm(vmName);
                 }
+                else if (vmWmiObj.EnabledState == EnabledState.Enabled)
+                {
+                    string infoMsg = string.Format("Create VM discovered there 
exists a VM with name {0}, state {1}",
+                        vmName,
+                        EnabledState.ToString(vmWmiObj.EnabledState));
+                    logger.Info(infoMsg);
+                    return vmWmiObj;
+                }
                 else
                 {
-                    // TODO: revise exception type
-                    errMsg = string.Format("Create VM failing, because there 
exists a VM with name {0}, state {1}", 
+                    errMsg = string.Format("Create VM failing, because there 
exists a VM with name {0}, state {1}",
                         vmName,
                         EnabledState.ToString(vmWmiObj.EnabledState));
                     var ex = new WmiException(errMsg);

Reply via email to