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
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@ public void TestDedicatedHostUpdateAndSize()
{
TestRunner.RunTestScript("Test-DedicatedHostUpdateAndSize");
}
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void testgenupdateazhost()
{
TestRunner.RunTestScript("TestGen-updateazhost");
}
}
}
51 changes: 43 additions & 8 deletions src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# ----------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# you may obtain a copy of the License at
# 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,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
Expand Down Expand Up @@ -333,4 +329,43 @@ function Test-DedicatedHostUpdateAndSize
# Cleanup
Clean-ResourceGroup $rgname
}
}
}

<#
.SYNOPSIS
Test Update-AzHost with Redeploy parameter.
#>
function TestGen-updateazhost
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
[string]$loc = Get-Location "Microsoft.Resources" "resourceGroups" "East US 2 EUAP";
$loc = $loc.Replace(' ', '');

New-AzResourceGroup -Name $rgname -Location $loc -Force;

$hostGroupName = $rgname + 'hostgroup';
New-AzHostGroup -ResourceGroupName $rgname -Name $hostGroupName -Location $loc -PlatformFaultDomain 1 -Zone "2" -Tag @{key1 = "val1"};

$hostName = $rgname + 'host';
New-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Location $loc -Sku "ESv3-Type1" -Tag @{key1 = "val2"};

# Test Update-AzHost without Redeploy
$updateHost = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -AutoReplaceOnFailure $false;
Assert-AreEqual $updateHost.AutoReplaceOnFailure $false;

# Test Update-AzHost with Redeploy
$updateHostRedeploy = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -AutoReplaceOnFailure $false -Redeploy $true;
Assert-AreEqual $updateHostRedeploy.AutoReplaceOnFailure $false;
Assert-AreEqual $true $updateHostRedeploy.Redeploy;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
5 changes: 5 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

-->
## Upcoming Release
* Added the `-Redeploy` parameter to the `Update-AzHost` cmdlet, which triggers a redeployment of the dedicated host.

* Added optional parameters `-SecurityPostureId` and `-SecurityPostureExcludeExtension` to cmdlets `New-AzVmss` and `New-AzVmssConfig`.
* Updated image aliases to be up-to-date in the azure-powershell\src\Compute\Strategies\ComputeRp\Images.json file.
* Added `NvmeDisk` argument completer to `DiffDiskPlacement` parameter for `Set-AzVMOSDisk` and `Set-AzVmssStorageProfile` cmdlets, allowing options for disk placement as `CacheDisk`, `ResourceDisk`, or `NvmeDisk`.
* Added optional parameters `-SecurityPostureId` and `-SecurityPostureExcludeExtension` to cmdlets `New-AzVmss` and `New-AzVmssConfig`.
* Updated image aliases to be up-to-date in the azure-powershell\src\Compute\Strategies\ComputeRp\Images.json file.
* Added `NvmeDisk` argument completer to `DiffDiskPlacement` parameter for `Set-AzVMOSDisk` and `Set-AzVmssStorageProfile` cmdlets, allowing options for disk placement as `CacheDisk`, `ResourceDisk`, or `NvmeDisk`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```csharp
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
Expand All @@ -6,7 +7,7 @@
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// Unless required by applicable law or agreed in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
Expand Down Expand Up @@ -78,6 +79,10 @@ public override void ExecuteCmdlet()
parameters.Sku = new Sku(this.Sku, null, null);
}

if (this.IsParameterBound(c => c.Redeploy))
{
parameters.Redeploy = this.Redeploy; // This line is causing the error
}

var result = DedicatedHostsClient.Update(resourceGroupName, hostGroupName, Name, parameters);
var psObject = new PSHost();
Expand Down Expand Up @@ -123,6 +128,11 @@ public override void ExecuteCmdlet()
Mandatory = false)]
public DedicatedHostLicenseTypes LicenseType { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Triggers redeployment of the dedicated host.")]
public bool Redeploy { get; set; }

[Parameter(
ParameterSetName = "ResourceIdParameter",
Position = 0,
Expand All @@ -132,3 +142,4 @@ public override void ExecuteCmdlet()

}
}
```
4 changes: 2 additions & 2 deletions src/Compute/Compute/Generated/Models/PSHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public string ResourceGroupName
public string Type { get; set; }
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }

public bool? Redeploy { get; set; }
}
}
}