Esempio n. 1
0
        private void Run()
        {
            WriteWarning("New-AzureRmSnapshotUpdateConfig: 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");

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

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

            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;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                WriteWarning("New-AzureRmSnapshotUpdateConfig: 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;
            }

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

            WriteObject(vSnapshotUpdate);
        }
Esempio n. 2
0
        private void Run()
        {
            // EncryptionSettings
            Microsoft.Azure.Management.Compute.Models.EncryptionSettings vEncryptionSettings = null;

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

            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;
            }

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

            var vSnapshotUpdate = new PSSnapshotUpdate
            {
                OsType             = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB         = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                Tags               = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                EncryptionSettings = vEncryptionSettings,
                Sku = new DiskSku
                {
                    Name = vSku.Name.ToString()
                }
            };

            WriteObject(vSnapshotUpdate);
        }
        private void Run()
        {
            // EncryptionSettings
            Microsoft.Azure.Management.Compute.Models.EncryptionSettings vEncryptionSettings = null;

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

            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;
            }

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


            var vSnapshotUpdate = new PSSnapshotUpdate
            {
                OsType             = this.OsType,
                DiskSizeGB         = this.DiskSizeGB,
                Tags               = (this.Tag == null) ? null : this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value),
                EncryptionSettings = vEncryptionSettings,
                Sku = vSku,
            };

            WriteObject(vSnapshotUpdate);
        }
        protected PSArgument[] CreateSnapshotUpdateParameters()
        {
            string           resourceGroupName = string.Empty;
            string           snapshotName      = string.Empty;
            PSSnapshotUpdate snapshot          = new PSSnapshotUpdate();

            return(ConvertFromObjectsToArguments(
                       new string[] { "ResourceGroupName", "SnapshotName", "Snapshot" },
                       new object[] { resourceGroupName, snapshotName, snapshot }));
        }
        protected void ExecuteSnapshotUpdateMethod(object[] invokeMethodInputParameters)
        {
            string           resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string           snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);
            PSSnapshotUpdate snapshot          = (PSSnapshotUpdate)ParseParameter(invokeMethodInputParameters[2]);
            PSSnapshot       snapshotOrg       = (PSSnapshot)ParseParameter(invokeMethodInputParameters[3]);

            var result = (snapshot == null)
                         ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                         : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

            WriteObject(result);
        }
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName  = this.ResourceGroupName;
                    string snapshotName       = this.SnapshotName;
                    PSSnapshotUpdate snapshot = this.SnapshotUpdate;
                    PSSnapshot snapshotOrg    = this.Snapshot;

                    var result = (snapshot == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

                    var psObject = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
Esempio n. 7
0
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Sku
            SnapshotSku vSku = null;

            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;
            }

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

            var vSnapshotUpdate = new PSSnapshotUpdate
            {
                OsType     = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                Tags       = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Sku = vSku,
            };

            WriteObject(vSnapshotUpdate);
        }
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Encryption
            Encryption vEncryption = null;

            // Sku
            SnapshotSku vSku = null;

            SupportedCapabilities vSupportedCapabilities = null;

            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.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new SnapshotSku();
                }
                vSku.Name = this.SkuName;
            }

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

            var vSnapshotUpdate = new PSSnapshotUpdate
            {
                OsType     = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                Tags       = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption            = vEncryption,
                Sku                   = vSku,
                SupportsHibernation   = this.IsParameterBound(c => c.SupportsHibernation) ? SupportsHibernation : null,
                PublicNetworkAccess   = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null,
                DataAccessAuthMode    = this.IsParameterBound(c => c.DataAccessAuthMode) ? DataAccessAuthMode : null,
                SupportedCapabilities = vSupportedCapabilities
            };

            WriteObject(vSnapshotUpdate);
        }
Esempio n. 9
0
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Encryption
            Encryption vEncryption = null;

            // Sku
            SnapshotSku vSku = null;

            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.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new SnapshotSku();
                }
                vSku.Name = this.SkuName;
            }

            var vSnapshotUpdate = new PSSnapshotUpdate
            {
                OsType     = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                Tags       = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption = vEncryption,
                Sku        = vSku,
            };

            WriteObject(vSnapshotUpdate);
        }