Skip to content

Commit

Permalink
feat: Connect Additional Instances to Cross-Instance Tier-0 Gateway (#…
Browse files Browse the repository at this point in the history
…757)

- Updated `Invoke-NsxFederationDeployment` with `Undo-NsxtGlobalManagerTier0Gateway` procedure.
- Added Documentation.

Signed-off-by: Gary Blake <gblake@vmware.com>
  • Loading branch information
GaryJBlake authored Sep 17, 2024
1 parent ad604d2 commit 925e7ab
Show file tree
Hide file tree
Showing 8 changed files with 544 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
- Added `Remove-NsxtGlobalManagerTier0Gateway` cmdlet to delete the Tier 0 Gateway from the NSX Global Manager.
- Added `Remove-NsxtGlobalManagerTier0LocaleServices` cmdlet to delete the locale service of Tier 0 Gateway from the NSX Global Manager.
- Added `Undo-NsxtGlobalManagerTier0Gateway` cmdlet to remove the Tier 0 Gateway from the NSX Global Manager.
- Added `Remove-NsxtGlobalManagerTier0BgpNeighborConfig ` cmdlet to delete the BGP neighbor of Tier 0 Gateway from the NSX Global Manager.
- Added `Remove-NsxtGlobalManagerTier0BgpNeighborConfig` cmdlet to delete the BGP neighbor of Tier 0 Gateway from the NSX Global Manager.
- Added `Remove-NsxtGlobalManagerTier0ServiceInterface` cmdlet to delete the interface from the Tier 0 Gateway on the NSX Global Manager.
- Added `Export-NsxtGlobalManagerTier0GatewayConfig` cmdlet to create the JSON specification file for the BGP neighbor and interface configuration.
- Added `Update-NsxtGlobalManagerTier1Gateway` cmdlet to update the Tier 1 Gateway on the NSX Global Manager.
Expand Down
2 changes: 1 addition & 1 deletion PowerValidatedSolutions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'PowerValidatedSolutions.psm1'

# Version number of this module.
ModuleVersion = '2.12.0.1028'
ModuleVersion = '2.12.0.1029'

# ID used to uniquely identify this module
GUID = 'a6dfed7b-65d2-4da2-bdcc-7f3d3df9b75d'
Expand Down
140 changes: 119 additions & 21 deletions PowerValidatedSolutions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -31757,16 +31757,6 @@ Function Invoke-NsxFederationDeployment {
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg -errorMessage $ErrorMsg; if ($ErrorMsg) { $failureDetected = $true }
}

if (!$failureDetected) {
Show-PowerValidatedSolutionsOutput -message "Settting Standby Global Manager for $solutionName"
$StatusMsg = Add-NsxtGlobalManagerMode -server $jsonInput.protected.gmClusterFqdn -user admin -pass $jsonInput.protected.adminPassword -mode STANDBY -displayName $jsonInput.recovery.gmName -standbyServer $jsonInput.recovery.gmClusterFqdn -standbyServerUser admin -standbyServerPass $jsonInput.recovery.adminPassword -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -WarningVariable WarnMsg -ErrorVariable ErrorMsg
if ($StatusMsg -match "SUCCESSFUL") {
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg
} else {
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg -errorMessage $ErrorMsg; if ($ErrorMsg) { $failureDetected = $true }
}
}

