Book Image

VMware NSX Cookbook

By : Bayu Wibowo, Tony Sangha
Book Image

VMware NSX Cookbook

By: Bayu Wibowo, Tony Sangha

Overview of this book

This book begins with a brief introduction to VMware's NSX for vSphere Network Virtualization solutions and how to deploy and configure NSX components and features such as Logical Switching, Logical Routing, layer 2 bridging and the Edge Services Gateway. Moving on to security, the book shows you how to enable micro-segmentation through NSX Distributed Firewall and Identity Firewall and how to do service insertion via network and guest introspection. After covering all the feature configurations for single-site deployment, the focus then shifts to multi-site setups using Cross-vCenter NSX. Next, the book covers management, backing up and restoring, upgrading, and monitoring using built-in NSX features such as Flow Monitoring, Traceflow, Application Rule Manager, and Endpoint Monitoring. Towards the end, you will explore how to leverage VMware NSX REST API using various tools from Python to VMware vRealize Orchestrator.
Table of Contents (19 chapters)
Title Page
Packt Upsell
Foreword
Contributors
Preface
Index

Using the REST API with Python


Python is one of many programming languages that is widely used for automating networks. There is no built-in REST or HTTP client in Python, but Python allows importing libraries, functions, modules, or frameworks. One of the libraries that can be used to send HTTP REST API requests is the requests library—an Apache2 Licensed HTTP library written in Python. In this recipe, we will import and leverage the requests library to perform a REST API call to NSX in Python version 2.7.

Getting ready

  1. Make sure you have Python and the requests library installed. Python comes pre-installed on many Linux/Unix operating systems. If you do not have Python installed, head over to https://www.python.org/downloads/ to obtain it.
  2. Once Python has been confirmed as installed and available, you can then verify the installation of the Requests Python module. One way to install Requests is through pip using the pip install requests command.

How to do it...

This recipe is divided into two...