Skip to content

Commit 9118cbe

Browse files
authored
Patch for release 2020 08 25 (#12795)
* fix for EncryptionAtHost * removing default value for encryptionathost for new-azvm * Adding test for null * fixing test * Adding recorderd test to check for null value when encryptionathost is not part of cmdlet * adding to changelog * Updated Changelog
1 parent fc18e96 commit 9118cbe

File tree

8 files changed

+3266
-16
lines changed

8 files changed

+3266
-16
lines changed

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ public void TestLowPriorityVirtualMachine()
284284
TestRunner.RunTestScript("Test-LowPriorityVirtualMachine");
285285
}
286286

287+
[Fact]
288+
[Trait(Category.AcceptanceType, Category.CheckIn)]
289+
public void TestEncryptionAtHostVMNull()
290+
{
291+
TestRunner.RunTestScript("Test-EncryptionAtHostVMNull");
292+
}
293+
287294
[Fact]
288295
[Trait(Category.AcceptanceType, Category.CheckIn)]
289296
public void TestEncryptionAtHostVM()

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,6 +3854,47 @@ function Test-LowPriorityVirtualMachine
38543854
}
38553855
}
38563856

3857+
<#
3858+
.SYNOPSIS
3859+
Test EncryptionAtHost Virtual Machine
3860+
#>
3861+
function Test-EncryptionAtHostVMNull
3862+
{
3863+
# Setup
3864+
$rgname = Get-ComputeTestResourceName
3865+
3866+
try
3867+
{
3868+
$loc = Get-ComputeVMLocation;
3869+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
3870+
3871+
# VM Profile & Hardware
3872+
$vmsize = 'Standard_DS2_v2';
3873+
$vmname = 'vm' + $rgname;
3874+
[string]$domainNameLabel = "$vmname-$vmname".tolower();
3875+
3876+
$user = "Foo2";
3877+
$password = $PLACEHOLDER;
3878+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
3879+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
3880+
$computerName = 'test';
3881+
3882+
$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel;
3883+
Assert-AreEqual $null $vm.SecurityProfile.encryptionathost
3884+
3885+
# Get VM
3886+
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
3887+
Assert-AreEqual $null $vm.SecurityProfile.encryptionAtHost
3888+
Assert-AreEqual $null $vm.encryptionAtHost
3889+
3890+
}
3891+
finally
3892+
{
3893+
# Cleanup
3894+
Clean-ResourceGroup $rgname
3895+
}
3896+
}
3897+
38573898
<#
38583899
.SYNOPSIS
38593900
Test EncryptionAtHost Virtual Machine

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestEncryptionAtHostVMNull.json

Lines changed: 3207 additions & 0 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Additional information about change #1
2020
-->
2121
## Upcoming Release
22+
* Patched -EncryptionAtHost parameter to remove default value of false
2223

2324
## Version 4.3.0
2425
* Added `-EncryptionAtHost` parameter to `New-AzVm`, `New-AzVmss`, `New-AzVMConfig`, `New-AzVmssConfig`, `Update-AzVM`, and `Update-AzVmss`

src/Compute/Compute/Strategies/ComputeRp/VirtualMachineScaleSetStrategy.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ internal static ResourceConfig<VirtualMachineScaleSet> CreateVirtualMachineScale
8181
AdditionalCapabilities = ultraSSDEnabled ? new AdditionalCapabilities(true) : null,
8282
VirtualMachineProfile = new VirtualMachineScaleSetVMProfile
8383
{
84-
SecurityProfile = new SecurityProfile
85-
{
86-
EncryptionAtHost = encryptionAtHost
87-
},
84+
SecurityProfile = (encryptionAtHost == true) ? new SecurityProfile(encryptionAtHost) : null,
8885
OsProfile = new VirtualMachineScaleSetOSProfile
8986
{
9087
ComputerNamePrefix = name.Substring(0, Math.Min(name.Length, 9)),

src/Compute/Compute/Strategies/ComputeRp/VirtualMachineStrategy.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
5656
string priority,
5757
string evictionPolicy,
5858
double? maxPrice,
59-
bool? encryptionAtHostEnabled)
59+
bool encryptionAtHostPresent)
6060

