I spend a lot of time building virtual networking tiers using VMware NSX, and so I wrote a few PowerShell scripts that automate the build and removal process and open sourced them on GitHub here. I’m by no means a wizard at this sort of thing, but I’ve tried to make the code as clean, commented, and error-handling friendly as I could within the past few rounds of commits.
The documentation is rather ugly, and there are more things I’d like to do with the project. If you were following Matt Brender’s really awesome Commitmas project, perhaps you’d consider floundering around GitHub with me and helping with the docs or features. 🙂
Contents
Requirements
- PowerShell 4.0, because I like the Invoke-WebRequest cmdlet.
- PowerCLI 5.x (tested with 5.8), required to pull the vCenter MoRefs for the NSX API requests. I’m open to better ways to do this to avoid needing vCenter at all.
- A functional VMware NSX installation: manager, controllers, prepared cluster, and transport zone. View the Working with NSX posts if you’ve yet to do this part. Yes, I could automate this as well, but I rarely find myself standing up net-new installations when compared to standing up (and removing) virtual networks. Prioritization of my time. 🙂
Topology
The script builds a pretty standard switch > router > transit > edge topology, nothing all that fancy. Here’s a delightful Visio with some sample subnets added as examples.
Results
At the time of this post, the script will build the following components based on what you put into a json file (provided) that holds the configuration variables:
- However many logical switches you desire.
- A distributed logical router for the mentioned switches.
- An edge services gateway.
- A transit switch to bridge the router to the gateway.
- Trimmings: Interface addresses, SSH access, dynamic routing with OSPF, etc.
Have fun!
[symple_box color=”red” fade_in=”false” float=”center” text_align=”left” width=””]Disclaimer: don’t use this in production unless you’re pretty sure of exactly what you’re doing. Even then, I take no responsibility for what happens. :)[/symple_box]