From 46635d1f21e06d8930c26043730c9c145a5d12a3 Mon Sep 17 00:00:00 2001 From: Kalen Date: Fri, 2 Feb 2018 09:08:59 -0700 Subject: [PATCH] LDR Password / SSH Options Copied the settings and parameters from New-NSXEdge to the New-NSXLogicalRouter function. The XML structure is the same and if a password isn't specified during deployment, console login will fail. Password is set to a mandatory value so this might break deployments that don't specify one. --- module/PowerNSX.psm1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/module/PowerNSX.psm1 b/module/PowerNSX.psm1 index 2f708f66..cb5bfc23 100644 --- a/module/PowerNSX.psm1 +++ b/module/PowerNSX.psm1 @@ -11460,6 +11460,18 @@ function New-NsxLogicalRouter { #Optional tenant string to be configured on the DLR. [ValidateNotNullOrEmpty()] [String]$Tenant, + [Parameter (Mandatory=$false)] + #Cli account username. + [ValidateNotNullOrEmpty()] + [String]$Username="admin", + [Parameter (Mandatory=$true)] + #CLI account password + [ValidateNotNullOrEmpty()] + [String]$Password, + [Parameter (Mandatory=$false)] + #Enable SSH + [ValidateNotNullOrEmpty()] + [switch]$EnableSSH=$false, [Parameter (Mandatory=$False)] #PowerNSX Connection object [ValidateNotNullOrEmpty()] @@ -11503,6 +11515,19 @@ function New-NsxLogicalRouter { Add-XmlElement -xmlRoot $xmlAppliance -xmlElementName "resourcePoolId" -xmlElementText $ResPoolId Add-XmlElement -xmlRoot $xmlAppliance -xmlElementName "datastoreId" -xmlElementText $datastore.extensiondata.moref.value + #CLI Settings + if ( $PsBoundParameters.ContainsKey('EnableSSH') -or $PSBoundParameters.ContainsKey('Password') ) { + + [System.XML.XMLElement]$xmlCliSettings = $XMLDoc.CreateElement("cliSettings") + $xmlRoot.appendChild($xmlCliSettings) | out-null + + if ( $PsBoundParameters.ContainsKey('Password') ) { + Add-XmlElement -xmlRoot $xmlCliSettings -xmlElementName "userName" -xmlElementText $UserName + Add-XmlElement -xmlRoot $xmlCliSettings -xmlElementName "password" -xmlElementText $Password + } + if ( $PsBoundParameters.ContainsKey('EnableSSH') ) { Add-XmlElement -xmlRoot $xmlCliSettings -xmlElementName "remoteAccess" -xmlElementText $EnableSsh.ToString().ToLower() } + } + if ( $EnableHA ) { [System.XML.XMLElement]$xmlAppliance = $XMLDoc.CreateElement("appliance") $xmlAppliances.appendChild($xmlAppliance) | out-null