コード例 #1
0
        protected override void ProcessRecord()
        {
            ComputeAutomationAutoMapperProfile.Initialize();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;

                    Disk diskObj = new Disk();
                    Mapper.Map <PSDisk, Disk>(this.Disk, diskObj);

                    DiskUpdate diskUpdateObj = new DiskUpdate();
                    Mapper.Map <PSDiskUpdate, DiskUpdate>(this.DiskUpdate, diskUpdateObj);

                    var result = (this.DiskUpdate == null)
                                 ? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskObj)
                                 : DisksClient.Update(resourceGroupName, diskName, diskUpdateObj);

                    var psObject = new PSDisk();
                    Mapper.Map <Disk, PSDisk>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
コード例 #2
0
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                WriteWarning("Update-AzureRmDisk: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                             "The Name property for a Sku will return Standard_LRS and Premium_LRS");

                if (ShouldProcess(this.DiskName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;
                    DiskUpdate diskupdate    = new DiskUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDiskUpdate, DiskUpdate>(this.DiskUpdate, diskupdate);
                    Disk disk = new Disk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDisk, Disk>(this.Disk, disk);

                    var result = (this.DiskUpdate == null)
                                 ? DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk)
                                 : DisksClient.Update(resourceGroupName, diskName, diskupdate);
                    var psObject = new PSDisk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
コード例 #3
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                string resourceGroupName = this.ResourceGroupName;
                string diskName          = this.DiskName;

                if (ShouldGetByName(resourceGroupName, diskName))
                {
                    var result   = DisksClient.Get(resourceGroupName, diskName);
                    var psObject = new PSDisk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
                else if (ShouldListByResourceGroup(resourceGroupName, diskName))
                {
                    var result       = DisksClient.ListByResourceGroup(resourceGroupName);
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = DisksClient.ListByResourceGroupNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSDiskList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDiskList>(r));
                    }
                    WriteObject(TopLevelWildcardFilter(resourceGroupName, diskName, psObject), true);
                }
                else
                {
                    var result       = DisksClient.List();
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = DisksClient.ListNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSDiskList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDiskList>(r));
                    }
                    WriteObject(TopLevelWildcardFilter(resourceGroupName, diskName, psObject), true);
                }
            });
        }
コード例 #4
0
        protected override void ProcessRecord()
        {
            AutoMapper.Mapper.AddProfile <ComputeAutomationAutoMapperProfile>();
            ExecuteClientAction(() =>
            {
                string resourceGroupName = this.ResourceGroupName;
                string diskName          = this.DiskName;

                if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(diskName))
                {
                    var result   = DisksClient.Get(resourceGroupName, diskName);
                    var psObject = new PSDisk();
                    Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
                else if (!string.IsNullOrEmpty(resourceGroupName))
                {
                    var result       = DisksClient.ListByResourceGroup(resourceGroupName);
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = DisksClient.ListByResourceGroupNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSDiskList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(Mapper.Map <Disk, PSDiskList>(r));
                    }
                    WriteObject(psObject, true);
                }
                else
                {
                    var result       = DisksClient.List();
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = DisksClient.ListNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSDiskList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(Mapper.Map <Disk, PSDiskList>(r));
                    }
                    WriteObject(psObject, true);
                }
            });
        }
コード例 #5
0
        protected PSArgument[] CreateDiskCreateOrUpdateParameters()
        {
            string resourceGroupName = string.Empty;
            string diskName          = string.Empty;
            PSDisk disk = new PSDisk();

            return(ConvertFromObjectsToArguments(
                       new string[] { "ResourceGroupName", "DiskName", "Disk" },
                       new object[] { resourceGroupName, diskName, disk }));
        }
コード例 #6
0
        protected void ExecuteDiskCreateOrUpdateMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string diskName          = (string)ParseParameter(invokeMethodInputParameters[1]);
            PSDisk disk = (PSDisk)ParseParameter(invokeMethodInputParameters[2]);

            var result = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk);

            WriteObject(result);
        }
