Fixing rebase issues after integrating with wmi v2 implementation.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e9a9f687 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e9a9f687 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e9a9f687 Branch: refs/heads/hyperv Commit: e9a9f687e27ef0e105cb7fdb73414394ad8af35f Parents: 77cdbcb Author: Devdeep Singh <[email protected]> Authored: Wed Oct 30 11:40:22 2013 +0530 Committer: Devdeep Singh <[email protected]> Committed: Wed Oct 30 11:40:22 2013 +0530 ---------------------------------------------------------------------- .../ServerResource/HypervResource/WmiCallsV2.cs | 48 +++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e9a9f687/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 5a9d586..6914ff3 100755 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs @@ -27,6 +27,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using CloudStack.Plugin.WmiWrappers.ROOT.CIMV2; using System.IO; +using System.Net.NetworkInformation; +using System.Net; namespace HypervResource { @@ -322,6 +324,7 @@ namespace HypervResource AddDiskDriveToVm(newVm, vhdFile, ideCtrllr, driveResourceType); } + String publicIpAddress = ""; // Add the Nics to the VM in the deviceId order. for (int i = 0; i <= 2; i++) { @@ -345,7 +348,12 @@ namespace HypervResource throw ex; } } - + + if (i == 2) + { + publicIpAddress = nic.ip; + } + if (nicid == i) { // Create network adapter @@ -391,7 +399,7 @@ namespace HypervResource } // call patch systemvm iso only for systemvms - if (vmName.StartsWith("r-")) + if (vmName.StartsWith("r-") || vmName.StartsWith("s-") || vmName.StartsWith("v-")) { patchSystemVmIso(vmName, systemVmIso); } @@ -400,16 +408,44 @@ namespace HypervResource SetState(newVm, RequiredState.Enabled); // we need to reboot to get the hv kvp daemon get started vr gets configured. - if (vmName.StartsWith("r-")) + if (vmName.StartsWith("r-") || vmName.StartsWith("s-") || vmName.StartsWith("v-")) { System.Threading.Thread.Sleep(90000); SetState(newVm, RequiredState.Reboot); - // wait for the second boot and then return with suces - System.Threading.Thread.Sleep(50000); + // wait for the second boot and then return with sucesss + pingResource(publicIpAddress); } logger.InfoFormat("Started VM {0}", vmName); return newVm; - } + } + + public static Boolean pingResource(String ip) + { + PingOptions pingOptions = null; + PingReply pingReply = null; + IPAddress ipAddress = null; + Ping pingSender = new Ping(); + int numberOfPings = 4; + int pingTimeout = 1000; + int byteSize = 32; + byte[] buffer = new byte[byteSize]; + ipAddress = IPAddress.Parse(ip); + pingOptions = new PingOptions(); + for (int i = 0; i < numberOfPings; i++) + { + pingReply = pingSender.Send(ipAddress, pingTimeout, buffer, pingOptions); + if (pingReply.Status == IPStatus.Success) + { + return true; + } + else + { + // wait for the second boot and then return with suces + System.Threading.Thread.Sleep(30000); + } + } + return false; + } private EthernetPortAllocationSettingData AttachNicToPort(ComputerSystem newVm, SyntheticEthernetPortSettingData newAdapter) {
