Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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}");
            }
        }