Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Compute/Compute.Test/ScenarioTests/DiskRPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
91 changes: 90 additions & 1 deletion src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1863,4 +1863,93 @@ function Test-DiskGrantAccessGetSASWithTL
# Cleanup
Clean-ResourceGroup $rgname;
}
}
}
function TestGen-newazdiskconfig
{
$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 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;
}
}
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -254,6 +254,17 @@ 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)]
[PSArgumentCompleter("SCSI", "NVME")]
public string DiskControllerType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
public string EncryptionSettingsVersion { get; set; }

protected override void ProcessRecord()
{
if (ShouldProcess("Disk", "New"))
Expand Down Expand Up @@ -421,6 +432,15 @@ private void Run()
vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
}

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

if (this.IsParameterBound(c => c.DiskEncryptionSetId))
{
if (vEncryption == null)
Expand Down Expand Up @@ -489,7 +509,8 @@ 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
};

WriteObject(vDisk);
Expand Down
30 changes: 27 additions & 3 deletions src/Compute/Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -7,7 +7,7 @@
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
Expand Down Expand Up @@ -56,6 +56,17 @@ public override void ExecuteCmdlet()
Disk disk = new Disk();
ComputeAutomationAutoMapperProfile.Mapper.Map<PSDisk, Disk>(this.Disk, disk);

// Apply overrides from cmdlet parameters if provided
if (!string.IsNullOrEmpty(this.DiskControllerType))
{
disk.DiskControllerType = this.DiskControllerType;
}

if (!string.IsNullOrEmpty(this.EncryptionSettingsVersion))
{
disk.EncryptionSettingsVersion = this.EncryptionSettingsVersion;
}

Dictionary<string, List<string>> auxAuthHeader = null;
if (!string.IsNullOrEmpty(disk.CreationData?.GalleryImageReference?.Id))
{
Expand Down Expand Up @@ -205,5 +216,18 @@ public override void ExecuteCmdlet()

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the disk controller type.")]
[ValidateSet("SCSI", "NVME", IgnoreCase = true)]
public string DiskControllerType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the encryption settings version.")]
public string EncryptionSettingsVersion { get; set; }
}
}
}
2 changes: 2 additions & 0 deletions src/Compute/Compute/Generated/Models/PSDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}