From e06672c3c57bfd2e5a6ae161434413eac0f2d1ec Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Mon, 22 Jun 2020 08:58:38 +0200 Subject: [PATCH 1/2] LBVIP: Enhance Example --- module/PowerNSX.psm1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/module/PowerNSX.psm1 b/module/PowerNSX.psm1 index 5a6a2c19..b633da3a 100644 --- a/module/PowerNSX.psm1 +++ b/module/PowerNSX.psm1 @@ -31878,14 +31878,16 @@ function Add-NsxLoadBalancerVip { This cmdlet creates a new Load Balancer VIP. .EXAMPLE - Example1: Need to create member specs for each of the pool members first - PS C:\> $WebVip = Get-NsxEdge Edge01 | - New-NsxLoadBalancerVip -Name WebVip -Description "Test Creating a VIP" - -IpAddress $edge_uplink_ip -Protocol http -Port 80 - -ApplicationProfile $AppProfile -DefaultPool $WebPool - -AccelerationEnabled + $AppProfile = Get-NsxEdge Edge01 | Get-NsxLoadBalancer | New-NsxLoadBalancerApplicationProfile -Name lb_app_profile_http -Type http + PS C:\> $vmmember1 = New-NsxLoadBalancerMemberSpec -name "VM01" -IpAddress 192.0.2.1 -Port 80 + PS C:\> $vmmember2 = New-NsxLoadBalancerMemberSpec -name "VM02" -IpAddress 192.0.2.2 -Port 80 + PS C:\> $WebPool = Get-NsxEdge Edge01 | Get-NsxLoadBalancer | New-NsxLoadBalancerPool -name WebPool -Memberspec $vmmember1, $vmmember2 + + PS C:\> $WebVip = Get-NsxEdge Edge01 | New-NsxLoadBalancerVip -Name WebVip -Description "Test Creating a VIP" -IpAddress $edge_uplink_ip + -Protocol http -Port 80 -ApplicationProfile $AppProfile -DefaultPool $WebPool -AccelerationEnabled + Add Load Balance VIP ($edge_uplink_ip) with Application and DefaultPool using HTTP and Acceleration #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidDefaultValueSwitchParameter","")] # Cant remove without breaking backward compatibility From 2213fe557ba64e0acff775e306c93c165f17751a Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Mon, 22 Jun 2020 09:03:03 +0200 Subject: [PATCH 2/2] LBVIP: Add optional ApplicationRule ID when Add LB VIP missing when Set LB VIP and also check field Part of #626 --- module/PowerNSX.psm1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/PowerNSX.psm1 b/module/PowerNSX.psm1 index b633da3a..e02b52c4 100644 --- a/module/PowerNSX.psm1 +++ b/module/PowerNSX.psm1 @@ -31920,6 +31920,9 @@ function Add-NsxLoadBalancerVip { [Parameter (Mandatory=$true)] [ValidateScript({ ValidateLoadBalancerPool $_ })] [System.Xml.XmlElement]$DefaultPool, + [Parameter (Mandatory=$true)] + #[ValidateScript({ ValidateLoadBalancerApplicationRule $_ })] + [System.Xml.XmlElement]$ApplicationRule, [Parameter (Mandatory=$False)] [ValidateNotNullOrEmpty()] [switch]$AccelerationEnabled=$True, @@ -31966,6 +31969,9 @@ function Add-NsxLoadBalancerVip { Add-XmlElement -xmlRoot $xmlVIip -xmlElementName "applicationProfileId" -xmlElementText $ApplicationProfile.applicationProfileId Add-XmlElement -xmlRoot $xmlVIip -xmlElementName "defaultPoolId" -xmlElementText $DefaultPool.poolId Add-XmlElement -xmlRoot $xmlVIip -xmlElementName "accelerationEnabled" -xmlElementText $AccelerationEnabled + if ( $PsBoundParameters.ContainsKey('ApplicationRule') ) { + Add-XmlElement -xmlRoot $xmlVIip -xmlElementName "ApplicationRuleId" -xmlElementText $ApplicationRule.appRuleId + } $URI = "/api/4.0/edges/$($EdgeId)/loadbalancer/config" $body = $_LoadBalancer.OuterXml