コード例 #7
0
        protected void ExecuteDiskGetMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string diskName          = (string)ParseParameter(invokeMethodInputParameters[1]);

            if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(diskName))
            {
                var result   = DisksClient.Get(resourceGroupName, diskName);
                var psObject = new PSDisk();
                Mapper.Map <Disk, PSDisk>(result, psObject);
                WriteObject(psObject);
            }
            else if (!string.IsNullOrEmpty(resourceGroupName))
            {
                var result       = DisksClient.ListByResourceGroup(resourceGroupName);
                var resultList   = result.ToList();
                var nextPageLink = result.NextPageLink;
                while (!string.IsNullOrEmpty(nextPageLink))
                {
                    var pageResult = DisksClient.ListByResourceGroupNext(nextPageLink);
                    foreach (var pageItem in pageResult)
                    {
                        resultList.Add(pageItem);
                    }
                    nextPageLink = pageResult.NextPageLink;
                }
                var psObject = new List <PSDiskList>();
                foreach (var r in resultList)
                {
                    psObject.Add(Mapper.Map <Disk, PSDiskList>(r));
                }
                WriteObject(psObject);
            }
            else
            {
                var result       = DisksClient.List();
                var resultList   = result.ToList();
                var nextPageLink = result.NextPageLink;
                while (!string.IsNullOrEmpty(nextPageLink))
                {
                    var pageResult = DisksClient.ListNext(nextPageLink);
                    foreach (var pageItem in pageResult)
                    {
                        resultList.Add(pageItem);
                    }
                    nextPageLink = pageResult.NextPageLink;
                }
                var psObject = new List <PSDiskList>();
                foreach (var r in resultList)
                {
                    psObject.Add(Mapper.Map <Disk, PSDiskList>(r));
                }
                WriteObject(psObject);
            }
        }
コード例 #8
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.DiskName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;
                    Disk disk = new Disk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDisk, Disk>(this.Disk, disk);

                    Dictionary <string, List <string> > auxAuthHeader = null;
                    if (!string.IsNullOrEmpty(disk.CreationData?.GalleryImageReference?.Id))
                    {
                        var resourceId = ResourceId.TryParse(disk.CreationData.GalleryImageReference.Id);

                        if (string.Equals("galleries", resourceId?.ResourceType?.Provider, StringComparison.OrdinalIgnoreCase) &&
                            !string.Equals(this.ComputeClient?.ComputeManagementClient?.SubscriptionId, resourceId?.SubscriptionId, StringComparison.OrdinalIgnoreCase))
                        {
                            List <string> resourceIds = new List <string>();
                            resourceIds.Add(disk.CreationData.GalleryImageReference.Id);
                            var auxHeaderDictionary = GetAuxilaryAuthHeaderFromResourceIds(resourceIds);
                            if (auxHeaderDictionary != null && auxHeaderDictionary.Count > 0)
                            {
                                auxAuthHeader = new Dictionary <string, List <string> >(auxHeaderDictionary);
                            }
                        }
                    }

                    Disk result;
                    if (auxAuthHeader != null)
                    {
                        var res = this.DisksClient.CreateOrUpdateWithHttpMessagesAsync(
                            this.ResourceGroupName,
                            diskName,
                            disk,
                            auxAuthHeader).GetAwaiter().GetResult();

                        result = res.Body;
                    }
                    else
                    {
                        result = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk);
                    }
                    var psObject = new PSDisk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
コード例 #9
0
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;
                    PSDisk disk = this.Disk;

                    var result = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk);
                    WriteObject(result);
                }
            });
        }
コード例 #10
0
        private void CreateManagedDisk(string ResourceGroupName, string DiskName, PSDisk psDisk)
        {
            string resourceGroupName = ResourceGroupName;
            string diskName          = DiskName;
            Disk   disk = new Disk();

            ComputeAutomationAutoMapperProfile.Mapper.Map <PSDisk, Disk>(psDisk, disk);

            var result   = this.ComputeClient.ComputeManagementClient.Disks.CreateOrUpdate(resourceGroupName, diskName, disk);
            var psObject = new PSDisk();

            ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);

            WriteVerbose("\nCreated Managed Disk:");
        }
