VMware NSX PowerShell based Installation and System Requirements Part-1.
VMware NSX PowerShell Installation and System Requirements – In this blog post we would look at the minimal system requirements of installing VMware NSX and also look at how you can automate the installation using PowerCLI cmdlets.
If you want to understand what is VMware NSX and how it helps to achieve a 100% virtualized SDDC implementation have a look at one of my previous blog post on VMware NSX : Why we need it in SDDC
So lets look at the initial system requirements of Installing NSX :-
a) You need to be running vSphere 5.5 or later (vSphere 6.0, the latest release at the time of this blog post).
b) You would need to have vCenter 5.5 or later installed on your vmware environment.
c) You need to have an Enterprise Plus license, this license is required as it supports VDS or the vSphere distributed switch which is one of the core component to enable the usage of NSX
d) Also you need the support of MTU or Jumbo Frames, this is required for NSX.
Next look at how you can install NSX using PowerCLI.
First thing you need is to head over to the VMware Download Portal and Download the OVA file for NSX.
Once you download the NSX OVA file, launch a powershell console and type in the below commands.
# Import the VMware Core Cmdlets PS Snapin Add-PSSnapin VMware.VimAutomation.Core # Next import the ovf config into a variable using the Get-OvfConfiguration cmdlet $ovfconfig = Get-OvfConfiguration .\VMware-NSX-Manager-6.2.1-3300239.ova
Once you import the config in the $ovfconfig variable, update the properties for each of the object shown below
You can update the properties for the above objects like below, here i show an example on how you can update the property object “vsm_hostname”
Once you assign all the required parameters to the OVF config, you can import the OVA file using the bwloc cmdlet.
# Note you need to enter the other parameters such as $vmhost, $vmname etc as per your environment Import-VApp -Source "C:\Users\vinithm\Downloads\msdnvins\VMware-NSX-Manager-6.2.1-3300239.ova"-OvfConfiguration $ovfconfig -Name $VMNAME -VMHost $vmhost -Datastore $datastore -DiskStorageFormat thin | Start-VM
Once the vAPP gets imported, you would need to register the NSX with your vCenter Server
Login to the NSX appliance and under NSX Management Service, select vCenter server, click on edit and and register the vCenter server.
..continued..
Next log out and login to the vSphere webclient and you would see that NSX is registered with your vCenter server.
Also note that the above steps are also possible via the NSX API, here is a small extract on the webrequest which needs to be passed to configure this via the official NSX API Guide, this can be done via Invoke-WebRequest cmdlet.
First and foremost i would like to thank Chris Wahl for posting some excellent stuff on how to access the NSX API’s using powershell, Chris Wahl GIT HUB Code, Create NSX 3-Tier Application i used a similar way as he had posted on his blog to access the API via powershell.
Next i would like to thank Timo Sugliani for his NSX Scripts, these examples are excellent, we have everything covered which uses the GET method to access the API’s
Using the sample code which is posted in their blogs i was able to create a query to register the vcenter connection.
$Username = "admin" $Password = "vwware1!" $NSXManager = "<NSX MGR IP>" ### Ignore TLS/SSL errors add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; }} "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy ### Create authorization string and store in $head $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Username + ":" + $Password)) $head = @{"Authorization"="Basic $auth"} # Here we have the request to configure vcenter with NSX $Request = "https://<Your NSX Controller IP Here>/api/2.0/services/vcconfig" # Here we create the body of how the request needs to be passed, as per the api guide. $body = "<vcInfo> <ipAddress>$ipaddress_vcenter</ipAddress> <userName>$username_vcenter</userName> <password>$password_vcenter</password> <assignRoleToUser>true</assignRoleToUser> <certificateThumbprint>5B:ED:42:85:D2:CA:FC:1A:52:16:B4:3D:04:06:90:FF:4A:97:68:41</certificateThumbprint> </vcInfo>" ### Connect to NSX Manager via API # Here we use a try catch to catch any exceptions which may occur from Invoke-Webrequest try { $result = Invoke-WebRequest -Uri $Request -Headers $head -ContentType "application/xml" -Method PUT -ErrorAction:Stop -Body $body } catch { $result = $_.Exception.Response.GetResponseStream() $reader = New-Object System.IO.StreamReader($result) $responseBody = $reader.ReadToEnd(); } $responseBody
Once you establish the connection, you would be able to see the vcenter registered with nsx.
You can also access the information on the registered vcenter using a GET method mentioned in the API guide.
$Request = "https://<Your NSX Controller IP Here>/api/2.0/services/vcconfig" $Username = "admin" $Password = "vwware1!" $NSXManager = "<NSX MGR IP>" ### Ignore TLS/SSL errors add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; }} "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy ### Create authorization string and store in $head $auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Username + ":" + $Password)) $head = @{"Authorization"="Basic $auth"} ### Connect to NSX Manager via API $r = Invoke-WebRequest -Uri $Request -Headers $head -ContentType "application/xml" -ErrorAction:Stop [xml]$rxml = $r.Content # Display the Output on Screen $rxml
This would lead you to the following output
I hope you enjoyed this blog post and found the information useful. in the next posts we would look into how you would create a “Controller Cluster”, install VIBs (vSphere Infrastructure bundles) onto the Host Clusters and other components to get ready and start using NSX, and we would be using more of automation in these posts too :).
Do check out some of my other Posts on NSX
Pingback: VMware NSX Components & Architecture - Part 2
Pingback: VMware NSX Controller Cluster creation with PowerShell
Pingback: VMware NSX Host Preparation with PowerShell
Pingback: VMware NSX Logical Switch and DLR config GUI-API
Pingback: Hair-pinning Solved with VMware NSX DLR
Pingback: Getting Started with PowerNSX - PowerShell Module for NSX
Pingback: VMware NSX Edge High Availability - PowerShell Config
Pingback: VMware NSX Edge Load Balancing - PowerShell Config
Pingback: VMware NSX Edge SNAT vs DNAT - PowerShell Config
Pingback: VMware NSX Static vs Dynamic Routing - PowerShell Config