Book Image

OpenStack Networking Cookbook

Book Image

OpenStack Networking Cookbook

Overview of this book

Table of Contents (19 chapters)
OpenStack Networking Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a basic ML2 mechanism driver


The first step in the journey to write an ML2 mechanism driver is to create a basic driver class. This will also help us understand the code structure.

Getting ready

As mentioned earlier, we will use DevStack in order to write and test our plugin. So, ensure that the DevStack environment is up and running successfully.

How to do it…

  1. With the appropriate credentials, SSH into your DevStack setup.

  2. Ensure that all the driver files from the GitHub repository are copied to /opt/stack/neutron/neutron/plugins/ml2/drivers.

  3. The ch10_ml2_mech_driver.py file will be our main mechanism driver file, as follows:

  4. The CookbookMechanismDriver class extends the MechanismDriver class of the Neutron API and overrides only the initialize method for now.

  5. You can view the MechanismDriver class defined in the /opt/stack/neutron/neutron/plugins/ml2/driver_api.py file. You will notice that the MechanismDriver class supports many methods related to the Network, Subnet, and Port.

How it...