コード例 #11
0
        private PSDisk CreateDiskConfig(long fixedSizeLength)
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            if (this.IsParameterBound(c => c.DiskSku))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.DiskSku;
            }

            vCreationData = new CreationData();
            vCreationData.CreateOption    = "upload";
            vCreationData.UploadSizeBytes = fixedSizeLength;

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.DiskZone) ? this.DiskZone : null,
                OsType            = this.IsParameterBound(c => c.DiskOsType) ? this.DiskOsType : OperatingSystemTypes.Windows,
                HyperVGeneration  = this.IsParameterBound(c => c.DiskHyperVGeneration) ? this.DiskHyperVGeneration : null,
                DiskSizeGB        = null,
                DiskIOPSReadWrite = null,
                DiskMBpsReadWrite = null,
                DiskIOPSReadOnly  = null,
                DiskMBpsReadOnly  = null,
                MaxShares         = null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                Tags         = null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = null,
                Encryption          = null,
                NetworkAccessPolicy = null,
                DiskAccessId        = null,
                DataAccessAuthMode  = this.IsParameterBound(c => c.DataAccessAuthMode) ? this.DataAccessAuthMode : null
            };

            return(vDisk);
        }
コード例 #12
0
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.DiskName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;
                    Disk disk = new Disk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDisk, Disk>(this.Disk, disk);

                    var result   = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk);
                    var psObject = new PSDisk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
コード例 #13
0
        private void createManagedDisk(string ResourceGroupName, string DiskName, PSDisk psDisk)
        {
            string resourceGroupName = ResourceGroupName;
            string diskName          = DiskName;
            Disk   disk = new Disk();

            ComputeAutomationAutoMapperProfile.Mapper.Map <PSDisk, Disk>(psDisk, disk);

            var result   = this.ComputeClient.ComputeManagementClient.Disks.CreateOrUpdate(resourceGroupName, diskName, disk);
            var psObject = new PSDisk();

            ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nCreated Managed Disk:");
            Console.ResetColor();

            WriteObject(psObject);
        }
コード例 #14
0
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.DiskName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;
                    DiskUpdate diskupdate    = new DiskUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDiskUpdate, DiskUpdate>(this.DiskUpdate, diskupdate);
                    Disk disk = new Disk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSDisk, Disk>(this.Disk, disk);

                    var result = (this.DiskUpdate == null)
                                 ? DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk)
                                 : DisksClient.Update(resourceGroupName, diskName, diskupdate);
                    var psObject = new PSDisk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
コード例 #15
0
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string diskName          = this.DiskName;
                    PSDiskUpdate disk        = this.DiskUpdate;
                    PSDisk diskOrg           = this.Disk;

                    var result = (disk == null)
                                 ? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskOrg)
                                 : DisksClient.Update(resourceGroupName, diskName, disk);

                    var psObject = new PSDisk();
                    Mapper.Map <Disk, PSDisk>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
コード例 #16
0
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.CreateOption))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.IsParameterBound(c => c.StorageAccountId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.IsParameterBound(c => c.ImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.IsParameterBound(c => c.SourceUri))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.IsParameterBound(c => c.SourceResourceId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.IsParameterBound(c => c.UploadSizeInBytes))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.UploadSizeBytes = this.UploadSizeInBytes;
            }

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                HyperVGeneration  = this.IsParameterBound(c => c.HyperVGeneration) ? this.HyperVGeneration : null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (int?)null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                Tags         = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
            };

            // this is to hide the breaking change for upload
            if ("upload".Equals(vDisk.CreationData?.CreateOption?.ToLowerInvariant()) && vDisk.CreationData?.UploadSizeBytes == null)
            {
                if (vDisk.DiskSizeGB != null)
                {
                    vDisk.CreationData.UploadSizeBytes = (long)vDisk.DiskSizeGB * 1073741824 + 512;  // multiplying 1GB and then add the size of footer (512 bytes)
                    vDisk.DiskSizeGB = null;
                }
            }

            WriteObject(vDisk);
        }
コード例 #17
0
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("CreateOption"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("StorageAccountId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("ImageReference"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceUri"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceResourceId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled"))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("DiskEncryptionKey"))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("KeyEncryptionKey"))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.MyInvocation.BoundParameters.ContainsKey("Zone") ? this.Zone : null,
                OsType            = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskIOPSReadWrite") ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskMBpsReadWrite") ? this.DiskMBpsReadWrite : (int?)null,
                Location          = this.MyInvocation.BoundParameters.ContainsKey("Location") ? this.Location : null,
                Tags         = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
            };

            WriteObject(vDisk);
        }
