Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Fixed New-NsxLoadBalancerPool #435

Closed
wants to merge 2 commits into from
Closed
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
17 changes: 10 additions & 7 deletions module/PowerNSX.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Powershell NSX module
#Powershell NSX module
#Nick Bradford
#nbradford@vmware.com
#Version - See Manifest for version details.
Expand Down Expand Up @@ -2793,7 +2793,9 @@ Function ValidateLoadBalancerMemberSpec {
throw "XML Element specified does not contain a name property. Create with New-NsxLoadbalancerMemberSpec"
}
if ( -not ( $argument | get-member -name ipAddress -Membertype Properties)) {
throw "XML Element specified does not contain an ipAddress property. Create with New-NsxLoadbalancerMemberSpec"
if ( -not ( $argument | get-member -name groupingObjectId -MemberType Properties ) ) {
throw "XML Element specified does not contain an ipAddress property. Create with New-NsxLoadbalancerMemberSpec"
}
}
if ( -not ( $argument | get-member -name weight -Membertype Properties)) {
throw "XML Element specified does not contain a weight property. Create with New-NsxLoadbalancerMemberSpec"
Expand Down Expand Up @@ -30253,8 +30255,9 @@ function New-NsxLoadBalancerPool {
write-warning "Load Balancer feature is not enabled on edge $($edgeId). Use Set-NsxLoadBalancer -Enabled to enable."
}

[System.XML.XMLElement]$xmlPool = $_LoadBalancer.OwnerDocument.CreateElement("pool")
$_LoadBalancer.appendChild($xmlPool) | out-null
[System.XML.XmlDocument]$xmldoc = New-Object System.XML.XmlDocument
[System.XML.XMLElement]$xmlPool = $xmldoc.CreateElement("pool")
$xmldoc.appendChild($xmlPool) | out-null

Add-XmlElement -xmlRoot $xmlPool -xmlElementName "name" -xmlElementText $Name
Add-XmlElement -xmlRoot $xmlPool -xmlElementName "description" -xmlElementText $Description
Expand All @@ -30272,11 +30275,11 @@ function New-NsxLoadBalancerPool {
}
}

$URI = "/api/4.0/edges/$EdgeId/loadbalancer/config"
$URI = "/api/4.0/edges/$EdgeId/loadbalancer/config/pools"
$body = $_LoadBalancer.OuterXml

Write-Progress -activity "Update Edge Services Gateway $($EdgeId)" -status "Load Balancer Config"
$null = invoke-nsxwebrequest -method "put" -uri $URI -body $body -connection $connection
$null = invoke-nsxwebrequest -method "post" -uri $URI -body $body -connection $connection
write-progress -activity "Update Edge Services Gateway $($EdgeId)" -completed

$UpdatedEdge = Get-NsxEdge -objectId $($EdgeId) -connection $connection
Expand Down Expand Up @@ -31347,7 +31350,7 @@ function New-NsxLoadBalancerApplicationRule {
#Store the edgeId and remove it from the XML as we need to post it...
$edgeId = $LoadBalancer.edgeId

if ( -not $_LoadBalancer.enabled -eq 'true' ) {
if ( -not $LoadBalancer.enabled -eq 'true' ) {
write-warning "Load Balancer feature is not enabled on edge $($edgeId). Use Set-NsxLoadBalancer -EnableLoadBalancing to enable."
}
#Create a new XML document. Use applicationRule as root.
Expand Down