Skip to content

Commit b51a2ba

Browse files
Sandidowyunchi-ms
andauthored
Added new cmdlet Restart-AzHost cmdlet for restarting dedicated hosts (#18113)
* manual play * autorest readme dedicatedhostjson * dev, test, changelog, help doc * doc cleanup from meeting Co-authored-by: Yunchi Wang <[email protected]>
1 parent 719066c commit b51a2ba

File tree

7 files changed

+2530
-1
lines changed

7 files changed

+2530
-1
lines changed

src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,12 @@ public void TestDedicatedHostVirtualMachine()
3737
{
3838
TestRunner.RunTestScript("Test-DedicatedHostVirtualMachine");
3939
}
40+
41+
[Fact]
42+
[Trait(Category.AcceptanceType, Category.CheckIn)]
43+
public void TestDedicatedHostRestart()
44+
{
45+
TestRunner.RunTestScript("Test-DedicatedHostRestart");
46+
}
4047
}
4148
}

src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,47 @@ function Test-DedicatedHostVirtualMachine
245245
Clean-ResourceGroup $rgname
246246
}
247247
}
248+
249+
<#
250+
.SYNOPSIS
251+
Test Restart dedicated host feature.
252+
#>
253+
function Test-DedicatedHostRestart
254+
{
255+
# Setup
256+
$rgname = Get-ComputeTestResourceName
257+
258+
try
259+
{
260+
# Common
261+
# [string]$loc = Get-Location "Microsoft.Resources" "resourceGroups" "East US 2 EUAP";
262+
# $loc = $loc.Replace(' ', '');
263+
$loc = "eastus2euap";
264+
265+
266+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
267+
268+
$hostGroupName = $rgname + 'hostgroup';
269+
New-AzHostGroup -ResourceGroupName $rgname -Name $hostGroupName -Location $loc -PlatformFaultDomain 1 -Zone "2" -Tag @{key1 = "val1"};
270+
271+
$hostGroup = Get-AzHostGroup -ResourceGroupName $rgname -Name $hostGroupName;
272+
$hostName = $rgname + 'host';
273+
New-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Location $loc -Sku "ESv3-Type1" -Tag @{key1 = "val2"};
274+
275+
$dedicatedHost = Get-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
276+
277+
# Restart the dedicated host
278+
Restart-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
279+
280+
# Resource Id Parameter set
281+
Restart-AzHost -ResourceId $dedicatedHost.Id;
282+
283+
# Object Parameter set
284+
Restart-AzHost -Host $dedicatedHost;
285+
}
286+
finally
287+
{
288+
# Cleanup
289+
Clean-ResourceGroup $rgname
290+
}
291+
}

0 commit comments

Comments
 (0)