public string GetIP() { CheckProfileHasMaster(); CheckProfileHasVM(); if (ipLazy == null) { Log(string.Format("Getting IP address of VM '{0}' primary network interface.", profile.VM)); GetIPRequest request = new GetIPRequest() { Vm = profile.VM }; GetIPResponse response = GetMasterClient().GetIP(request); ipLazy = response.Ip; } return(ipLazy); }
public GetIPResponse GetIP(GetIPRequest request) { log.InfoFormat("GetIP:\n VM: {0}", request.Vm); string ip = null; Retry((lastRetry) => { string output; int exitCode = ExecuteVBoxCommand("VBoxManage.exe", string.Format("guestproperty get \"{0}\" /VirtualBox/GuestInfo/Net/0/V4/IP", request.Vm), TimeSpan.FromSeconds(30), out output); Match match = Regex.Match(output, @"Value: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"); if (exitCode != 0 || !match.Success) { if (exitCode != 0 || lastRetry) { throw OperationFailed( "Failed to get the IP address of the virtual machine's primary network interface.", ErrorDetails(exitCode, output)); } else { return(false); } } ip = match.Groups[1].Value; return(true); }); return(new GetIPResponse() { Ip = ip }); }
public GetIPResponse GetIP(GetIPRequest request) { log.InfoFormat("GetIP:\n VM: {0}", request.Vm); string ip = null; Retry((lastRetry) => { string output; int exitCode = ExecuteVBoxCommand("VBoxManage.exe", string.Format("guestproperty get \"{0}\" /VirtualBox/GuestInfo/Net/0/V4/IP", request.Vm), TimeSpan.FromSeconds(30), out output); Match match = Regex.Match(output, @"Value: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"); if (exitCode != 0 || ! match.Success) { if (exitCode != 0 || lastRetry) throw OperationFailed( "Failed to get the IP address of the virtual machine's primary network interface.", ErrorDetails(exitCode, output)); else return false; } ip = match.Groups[1].Value; return true; }); return new GetIPResponse() { Ip = ip }; }
public string GetIP() { CheckProfileHasMaster(); CheckProfileHasVM(); if (ipLazy == null) { Log(string.Format("Getting IP address of VM '{0}' primary network interface.", profile.VM)); GetIPRequest request = new GetIPRequest() { Vm = profile.VM }; GetIPResponse response = GetMasterClient().GetIP(request); ipLazy = response.Ip; } return ipLazy; }