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…
With the appropriate credentials, SSH into your DevStack setup.
Ensure that all the driver files from the GitHub repository are copied to
/opt/stack/neutron/neutron/plugins/ml2/drivers
.The
ch10_ml2_mech_driver.py
file will be our main mechanism driver file, as follows:The
CookbookMechanismDriver
class extends theMechanismDriver
class of the Neutron API and overrides only the initialize method for now.You can view the
MechanismDriver
class defined in the/opt/stack/neutron/neutron/plugins/ml2/driver_api.py
file. You will notice that theMechanismDriver
class supports many methods related to the Network, Subnet, and Port.