public async Task <VmExtendedDto> GetExtendedInfo(string resourceGroupName, string resourceName, CancellationToken cancellationToken = default)
        {
            var vm = await GetInternalAsync(resourceGroupName, resourceName);

            var result = new VmExtendedDto
            {
                PowerState = AzureVmUtil.GetPowerState(vm),
                OsType     = AzureVmUtil.GetOsType(vm)
            };

            if (vm == null)
            {
                return(result);
            }

            result.SizeName = vm.Size.ToString();

            await DecorateWithNetworkProperties(vm, result, cancellationToken);

            result.Disks.Add(await CreateDiskDto(vm.OSDiskId, true, cancellationToken));

            foreach (var curDiskKvp in vm.DataDisks.Values)
            {
                result.Disks.Add(CreateDiskDto(curDiskKvp, false));
            }

            return(result);
        }
Beispiel #2
0
        public void Vm_getPowerState_WithNull_shouldReturnString()
        {
            var result = AzureVmUtil.GetPowerState(null);

            Assert.Equal("not found", result);
        }