コード例 #18
0
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Encryption
            Encryption vEncryption = null;

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.CreateOption))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.IsParameterBound(c => c.StorageAccountId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.IsParameterBound(c => c.ImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.IsParameterBound(c => c.GalleryImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.GalleryImageReference = this.GalleryImageReference;
            }

            if (this.IsParameterBound(c => c.SourceUri))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.IsParameterBound(c => c.SourceResourceId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.IsParameterBound(c => c.UploadSizeInBytes))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.UploadSizeBytes = this.UploadSizeInBytes;
            }

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                HyperVGeneration  = this.IsParameterBound(c => c.HyperVGeneration) ? this.HyperVGeneration : null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (long?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (long?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : (long?)null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : (long?)null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : (int?)null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                Tags         = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption = vEncryption,
            };

            WriteObject(vDisk);
        }
コード例 #19
0
        private void Run()
        {
            // Sku
            Microsoft.Azure.Management.Compute.Models.DiskSku vSku = null;

            // CreationData
            Microsoft.Azure.Management.Compute.Models.CreationData vCreationData = null;

            // EncryptionSettings
            Microsoft.Azure.Management.Compute.Models.EncryptionSettings vEncryptionSettings = null;

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                if (vSku == null)
                {
                    vSku = new Microsoft.Azure.Management.Compute.Models.DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("CreateOption"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("StorageAccountId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("ImageReference"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceUri"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceResourceId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.Enabled = this.EncryptionSettingsEnabled;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("DiskEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("KeyEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.KeyEncryptionKey = this.KeyEncryptionKey;
            }

            var vDisk = new PSDisk
            {
                Zones              = this.MyInvocation.BoundParameters.ContainsKey("Zone") ? this.Zone : null,
                OsType             = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB         = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                Location           = this.MyInvocation.BoundParameters.ContainsKey("Location") ? this.Location : null,
                Tags               = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku                = vSku,
                CreationData       = vCreationData,
                EncryptionSettings = vEncryptionSettings,
            };

            WriteObject(vDisk);
        }
コード例 #20
0
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Encryption
            Encryption vEncryption = null;

            // ExtendedLocation
            ExtendedLocation vExtendedLocation = null;

            // SupportedCapabilities
            SupportedCapabilities vSupportedCapabilities = null;

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.CreateOption))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.IsParameterBound(c => c.StorageAccountId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.IsParameterBound(c => c.ImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.IsParameterBound(c => c.GalleryImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.GalleryImageReference = this.GalleryImageReference;
            }

            if (this.IsParameterBound(c => c.SourceUri))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.IsParameterBound(c => c.SourceResourceId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.IsParameterBound(c => c.UploadSizeInBytes))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.UploadSizeBytes = this.UploadSizeInBytes;
            }

            if (this.IsParameterBound(c => c.LogicalSectorSize))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.LogicalSectorSize = this.LogicalSectorSize;
            }

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            if (this.IsParameterBound(c => c.EdgeZone))
            {
                vExtendedLocation = new ExtendedLocation {
                    Name = this.EdgeZone, Type = ExtendedLocationTypes.EdgeZone
                };
            }

            if (this.IsParameterBound(c => c.AcceleratedNetwork))
            {
                if (vSupportedCapabilities == null)
                {
                    vSupportedCapabilities = new SupportedCapabilities();
                }
                vSupportedCapabilities.AcceleratedNetwork = AcceleratedNetwork;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                HyperVGeneration  = this.IsParameterBound(c => c.HyperVGeneration) ? this.HyperVGeneration : null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (long?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (long?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : (long?)null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : (long?)null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : (int?)null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                ExtendedLocation  = vExtendedLocation,
                Tags         = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption          = vEncryption,
                NetworkAccessPolicy = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy : null,
                DiskAccessId        = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId : null,
                Tier                  = this.IsParameterBound(c => c.Tier) ? this.Tier : null,
                BurstingEnabled       = this.IsParameterBound(c => c.BurstingEnabled) ? this.BurstingEnabled : null,
                PurchasePlan          = this.IsParameterBound(c => c.PurchasePlan) ? this.PurchasePlan : null,
                SupportsHibernation   = this.IsParameterBound(c => c.SupportsHibernation) ? SupportsHibernation : null,
                SupportedCapabilities = vSupportedCapabilities,
                PublicNetworkAccess   = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null
            };

            WriteObject(vDisk);
        }
コード例 #21
0
        private void Run()
        {
            WriteWarning("New-AzureRmDiskConfig: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                         "The Name property for a Sku will return Standard_LRS and Premium_LRS");

            // Sku
            Microsoft.Azure.Management.Compute.Models.DiskSku vSku = null;

            // CreationData
            Microsoft.Azure.Management.Compute.Models.CreationData vCreationData = null;

            // EncryptionSettings
            Microsoft.Azure.Management.Compute.Models.EncryptionSettings vEncryptionSettings = null;

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                WriteWarning("New-AzureRmDiskConfig: The accepted values for parameter SkuName will change in an upcoming breaking change release from" +
                             "StandardLRS and PremiumLRS to Standard_LRS and Premium_LRS, respectively.");
                if (vSku == null)
                {
                    vSku = new Microsoft.Azure.Management.Compute.Models.DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("CreateOption"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("StorageAccountId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("ImageReference"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceUri"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceResourceId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.Enabled = this.EncryptionSettingsEnabled;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("DiskEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("KeyEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.KeyEncryptionKey = this.KeyEncryptionKey;
            }

            var vDisk = new PSDisk
            {
                Zones              = this.MyInvocation.BoundParameters.ContainsKey("Zone") ? this.Zone : null,
                OsType             = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB         = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                Location           = this.MyInvocation.BoundParameters.ContainsKey("Location") ? this.Location : null,
                Tags               = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku                = vSku,
                CreationData       = vCreationData,
                EncryptionSettings = vEncryptionSettings,
            };

            WriteObject(vDisk);
        }
コード例 #22
0
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                WriteWarning("Get-AzureRmDisk: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                             "The Name property for a Sku will return Standard_LRS and Premium_LRS");

                string resourceGroupName = this.ResourceGroupName;
                string diskName          = this.DiskName;

                if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(diskName))
                {
                    var result   = DisksClient.Get(resourceGroupName, diskName);
                    var psObject = new PSDisk();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDisk>(result, psObject);
                    WriteObject(psObject);
                }
                else if (!string.IsNullOrEmpty(resourceGroupName))
                {
                    var result       = DisksClient.ListByResourceGroup(resourceGroupName);
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = DisksClient.ListByResourceGroupNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSDiskList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDiskList>(r));
                    }
                    WriteObject(psObject, true);
                }
                else
                {
                    var result       = DisksClient.List();
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = DisksClient.ListNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSDiskList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Disk, PSDiskList>(r));
                    }
                    WriteObject(psObject, true);
                }
            });
        }
