private static async Task <VmInfoDto> GetVirtualMachineInfoByName(string vmName) { VmInfoDto vmInfoDto = null; HttpResponseMessage response = await _client.GetAsync($"api/VirtualMachines/{vmName}"); if (response.IsSuccessStatusCode) { vmInfoDto = await response.Content.ReadAsAsync <VmInfoDto>(); } return(vmInfoDto); }
private static async Task RunAsync() { _client.BaseAddress = new Uri("http://localhost:42505/"); _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { List <string> vms = await GetVirtualMachines(); // Get the product VmInfoDto vmInfo = await GetVirtualMachineInfoByName(vms.FirstOrDefault()); } catch (Exception) { throw; } }
private static void WriteVmInfo(VmInfoDto vmInfo) { if (vmInfo == null) { Console.WriteLine("VmInfo is null"); return; } Console.WriteLine("Virtual disk info:"); foreach (var disk in vmInfo.VirtualDisks) { Console.WriteLine( $"Path: {disk.Path} Capacity: {FormatHelper.FormatBytes(disk.Capacity)} Free space: {FormatHelper.FormatBytes(disk.Capacity)}"); } Console.WriteLine("CD-ROM info:"); foreach (var disk in vmInfo.CdDisks) { Console.WriteLine($"Path: {disk.Path}"); } }