Skip to content

Add Dedicated Host redeploy support #27764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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");
}
}
}
43 changes: 43 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,49 @@ function Test-DedicatedHostUpdateAndSize
$dHUpdate = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -AutoReplaceOnFailure $false;
Assert-AreEqual $dHUpdate.AutoReplaceOnFailure $False ;

}
finally
{
# 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 "Dadsv5-Type1" -Tag @{key1 = "val2"};

# Test Update-AzHost with Redeploy parameter
$updateHost = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Redeploy $true;
Assert-AreEqual $true $updateHost.Redeploy;

# Verify the host is updated
$dedicatedHost = Get-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
Assert-AreEqual $hostName $dedicatedHost.Name;
Assert-AreEqual $rgname $dedicatedHost.ResourceGroupName;
Assert-AreEqual $loc $dedicatedHost.Location;

}
finally
{
Expand Down
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* 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.
* Added `-Redeploy` parameter as an optional boolean for `Update-AzHost` cmdlet to enhance host management capabilities.

## Version 9.3.0
* Added new cmdlets `Add-AzVmssSkuProfileVMSize` and `Remove-AzVmssSkuProfileVMSize` to add and remove VM sizes to and from the VMSS SkuProfile.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,19 @@ public override void ExecuteCmdlet()
parameters.Sku = new Sku(this.Sku, null, null);
}

if (this.IsParameterBound(c => c.Redeploy))
{
var redeployResult = DedicatedHostsClient.Redeploy(resourceGroupName, hostGroupName, Name);
WriteObject(redeployResult);
}
else
{
var result = DedicatedHostsClient.Update(resourceGroupName, hostGroupName, Name, parameters);

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

[Parameter(
Mandatory = false,
HelpMessage = "Redeploy the dedicated host. The operation will complete successfully once the dedicated host has migrated to a new node and is running. To determine the health of VMs deployed on the dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more details.")]
public bool Redeploy { get; set; }

[Parameter(
ParameterSetName = "ResourceIdParameter",
Position = 0,
Expand All @@ -131,4 +144,4 @@ public override void ExecuteCmdlet()
public string ResourceId { get; set; }

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

}
}
}
Loading