Skip to content

Commit 8e0fa53

Browse files
committed
Add Drain/Resume
1 parent df32ee7 commit 8e0fa53

2 files changed

Lines changed: 282 additions & 52 deletions

File tree

Infrastructure/AzureStack.Infra.psm1

Lines changed: 126 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Function Get-AzSScaleUnit{
6161
$subscription, $headers = (Get-AzureStackAdminSubTokenHeader -TenantId $tenantId -AzureStackCredentials $azureStackCredentials -EnvironmentName $EnvironmentName)
6262
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/ScaleUnits?api-version=2016-05-01"
6363
$Cluster=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
64-
$Cluster.value |select name,location |fl
64+
$Cluster.value |select name,location,properties
6565

6666
}
6767
export-modulemember -function Get-AzSScaleUnit
@@ -94,7 +94,7 @@ Function Get-AzSScaleUnitNode{
9494
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/scaleunitnodes?api-version=2016-05-01"
9595
$nodes=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
9696
$nodesprop=$nodes.value
97-
$nodesprop.name
97+
$nodesprop|select name,location,properties
9898
}
9999

100100
export-modulemember -function Get-AzSScaleUnitNode
@@ -130,7 +130,7 @@ Function Get-AzSStorageCapacity{
130130
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/storagesubSystems?api-version=2016-05-01"
131131
$Storage=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
132132
$Storageprop=$storage.value
133-
$storageprop.properties|select totalcapacityGB|fl
133+
$storageprop|select name,location,properties
134134

135135
}
136136
export-modulemember -function Get-AzSStorageCapacity
@@ -163,8 +163,7 @@ Function Get-AzSInfraRole{
163163
$subscription, $headers = (Get-AzureStackAdminSubTokenHeader -TenantId $tenantId -AzureStackCredentials $azureStackCredentials -EnvironmentName $EnvironmentName)
164164
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/InfraRoles?api-version=2016-05-01"
165165
$Roles=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
166-
$Roleprop=$roles.value
167-
$Roleprop.Name|fl
166+
$roles.value|select name,properties
168167

169168
}
170169
export-modulemember -function Get-AzSInfraRole
@@ -198,7 +197,7 @@ Function Get-AzSInfraRoleInstance{
198197
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/infraRoleInstances?api-version=2016-05-01"
199198
$VMs=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
200199
$VMprop=$VMs.value
201-
$VMprop|ft name
200+
$VMprop|select name,properties
202201

203202
}
204203
export-modulemember -function Get-AzSInfraRoleInstance
@@ -231,7 +230,7 @@ Function Get-AzSStorageShare{
231230
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/fileShares?api-version=2016-05-01"
232231
$Shares=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
233232
$Shareprop=$Shares.value
234-
$Shareprop.properties|select uncPath|fl
233+
$Shareprop|select name,location,properties
235234

236235
}
237236
export-modulemember -function Get-AzSStorageShare
@@ -264,7 +263,7 @@ Function Get-AzSLogicalNetwork{
264263
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/logicalNetworks?api-version=2016-05-01"
265264
$LNetworks=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
266265
$LNetworkprop=$LNetworks.value
267-
$LNetworkprop|ft name
266+
$LNetworkprop|select name,location,properties
268267

269268
}
270269
export-modulemember -function Get-AzSLogicalNetwork
@@ -297,7 +296,7 @@ Function Get-AzSUpdateSummary{
297296
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Update.Admin/updatelocations/$region/regionUpdateStatus?api-version=2016-05-01"
298297
$USummary=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
299298
$USummaryprop=$USummary.value
300-
$USummaryprop.properties|select locationName,currentversion,lastUpdated,lastChecked,state|fl
299+
$USummaryprop.properties|select locationName,currentversion,lastUpdated,lastChecked,state
301300

302301
}
303302
export-modulemember -function Get-AzSUpdateSummary
@@ -331,7 +330,7 @@ Function Get-AzSUpdate{
331330
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Update.Admin/updatelocations/$region/updates?api-version=2016-05-01"
332331
$Updates=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
333332
$Updateprop=$Updates.value
334-
$Updateprop.properties|select updateName,version,isApplicable,description,state,isDownloaded,packageSizeInMb,kblink|fl
333+
$Updateprop.properties|select updateName,version,isApplicable,description,state,isDownloaded,packageSizeInMb,kblink
335334

336335
}
337336
export-modulemember -function Get-AzSUpdate
@@ -369,7 +368,7 @@ Function Get-AzSUpdateRun{
369368
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Update.Admin/updatelocations/$region/updates/$vupdate/updateRuns?api-version=2016-05-01"
370369
$UpdateRuns=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
371370
$Updaterunprop=$UpdateRuns.value
372-
$Updaterunprop.properties|select updateLocation,updateversion,state,timeStarted,duration|fl
371+
$Updaterunprop.properties|select updateLocation,updateversion,state,timeStarted,duration
373372

374373
}
375374
export-modulemember -function Get-AzSUpdateRun
@@ -433,7 +432,7 @@ Function Close-AzSAlert{
433432
[ValidateNotNullorEmpty()]
434433
[System.Management.Automation.PSCredential] $azureStackCredentials,
435434

436-
[Parameter(Mandatory=$true, HelpMessage="The Azure Stack Administrator Environment Name", ParameterSetName='CloseAlert')]
435+
[Parameter(Mandatory=$true, HelpMessage="The Azure Stack Administrator Environment Name", ParameterSetName='closealert')]
437436
[string] $EnvironmentName,
438437

439438
[Parameter(ParameterSetName='closealert')]
@@ -453,7 +452,6 @@ Function Close-AzSAlert{
453452
$Alerts.properties.state = "Closed"
454453
$AlertUpdateBody = $Alerts | ConvertTo-Json
455454
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.InfrastructureInsights.Admin/regionHealths/$region/Alerts/${alertname}?api-version=2016-05-01"
456-
$URI
457455
$Close=Invoke-RestMethod -Method PUT -Uri $uri -ContentType 'application/json' -Headers $Headers -Body $AlertUpdateBody
458456
$CloseRun=$Close.value
459457
$closeRun
@@ -491,7 +489,7 @@ Function Get-AzSIPPool{
491489
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/IPPools?api-version=2016-05-01"
492490
$IPPools=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
493491
$IPPoolprop=$IPPools.value
494-
$IPPoolprop.properties|select startIpAddress,endIpAddress,numberOfIpAddresses,numberOfAllocatedIpAddresses |fl
492+
$IPPoolprop.properties|select startIpAddress,endIpAddress,numberOfIpAddresses,numberOfAllocatedIpAddresses
495493
}
496494
export-modulemember -function Get-AzSIPPool
497495

@@ -525,7 +523,7 @@ Function Get-AzSMaCPool{
525523
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/MacAddressPools?api-version=2016-05-01"
526524
$MACPools=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
527525
$MaCPoolsprop=$MaCPools.value
528-
$MaCPoolsprop.properties|select startmacAddress,endmacAddress,numberOfmacAddresses,numberOfAllocatedmacAddresses |fl
526+
$MaCPoolsprop.properties|select startmacAddress,endmacAddress,numberOfmacAddresses,numberOfAllocatedmacAddresses
529527
}
530528
export-modulemember -function Get-AzSMaCPool
531529

@@ -559,7 +557,7 @@ Function Get-AzSGatewayPool{
559557
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/edgeGatewayPools?api-version=2016-05-01"
560558
$GatewayPools=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
561559
$MGatewaysprop=$GatewayPools.value
562-
$MGatewaysprop.properties|select Gatewaytype,numberofgateways,redundantGatewayCount,gatewayCapacityKiloBitsPerSecond,publicIpAddress |fl
560+
$MGatewaysprop.properties|select Gatewaytype,numberofgateways,redundantGatewayCount,gatewayCapacityKiloBitsPerSecond,publicIpAddress
563561
}
564562
export-modulemember -function Get-AzSGatewayPool
565563

@@ -594,7 +592,7 @@ Function Get-AzSSLBMUX{
594592
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/SlbMuxInstances?api-version=2016-05-01"
595593
$SLBMUX=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
596594
$SLBMUXprop=$SLBMUX.value
597-
$SLBMUXprop.properties|select VirtualServer,ConfigurationState |fl
595+
$SLBMUXprop.properties|select VirtualServer,ConfigurationState
598596
}
599597
export-modulemember -function Get-AzSSLBMUX
600598

@@ -628,7 +626,7 @@ Function Get-AzSGateway{
628626
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/edgegateways?api-version=2016-05-01"
629627
$Gateways=Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $Headers
630628
$Gatewaysprop=$Gateways.value
631-
$Gatewaysprop.properties|select state, numberofconnections,totalcapacity,availablecapacity |fl
629+
$Gatewaysprop.properties|select state, numberofconnections,totalcapacity,availablecapacity
632630
}
633631
export-modulemember -function Get-AzSGateway
634632

@@ -724,7 +722,7 @@ Function Restart-AzSInfraRoleInstance{
724722
[ValidateNotNullorEmpty()]
725723
[System.Management.Automation.PSCredential] $azureStackCredentials,
726724

727-
[Parameter(Mandatory=$true, HelpMessage="The Azure Stack Administrator Environment Name", ParameterSetName='Restart-AzSInfraRoleInstance')]
725+
[Parameter(Mandatory=$true, HelpMessage="The Azure Stack Administrator Environment Name", ParameterSetName='RestartInfraRoleInstance')]
728726
[string] $EnvironmentName,
729727

730728
[Parameter(ParameterSetName='RestartInfraRoleInstance')]
@@ -800,6 +798,114 @@ $IPPoolBodyJson =$IPPoolBody |ConvertTo-Json
800798
}
801799
export-modulemember -function Add-AzSIPPool
802800

801+
<#
802+
.SYNOPSIS
803+
Enable Maintenance Mode
804+
#>
805+
806+
Function Disable-AzSScaleUnitNode{
807+
[CmdletBinding(DefaultParameterSetName='DisableAzSScaleUnitNode')]
808+
Param(
809+
810+
[Parameter(Mandatory=$true, ParameterSetName='DisableAzSScaleUnitNode')]
811+
[ValidateNotNullorEmpty()]
812+
[String] $TenantId,
813+
814+
[Parameter(Mandatory=$true, ParameterSetName='DisableAzSScaleUnitNode')]
815+
[ValidateNotNullorEmpty()]
816+
[System.Management.Automation.PSCredential] $azureStackCredentials,
817+
818+
[Parameter(Mandatory=$true, HelpMessage="The Azure Stack Administrator Environment Name", ParameterSetName='DisableAzSScaleUnitNode')]
819+
[string] $EnvironmentName,
820+
821+
[Parameter(ParameterSetName='DisableAzSScaleUnitNode')]
822+
[string] $region = 'local',
823+
824+
[Parameter(Mandatory=$true, ParameterSetName='DisableAzSScaleUnitNode')]
825+
[string] $Name
826+
827+
)
828+
$ARMEndpoint = GetARMEndpoint -EnvironmentName $EnvironmentName -ErrorAction Stop
829+
830+
$subscription, $headers = (Get-AzureStackAdminSubTokenHeader -TenantId $tenantId -AzureStackCredentials $azureStackCredentials -EnvironmentName $EnvironmentName)
831+
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/scaleunitnodes/$name/StartMaintenanceMode?api-version=2016-05-01"
832+
$Drain=Invoke-RestMethod -Method Post -Uri $uri -ContentType 'application/json' -Headers $Headers
833+
$Drain
834+
835+
}
836+
export-modulemember -function Disable-AzSScaleUnitNode
837+
838+
839+
<#
840+
.SYNOPSIS
841+
Disable Maintenance Mode
842+
#>
843+
844+
Function Enable-AzSScaleUnitNode{
845+
[CmdletBinding(DefaultParameterSetName='EnableAzSScaleUnitNode')]
846+
Param(
847+
848+
[Parameter(Mandatory=$true, ParameterSetName='EnableAzSScaleUnitNode')]
849+
[ValidateNotNullorEmpty()]
850+
[String] $TenantId,
851+
852+
[Parameter(Mandatory=$true, ParameterSetName='EnableAzSScaleUnitNode')]
853+
[ValidateNotNullorEmpty()]
854+
[System.Management.Automation.PSCredential] $azureStackCredentials,
855+
856+
[Parameter(Mandatory=$true, HelpMessage="The Azure Stack Administrator Environment Name", ParameterSetName='EnableAzSScaleUnitNode')]
857+
[string] $EnvironmentName,
858+
859+
[Parameter(ParameterSetName='EnableAzSScaleUnitNode')]
860+
[string] $region = 'local',
861+
862+
[Parameter(Mandatory=$true, ParameterSetName='EnableAzSScaleUnitNode')]
863+
[string] $Name
864+
865+
)
866+
$ARMEndpoint = GetARMEndpoint -EnvironmentName $EnvironmentName -ErrorAction Stop
867+
868+
$subscription, $headers = (Get-AzureStackAdminSubTokenHeader -TenantId $tenantId -AzureStackCredentials $azureStackCredentials -EnvironmentName $EnvironmentName)
869+
$URI= "${ArmEndpoint}/subscriptions/${subscription}/resourceGroups/system.$region/providers/Microsoft.Fabric.Admin/fabricLocations/$region/scaleunitnodes/$name/StopMaintenanceMode?api-version=2016-05-01"
870+
$Resume=Invoke-RestMethod -Method Post -Uri $uri -ContentType 'application/json' -Headers $Headers
871+
$Resume
872+
873+
}
874+
export-modulemember -function Enable-AzSScaleUnitNode
875+
876+
Function Set-AzSLocationInformation {
877+
Param(
878+
[Parameter(Mandatory = $true)]
879+
[ValidateNotNullorEmpty()]
880+
[String] $TenantId,
881+
882+
[Parameter(Mandatory = $true)]
883+
[System.Management.Automation.PSCredential] $AzureStackCredentials,
884+
885+
[Parameter(Mandatory = $true)]
886+
[string] $EnvironmentName,
887+
888+
[Parameter(Mandatory = $true)]
889+
[string] $Region = 'local',
890+
891+
[Parameter(Mandatory = $true)]
892+
[string] $Latitude = '47.608013',
893+
894+
[Parameter(Mandatory = $true)]
895+
[string] $Longitude = '-122.335167'
896+
)
897+
$ArmEndpoint = GetARMEndpoint -EnvironmentName $EnvironmentName -ErrorAction Stop
898+
$subscription, $headers = (Get-AzureStackAdminSubTokenHeader -TenantId $TenantId -AzureStackCredentials $AzureStackCredentials -EnvironmentName $EnvironmentName)
899+
$uri = "{0}/subscriptions/{1}/providers/Microsoft.Subscriptions.Admin/locations/{2}?api-version=2015-11-01" -f $ArmEndpoint, $subscription, $Region
900+
901+
$obtainedRegion = Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $headers
902+
$obtainedRegion.latitude = $Latitude
903+
$obtainedRegion.longitude = $Longitude
904+
905+
Invoke-WebRequest -Uri $uri -Method PUT -Body $(Convertto-Json $obtainedRegion) -ContentType 'application/json' -Headers $headers
906+
}
907+
Export-ModuleMember -function Set-AzSLocationInformation
908+
803909
Function GetARMEndpoint{
804910
param(
805911
# Azure Stack environment name
@@ -817,4 +923,4 @@ Function GetARMEndpoint{
817923
}
818924

819925
$ARMEndpoint
820-
}
926+
}

0 commit comments

Comments
 (0)