Skip to content
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

[Compute] Redeploy Dedicated Hosts #26655

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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");
}
}
}
45 changes: 43 additions & 2 deletions src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -333,4 +333,45 @@ 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 "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
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

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 `-Redeploy` parameter as an optional boolean for `Update-AzHost` cmdlet to enhance host management capabilities.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge main to your branch again. This file has a conflict.

* Made `-PublicIpSku` parameter Standard by default in `New-AzVM`

## Version 8.5.0
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; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to this guide. Please use "SwitchParameter" instead.


[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