コード例 #23
0
        private void Run()
        {
            // Sku
            Microsoft.Azure.Management.Compute.Models.DiskSku vSku = null;

            // CreationData
            Microsoft.Azure.Management.Compute.Models.CreationData vCreationData = null;

            // EncryptionSettings
            Microsoft.Azure.Management.Compute.Models.EncryptionSettings vEncryptionSettings = null;

            if (this.SkuName != null)
            {
                if (vSku == null)
                {
                    vSku = new Microsoft.Azure.Management.Compute.Models.DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.CreateOption.HasValue)
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.CreateOption = this.CreateOption.Value;
            }

            if (this.StorageAccountId != null)
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.ImageReference != null)
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.SourceUri != null)
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.SourceResourceId != null)
            {
                if (vCreationData == null)
                {
                    vCreationData = new Microsoft.Azure.Management.Compute.Models.CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.EncryptionSettingsEnabled != null)
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.Enabled = this.EncryptionSettingsEnabled;
            }

            if (this.DiskEncryptionKey != null)
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.KeyEncryptionKey != null)
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new Microsoft.Azure.Management.Compute.Models.EncryptionSettings();
                }
                vEncryptionSettings.KeyEncryptionKey = this.KeyEncryptionKey;
            }


            var vDisk = new PSDisk
            {
                Zones              = this.Zone,
                OsType             = this.OsType,
                DiskSizeGB         = this.DiskSizeGB,
                Location           = this.Location,
                Tags               = (this.Tag == null) ? null : this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value),
                Sku                = vSku,
                CreationData       = vCreationData,
                EncryptionSettings = vEncryptionSettings,
            };

            WriteObject(vDisk);
        }