if (!$failureDetected) {
Show-PowerValidatedSolutionsOutput -message "Creating and Configuring Cross-Instance Tier-1 Gateway for $solutionName"
$StatusMsg = Add-NsxtGlobalManagerTier1Gateway -server $jsonInput.protected.gmClusterFqdn -user admin -pass $jsonInput.protected.adminPassword -tier1Gateway $jsonInput.protected.xregTier1Gateway -tier0Gateway $jsonInput.protected.localTier0Gateway -location $jsonInput.protected.location -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -WarningVariable WarnMsg -ErrorVariable ErrorMsg
Expand All @@ -31781,10 +31771,37 @@ Function Invoke-NsxFederationDeployment {

if (!$failureDetected) {
Show-PowerValidatedSolutionsOutput -message "Deleting Existing Tier-0 Gateways in an Additional Instance for $solutionName"
$StatusMsg = Undo-NsxtGlobalManagerTier0Gateway -server $jsonInput.protected.gmClusterFqdn -user admin -pass $jsonInput.protected.adminPassword-tier0Gateway $jsonInput.recovery.localTier0Gateway -location $jsonInput.recovery.location -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -WarningVariable WarnMsg -ErrorVariable ErrorMsg
$StatusMsg = Undo-NsxtGlobalManagerTier0Gateway -server $jsonInput.protected.gmClusterFqdn -user admin -pass $jsonInput.protected.adminPassword -tier0Gateway $jsonInput.recovery.localTier0Gateway -location $jsonInput.recovery.location -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -WarningVariable WarnMsg -ErrorVariable ErrorMsg
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg -errorMessage $ErrorMsg; if ($ErrorMsg) { $failureDetected = $true }
}

# if (!$failureDetected) {
# Show-PowerValidatedSolutionsOutput -message "Connect Additional VMware Cloud Foundation Instances to Cross-Instance Tier-0 Gateway for $solutionName"
# Update-NsxtGlobalManagerTier0LocaleService
# Update-NsxtGlobalManagerTier0Gateway
# }

if (!$failureDetected) {
Show-PowerValidatedSolutionsOutput -message "Connect Local Tier-1 Gateway to Cross-Instance Tier-0 Gateway for $solutionName"
$StatusMsg = Update-NsxtGlobalManagerTier1Gateway -server $jsonInput.protected.gmClusterFqdn -user admin -pass $jsonInput.protected.adminPassword -tier1Gateway $jsonInput.recovery.localTier1Gateway -tier0Gateway $jsonInput.protected.localTier0Gateway -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -WarningVariable WarnMsg -ErrorVariable ErrorMsg
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg -errorMessage $ErrorMsg; if ($ErrorMsg) { $failureDetected = $true }
}

# if (!$failureDetected) {
# Show-PowerValidatedSolutionsOutput -message "Add Additional Instance as Locations to the Cross-Instance Tier-1 Gateway for $solutionName"
# Update-NsxtGlobalManagerTier1LocaleService
# }

if (!$failureDetected) {
Show-PowerValidatedSolutionsOutput -message "Setting Standby Global Manager for $solutionName"
$StatusMsg = Add-NsxtGlobalManagerMode -server $jsonInput.protected.gmClusterFqdn -user admin -pass $jsonInput.protected.adminPassword -mode STANDBY -displayName $jsonInput.recovery.gmName -standbyServer $jsonInput.recovery.gmClusterFqdn -standbyServerUser admin -standbyServerPass $jsonInput.recovery.adminPassword -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -WarningVariable WarnMsg -ErrorVariable ErrorMsg
if ($StatusMsg -match "SUCCESSFUL") {
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg
} else {
messageHandler -statusMessage $StatusMsg -warningMessage $WarnMsg -errorMessage $ErrorMsg; if ($ErrorMsg) { $failureDetected = $true }
}
}

if (!$failureDetected) {
Show-PowerValidatedSolutionsOutput -type NOTE -message "Finished Deployment of $solutionName"
}
Expand Down Expand Up @@ -33241,25 +33258,25 @@ Function Undo-NsxtGlobalManagerTier0Gateway {
Write-Warning "Deleting interface on Tier 0 Gateway ($tier0Gateway) in NSX Global Manager instance ($($server)), not configured : SKIPPED"
}
Remove-NsxtGlobalManagerTier0LocaleServices -tier0GatewayId $t0Details.id -localeServiceId $localeServiceId | Out-Null
if (-Not (Get-NsxtGlobalManagerTier0LocaleServices -tier0GatewayId $t0Details.id | Where-Object { $_.edge_cluster_path -eq $edge_cluster_path })) {
Write-Output "Removing locale services on NSX T0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): SUCCESSFUL"
if (-Not (Get-NsxtGlobalManagerTier0LocaleServices -tier0GatewayId $t0Details.id | Where-Object {$_.edge_cluster_path -eq $edge_cluster_path})) {
Write-Output "Removing locale services onTier 0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): SUCCESSFUL"
} else {
Write-Error "Removing locale services on NSX T0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): POST_VALIDATION_FAILED"
Write-Error "Removing locale services on Tier 0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): POST_VALIDATION_FAILED"
}
} else {
Write-Warning "Removing locale services on NSX T0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)), not configured : SKIPPED"
Write-Warning "Removing locale services on Tier 0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)), not configured : SKIPPED"
}
Remove-NsxtGlobalManagertier0Gateway -tier0GatewayId $t0Details.id #| Out-Null
if (-Not (Get-NsxtGlobalManagertier0Gateway | Where-Object { $_.display_name -eq $tier0Gateway })) {
Write-Output "Removing NSX T0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): SUCCESSFUL"
if (-Not (Get-NsxtGlobalManagertier0Gateway | Where-Object {$_.display_name -eq $tier0Gateway})) {
Write-Output "Removing Tier 0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): SUCCESSFUL"
} else {
Write-Error "Removing NSX T0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): POST_VALIDATION_FAILED"
Write-Error "Removing Tier 0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)): POST_VALIDATION_FAILED"
}
} else {
Write-Error "Unable to find location ($location) in NSX Global Manager instance ($server): PRE_VALIDATION_FAILED"
}
} else {
Write-Warning "Removing NSX T0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)), not configured : SKIPPED"
Write-Warning "Removing Tier 0 gateway ($tier0Gateway) in NSX Global Manager instance ($($server)), not configured : SKIPPED"
}
}
}
Expand All @@ -33281,7 +33298,7 @@ Function Update-NsxtGlobalManagerTier1Gateway {
- Updates the Tier 1 Gateway on the NSX Global Manager.

.EXAMPLE
Update-NsxtGlobalManagerTier1Gateway -server sfo-m01-nsx-gm01.sfo.rainpole.io -user admin -pass VMw@re1!VMw@re1! -tier1Gateway lax-m01-ec01-t1-gw01 -tier0Gateway sfo-m01-ec01-t0-gw01
Update-NsxtGlobalManagerTier1Gateway -server sfo-m01-nsx-gm01.sfo.rainpole.io -user admin -pass VMw@re1!VMw@re1! -tier1Gateway lax-m01-ec01-t1-gw01 -tier0Gateway sfo-m01-ec01-t0-gw01
This example updates the Tier 1 Gateway on the NSX Global Manager.

.PARAMETER server
Expand All @@ -33298,7 +33315,6 @@ Function Update-NsxtGlobalManagerTier1Gateway {

.PARAMETER tier0Gateway
The NSX Tier0 Gateway to connect to.

#>

Param (
Expand Down Expand Up @@ -47008,6 +47024,88 @@ Function Remove-NsxtGlobalManagerTier0LocaleServices {
}
Export-ModuleMember -Function Remove-NsxtGlobalManagerTier0LocaleServices

Function Remove-NsxtGlobalManagerTier0ServiceInterface {
<#
.SYNOPSIS
Delete the interface from the Tier 0 Gateway on the NSX Global Manager.

.DESCRIPTION
The Remove-NsxtGlobalManagerTier0ServiceInterface cmdlet deletes the interface from the Tier 0 Gateway on the NSX Global Manager.

.EXAMPLE
Remove-NsxtGlobalManagerTier0ServiceInterface -tier0GatewayId "92a3a3b4-a1d1-48a9-8190-dca8e44c18c1" -localeServiceId "lax-m01" -interfaceId "lax-m01-r01-en01_901e6f07-d502-46fd-b71e-e6c27358e905"
This example deletes the interface from the Tier 0 Gateway on the NSX Global Manager.

.PARAMETER tier0GatewayId
The ID of the NSX Tier0 Gateway where the interface is to be deleted.

.PARAMETER localeServiceId
The ID of the locale service.

.PARAMETER interfaceId
The ID of the interface.
#>

Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$tier0GatewayId,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$localeServiceId,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$interfaceId
)

Try {
if ($nsxtHeaders.Authorization) {
$uri = "https://$nsxtManager/global-manager/api/v1/global-infra/tier-0s/$tier0GatewayId/locale-services/$localeServiceId/interfaces/$interfaceId"
Invoke-RestMethod $uri -Method 'DELETE' -Headers $nsxtHeaders
} else {
Write-Error "Not connected to NSX Local/Global Manager, run Request-NsxtToken and try again"
}
} Catch {
Write-Error $_.Exception.Message
}
}
Export-ModuleMember -Function Remove-NsxtGlobalManagerTier0ServiceInterface

Function Remove-NsxtGlobalManagerTier0BgpNeighborConfig {
<#
.SYNOPSIS
Delete the BGP neighbor of Tier 0 Gateway from the NSX Global Manager.

.DESCRIPTION
The Remove-NsxtGlobalManagerTier0BgpNeighborConfig cmdlet deletes the BGP neighbor of Tier 0 Gateway from the NSX Global Manager.

.EXAMPLE
Remove-NsxtGlobalManagerTier0BgpNeighborConfig -tier0GatewayId "92a3a3b4-a1d1-48a9-8190-dca8e44c18c1" -neighborID "172.27.34.10_65211" -localeServiceId "lax-m01"
This example deletes the BGP neighbor of Tier 0 Gateway from the NSX Global Manager.

.PARAMETER tier0GatewayId
The ID of the NSX Tier0 Gateway.

.PARAMETER localeServiceId
The ID of the locale service.

.PARAMETER neighborId
The ID of the BGP neighbor.
#>

Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$tier0GatewayId,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$localeServiceId,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$neighborId
)

Try {
if ($nsxtHeaders.Authorization) {
$uri = "https://$nsxtManager/global-manager/api/v1/global-infra/tier-0s/$tier0GatewayId/locale-services/$localeServiceId/bgp/neighbors/$neighborId"
Invoke-RestMethod $uri -Method 'DELETE' -Headers $nsxtHeaders
} else {
Write-Error "Not connected to NSX Local/Global Manager, run Request-NsxtToken and try again"
}
} Catch {
Write-Error $_.Exception.Message
}
}
Export-ModuleMember -Function Remove-NsxtGlobalManagerTier0BgpNeighborConfig

#EndRegion End NSX Functions ######
###################################################################################

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Export-NsxtGlobalManagerTier0GatewayConfig

## Synopsis

Create the JSON specification file for the BGP neighbor and interface configuration.

## Syntax

```powershell
Export-NsxtGlobalManagerTier0GatewayConfig [-server] <String> [-user] <String> [-pass] <String> [-tier0Gateway] <String> [-location] <String> [-bgpNeighborJsonFile] <String> [-interfaceJsonFile] <String> [<CommonParameters>]
```

## Description

The `Export-NsxtGlobalManagerTier0GatewayConfig` cmdlet removes the Tier 0 Gateway from the NSX Global Manager.

- Validates that network connectivity and authentication is possible to NSX Global Manager.
- Creates the JSON specification file for the BGP neighbor and interface configuration, if configured.

## Examples

### Example 1

```powershell
Export-NsxtGlobalManagerTier0GatewayConfig -server sfo-m01-nsx-gm01.sfo.rainpole.io -user admin -pass VMw@re1!VMw@re1! -tier0Gateway lax-m01-ec01-t0-gw01 -location lax-m01 -bgpNeighborJsonFile ./tier0-bgp-neighbor.json -interfaceJsonFile ./tier0-interface.json
```

This example creates the JSON specification file for the BGP neighbor and interface configuration.

## Parameters

### -server

The fully qualified domain name of the NSX Global Manager.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -user
The username to authenticate to the NSX Global Manager.
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -pass
The password to authenticate to the NSX Global Manager.
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -tier0Gateway
The NSX Tier0 Gateway name to delete.
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -location
The name of the location.
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -bgpNeighborJsonFile
The JSON file to be used for exporting the BGP neighbor configuration
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -interfaceJsonFile
The JSON file to be used for exporting the interface configuration
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### Common Parameters
This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, `-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Loading

0 comments on commit 925e7ab

Please sign in to comment.