diff --git a/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs b/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs index 700af4de4cb1..cd7f26c828ad 100644 --- a/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs +++ b/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs @@ -199,5 +199,19 @@ public void TestDiskGrantAccessGetSASWithTL() TestRunner.RunTestScript("Test-DiskGrantAccessGetSASWithTL"); } - } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgennewazdiskconfig() + { + TestRunner.RunTestScript("TestGen-newazdiskconfig"); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void testgennewazdisk() + { + TestRunner.RunTestScript("TestGen-newazdisk"); + } + } } diff --git a/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1 b/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1 index 153bee5c2953..0c441abde37f 100644 --- a/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1 +++ b/src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1 @@ -1863,4 +1863,92 @@ function Test-DiskGrantAccessGetSASWithTL # Cleanup Clean-ResourceGroup $rgname; } -} \ No newline at end of file +} +function TestGen-newazdiskconfig +{ + $rgname = Get-ComputeTestResourceName; + $loc = Get-Location; + + try + { + New-AzResourceGroup -Name $rgname -Location $loc -Force; + + # Setup + $diskName = 'disk' + $rgname; + $diskAccountType = 'Premium_LRS'; + $createOption = 'Empty'; + $diskSize = 32; + $diskControllerType1 = 'SCSI'; + $diskControllerType2 = 'NVME'; + $encryptionSettingsVersion1 = '1.0'; + $encryptionSettingsVersion2 = '2.0'; + + # Test DiskConfig with DiskControllerType and EncryptionSettingsVersion + $diskConfig1 = New-AzDiskConfig -Location $loc -AccountType $diskAccountType -CreateOption $createOption -DiskSizeGB $diskSize -DiskControllerType $diskControllerType1 -EncryptionSettingsVersion $encryptionSettingsVersion1; + New-AzDisk -ResourceGroupName $rgname -DiskName $diskName -Disk $diskConfig1; + $disk1 = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskName; + Assert-AreEqual $disk1.DiskControllerType $diskControllerType1; + Assert-AreEqual $disk1.EncryptionSettingsVersion $encryptionSettingsVersion1; + + # Update DiskConfig with new DiskControllerType and EncryptionSettingsVersion + $diskUpdateConfig = New-AzDiskUpdateConfig -DiskControllerType $diskControllerType2 -EncryptionSettingsVersion $encryptionSettingsVersion2; + Update-AzDisk -ResourceGroupName $rgname -DiskName $diskName -DiskUpdate $diskUpdateConfig; + $diskUpdated = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskName; + Assert-AreEqual $diskUpdated.DiskControllerType $diskControllerType2; + Assert-AreEqual $diskUpdated.EncryptionSettingsVersion $encryptionSettingsVersion2; + + # Cleanup + Remove-AzDisk -ResourceGroupName $rgname -DiskName $diskName -Force; + Remove-AzResourceGroup -Name $rgname -Force; + } + catch + { + Write-Error "Test failed: $_"; + throw $_; + } +} + +function TestGen-newazdisk +{ + $rgname = Get-ComputeTestResourceName; + $loc = Get-Location; + + try + { + # Create Resource Group + New-AzResourceGroup -Name $rgname -Location $loc -Force; + + # Setup + $diskName = 'disk' + $rgname; + $diskAccountType = 'Premium_LRS'; + $createOption = 'Empty'; + $diskSize = 32; + $diskControllerType1 = 'SCSI'; + $diskControllerType2 = 'NVME'; + $encryptionSettingsVersion1 = '1.0'; + $encryptionSettingsVersion2 = '2.0'; + + # Test DiskControllerType and EncryptionSettingsVersion in New-AzDiskConfig + $diskConfig1 = New-AzDiskConfig -Location $loc -AccountType $diskAccountType -CreateOption $createOption -DiskSizeGB $diskSize -DiskControllerType $diskControllerType1 -EncryptionSettingsVersion $encryptionSettingsVersion1; + New-AzDisk -ResourceGroupName $rgname -DiskName $diskName -Disk $diskConfig1; + $disk1 = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskName; + Assert-AreEqual $disk1.DiskControllerType $diskControllerType1; + Assert-AreEqual $disk1.EncryptionSettingsVersion $encryptionSettingsVersion1; + + # Update DiskControllerType and EncryptionSettingsVersion + $diskUpdateConfig = New-AzDiskUpdateConfig -DiskControllerType $diskControllerType2 -EncryptionSettingsVersion $encryptionSettingsVersion2; + Update-AzDisk -ResourceGroupName $rgname -DiskName $diskName -DiskUpdate $diskUpdateConfig; + $diskUpdated = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskName; + Assert-AreEqual $diskUpdated.DiskControllerType $diskControllerType2; + Assert-AreEqual $diskUpdated.EncryptionSettingsVersion $encryptionSettingsVersion2; + + # Cleanup + Remove-AzDisk -ResourceGroupName $rgname -DiskName $diskName -Force; + Remove-AzResourceGroup -Name $rgname -Force; + } + catch + { + Write-Error "Test failed: $_"; + throw $_; + } +} diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index dd327ab98cbb..2158a314ce7f 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -20,6 +20,7 @@ --> ## Upcoming Release +* Added parameters `DiskControllerType` and `EncryptionSettingsVersion` to `New-AzDisk` and `New-AzDiskConfig`. * Added new properties `Architecture`, `HyperVGeneration`, and `ImageDeprecationStatus` to be returned in `Get-AzVMImage` ListVMImage parameter set. * Deprecated `Get-AzVMSize` 'List Virtual Machine Size' parameter set. * Added new parameters `EnableAutomaticZoneRebalance`, `AutomaticZoneRebalanceStrategy` and `AutomaticZoneRebalanceBehavior` to `New-AzVmssConfig` and `Update-AzVmss` cmdlets for VMSS Automatic Zone Rebalancing. diff --git a/src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskConfigCommand.cs b/src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskConfigCommand.cs index e1c7982b6042..e5ca0168936e 100644 --- a/src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskConfigCommand.cs +++ b/src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskConfigCommand.cs @@ -1,4 +1,4 @@ -// + // // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -254,6 +254,19 @@ public partial class NewAzureRmDiskConfigCommand : Microsoft.Azure.Commands.Reso HelpMessage = "Setting this property to true improves reliability and performance of data disks that are frequently (more than 5 times a day) by detached from one virtual machine and attached to another. This property should not be set for disks that are not detached and attached frequently as it causes the disks to not align with the fault domain of the virtual machine.")] public bool? OptimizedForFrequentAttach { get; set; } + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "The Disk Controller Type. Possible values are SCSI or NVME.")] + [PSArgumentCompleter("SCSI", "NVME")] + public string DiskControllerType { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Specifies the version of the Encryption Settings (for example, 1.0 or 2.0).")] + public string EncryptionSettingsVersion { get; set; } + protected override void ProcessRecord() { if (ShouldProcess("Disk", "New")) @@ -421,6 +434,15 @@ private void Run() vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey; } + if (this.IsParameterBound(c => c.EncryptionSettingsVersion)) + { + if (vEncryptionSettingsCollection == null) + { + vEncryptionSettingsCollection = new EncryptionSettingsCollection(); + } + vEncryptionSettingsCollection.Version = this.EncryptionSettingsVersion; + } + if (this.IsParameterBound(c => c.DiskEncryptionSetId)) { if (vEncryption == null) @@ -489,7 +511,9 @@ private void Run() SupportedCapabilities = vSupportedCapabilities, PublicNetworkAccess = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null, DataAccessAuthMode = this.IsParameterBound(c => c.DataAccessAuthMode) ? DataAccessAuthMode : null, - OptimizedForFrequentAttach = this.IsParameterBound(c => c.OptimizedForFrequentAttach) ? OptimizedForFrequentAttach : null + OptimizedForFrequentAttach = this.IsParameterBound(c => c.OptimizedForFrequentAttach) ? OptimizedForFrequentAttach : null, + DiskControllerType = this.IsParameterBound(c => c.DiskControllerType) ? this.DiskControllerType : null, + EncryptionSettingsVersion = this.IsParameterBound(c => c.EncryptionSettingsVersion) ? this.EncryptionSettingsVersion : null }; WriteObject(vDisk); diff --git a/src/Compute/Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs b/src/Compute/Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs index 3a3e0e58d930..4f7bc2f81b23 100644 --- a/src/Compute/Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs +++ b/src/Compute/Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs @@ -1,4 +1,4 @@ -// + // // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -56,6 +56,17 @@ public override void ExecuteCmdlet() Disk disk = new Disk(); ComputeAutomationAutoMapperProfile.Mapper.Map(this.Disk, disk); + // Apply new optional parameters when they are explicitly provided by the user. + if (this.MyInvocation.BoundParameters.ContainsKey(nameof(DiskControllerType))) + { + disk.DiskControllerType = this.DiskControllerType; + } + + if (this.MyInvocation.BoundParameters.ContainsKey(nameof(EncryptionSettingsVersion))) + { + disk.EncryptionSettingsVersion = this.EncryptionSettingsVersion; + } + Dictionary> auxAuthHeader = null; if (!string.IsNullOrEmpty(disk.CreationData?.GalleryImageReference?.Id)) { @@ -205,5 +216,16 @@ public override void ExecuteCmdlet() [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Specifies the disk controller type to use with the disk. Possible values include 'SCSI' and 'NVME'.")] + [ValidateSet("SCSI", "NVME", IgnoreCase = true)] + public string DiskControllerType { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Specifies the encryption settings version for the disk.")] + public string EncryptionSettingsVersion { get; set; } } } diff --git a/src/Compute/Compute/Generated/Models/PSDisk.cs b/src/Compute/Compute/Generated/Models/PSDisk.cs index d257855adaae..29d051f052e6 100644 --- a/src/Compute/Compute/Generated/Models/PSDisk.cs +++ b/src/Compute/Compute/Generated/Models/PSDisk.cs @@ -79,5 +79,7 @@ public string ResourceGroupName public string DataAccessAuthMode { get; set; } public double? CompletionPercent { get; set; } public bool? OptimizedForFrequentAttach { get; set; } + public string DiskControllerType { get; set; } + public string EncryptionSettingsVersion { get; set; } } }