Skip to content

Commit 4ce53c9

Browse files
committed
Enable repair, poweron and poweroff operations for scaleunitnodes
1 parent f62786d commit 4ce53c9

File tree

1 file changed

+104
-8
lines changed

1 file changed

+104
-8
lines changed

Infrastructure/AzureStack.Infra.psm1

Lines changed: 104 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ function Start-AzsInfrastructureRoleInstance {
392392
[switch] $Force
393393
)
394394

395-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to start $Name ?", "")) {
395+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to start $Name ?", "")) {
396396
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/infraRoleInstances"
397397

398398
Invoke-AzsInfrastructureAction -Name $Name -Action "poweron" -Location $Location -ResourceType $resourceType
@@ -418,7 +418,7 @@ function Stop-AzsInfrastructureRoleInstance {
418418
[switch] $Force
419419
)
420420

421-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to shut down $Name ?", "")) {
421+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to shut down $Name ?", "")) {
422422
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/infraRoleInstances"
423423

424424
Invoke-AzsInfrastructureAction -Name $Name -Action "shutdown" -Location $Location -ResourceType $resourceType
@@ -444,7 +444,7 @@ function Restart-AzsInfrastructureRoleInstance {
444444
[switch] $Force
445445
)
446446

447-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to restart $Name ?", "")) {
447+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to restart $Name ?", "")) {
448448
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/infraRoleInstances"
449449

450450
Invoke-AzsInfrastructureAction -Name $Name -Action "reboot" -Location $Location -ResourceType $resourceType
@@ -482,7 +482,7 @@ function Add-AzsIpPool {
482482
ResourceType = "Microsoft.Fabric.Admin/fabricLocations/IPPools"
483483
ResourceGroupName = "system.{0}" -f $Location
484484
ApiVersion = "2016-05-01"
485-
Properties = @{
485+
Properties = @{
486486
StartIpAddress = "$StartIPAddress"
487487
EndIpAddress = "$EndIPAddress"
488488
AddressPrefix = "$AddressPrefix"
@@ -512,7 +512,7 @@ function Disable-AzsScaleUnitNode {
512512
[switch] $Force
513513
)
514514

515-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to disable scale unit node $Name ?", "")) {
515+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to disable scale unit node $Name ?", "")) {
516516
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
517517

518518
Invoke-AzsInfrastructureAction -Action "StartMaintenanceMode" -Name $Name -Location $Location -ResourceType $resourceType
@@ -540,7 +540,7 @@ function Enable-AzsScaleUnitNode {
540540
[switch] $Force
541541
)
542542

543-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to enable scale unit node $Name ?", "")) {
543+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to enable scale unit node $Name ?", "")) {
544544
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
545545

546546
Invoke-AzsInfrastructureAction -Action "StopMaintenanceMode" -Name $Name -Location $Location -ResourceType $resourceType
@@ -549,6 +549,94 @@ function Enable-AzsScaleUnitNode {
549549

550550
Export-ModuleMember -Function Enable-AzsScaleUnitNode
551551

552+
<#
553+
.SYNOPSIS
554+
Repairs a scale unit node by reimaging and readding a specific node
555+
#>
556+
557+
function Repair-AzsScaleUnitNode {
558+
[CmdletBinding(SupportsShouldProcess = $true)]
559+
Param(
560+
[Parameter(Mandatory = $false)]
561+
[string] $Location,
562+
563+
[Parameter(Mandatory = $true)]
564+
[ValidateNotNullorEmpty()]
565+
[string] $ScaleUnitNodeName,
566+
567+
[Parameter(Mandatory = $true)]
568+
[ValidateNotNullorEmpty()]
569+
[string] $BMCIPv4Address,
570+
571+
[switch] $Force
572+
)
573+
574+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to repair scale unit node $ScaleUnitNodeName ?", "")) {
575+
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
576+
577+
$parameters = @{
578+
bmcIPv4Address = $BMCIPv4Address
579+
}
580+
581+
Invoke-AzsInfrastructureAction -Action "Repair" -Name $ScaleUnitNodeName -Location $Location -ResourceType $resourceType -Parameters $parameters
582+
}
583+
}
584+
585+
Export-ModuleMember -Function Repair-AzsScaleUnitNode
586+
587+
<#
588+
.SYNOPSIS
589+
Powers off a scale unit node
590+
#>
591+
592+
function Stop-AzsScaleUnitNode {
593+
[CmdletBinding(SupportsShouldProcess = $true)]
594+
Param(
595+
[Parameter(Mandatory = $false)]
596+
[string] $Location,
597+
598+
[Parameter(Mandatory = $true)]
599+
[ValidateNotNullorEmpty()]
600+
[string] $ScaleUnitNodeName,
601+
602+
[switch] $Force
603+
)
604+
605+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to stop scale unit node $ScaleUnitNodeName ?", "")) {
606+
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
607+
608+
Invoke-AzsInfrastructureAction -Action "PowerOff" -Name $ScaleUnitNodeName -Location $Location -ResourceType $resourceType
609+
}
610+
}
611+
612+
Export-ModuleMember -Function Stop-AzsScaleUnitNode
613+
614+
<#
615+
.SYNOPSIS
616+
Powers on a scale unit node
617+
#>
618+
619+
function Start-AzsScaleUnitNode {
620+
[CmdletBinding(SupportsShouldProcess = $true)]
621+
Param(
622+
[Parameter(Mandatory = $false)]
623+
[string] $Location,
624+
625+
[Parameter(Mandatory = $true)]
626+
[ValidateNotNullorEmpty()]
627+
[string] $ScaleUnitNodeName,
628+
629+
[switch] $Force
630+
)
631+
632+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to start scale unit node $ScaleUnitNodeName ?", "")) {
633+
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
634+
635+
Invoke-AzsInfrastructureAction -Action "PowerOn" -Name $ScaleUnitNodeName -Location $Location -ResourceType $resourceType
636+
}
637+
}
638+
639+
Export-ModuleMember -Function Start-AzsScaleUnitNode
552640

553641
<#
554642
.SYNOPSIS
@@ -624,9 +712,12 @@ function Invoke-AzsInfrastructureAction {
624712
[string] $Name,
625713
[string] $Location,
626714
[string] $Action,
627-
[string] $ResourceType
715+
[string] $ResourceType,
716+
717+
[Parameter(Mandatory = $false)]
718+
[Hashtable] $Parameters = $null
628719
)
629-
720+
630721
$Location = Get-AzsHomeLocation -Location $Location
631722

632723
$params = @{
@@ -637,5 +728,10 @@ function Invoke-AzsInfrastructureAction {
637728
ResourceName = "{0}/{1}" -f $Location, $Name
638729
}
639730

731+
if ($Parameters)
732+
{
733+
$params.Parameters = $Parameters
734+
}
735+
640736
Invoke-AzureRmResourceAction @params -Force
641737
}

0 commit comments

Comments
 (0)