6161
=> Strategy.CreateResourceConfig(
6262
resourceGroup: resourceGroup,
@@ -97,7 +97,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
9797
Priority = priority,
9898
EvictionPolicy = evictionPolicy,
9999
BillingProfile = (maxPrice == null) ? null : new BillingProfile(maxPrice),
100-
SecurityProfile = (encryptionAtHostEnabled == null) ? null : new SecurityProfile(encryptionAtHostEnabled)
100+
SecurityProfile = (encryptionAtHostPresent == true) ? new SecurityProfile(encryptionAtHostPresent) : null
101101
});
102102

103103
public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
@@ -117,7 +117,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
117117
string priority,
118118
string evictionPolicy,
119119
double? maxPrice,
120-
bool? encryptionAtHostEnabled
120+
bool encryptionAtHostPresent
121121
)
122122
=> Strategy.CreateResourceConfig(
123123
resourceGroup: resourceGroup,
@@ -155,10 +155,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
155155
Priority = priority,
156156
EvictionPolicy = evictionPolicy,
157157
BillingProfile = (maxPrice == null) ? null : new BillingProfile(maxPrice),
158-
SecurityProfile = new SecurityProfile
159-
{
160-
EncryptionAtHost = encryptionAtHostEnabled
161-
}
158+
SecurityProfile = (encryptionAtHostPresent == true) ? new SecurityProfile(encryptionAtHostPresent) : null
162159
});
163160
}
164161
}

src/Compute/Compute/VirtualMachine/Config/NewAzureVMConfigCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public class NewAzureVMConfigCommand : Microsoft.Azure.Commands.ResourceManager.
122122
Mandatory = false,
123123
ValueFromPipelineByPropertyName = false,
124124
HelpMessage = "EncryptionAtHost property can be used by user in the request to enable or disable the Host Encryption for the virtual machine. This will enable the encryption for all the disks including Resource/Temp disk at host itself.")]
125-
public SwitchParameter EncryptionAtHost { get; set; } = false;
125+
public SwitchParameter EncryptionAtHost { get; set; }
126126

127127
protected override bool IsUsageMetricEnabled
128128
{

src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public class NewAzureVMCommand : VirtualMachineBaseCmdlet
258258
HelpMessage = "EncryptionAtHost property can be used by user in the request to enable or disable the Host Encryption for the virtual machine. This will enable the encryption for all the disks including Resource/Temp disk at host itself.")]
259259
[Parameter(ParameterSetName = DiskFileParameterSet, Mandatory = false,
260260
HelpMessage = "EncryptionAtHost property can be used by user in the request to enable or disable the Host Encryption for the virtual machine. This will enable the encryption for all the disks including Resource/Temp disk at host itself.")]
261-
public SwitchParameter EncryptionAtHost { get; set; } = false;
261+
public SwitchParameter EncryptionAtHost { get; set; }
262262

263263
public override void ExecuteCmdlet()
264264
{
@@ -395,7 +395,7 @@ public async Task<ResourceConfig<VirtualMachine>> CreateConfigAsync()
395395
priority: _cmdlet.Priority,
396396
evictionPolicy: _cmdlet.EvictionPolicy,
397397
maxPrice: _cmdlet.IsParameterBound(c => c.MaxPrice) ? _cmdlet.MaxPrice : (double?)null,
398-
encryptionAtHostEnabled: _cmdlet.EncryptionAtHost.IsPresent
398+
encryptionAtHostPresent: _cmdlet.EncryptionAtHost.IsPresent
399399
);
400400
}
401401
else
@@ -420,8 +420,8 @@ public async Task<ResourceConfig<VirtualMachine>> CreateConfigAsync()
420420
priority: _cmdlet.Priority,
421421
evictionPolicy: _cmdlet.EvictionPolicy,
422422
maxPrice: _cmdlet.IsParameterBound(c => c.MaxPrice) ? _cmdlet.MaxPrice : (double?)null,
423-
encryptionAtHostEnabled: _cmdlet.EncryptionAtHost.IsPresent
424-
);
423+
encryptionAtHostPresent: _cmdlet.EncryptionAtHost.IsPresent
424+
);
425425
}
426426
}
427427
}

0 commit comments

Comments
 (0)