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");
}
}
}
90 changes: 89 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,92 @@ function Test-DiskGrantAccessGetSASWithTL
# Cleanup
Clean-ResourceGroup $rgname;
}
}
}
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 $_;
}
}
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,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"))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 23 additions & 1 deletion 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 Down Expand Up @@ -56,6 +56,17 @@ public override void ExecuteCmdlet()
Disk disk = new Disk();
ComputeAutomationAutoMapperProfile.Mapper.Map<PSDisk, Disk>(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<string, List<string>> auxAuthHeader = null;
if (!string.IsNullOrEmpty(disk.CreationData?.GalleryImageReference?.Id))
{
Expand Down Expand Up @@ -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; }
}
}
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; }
}
}