Tuesday 24 September 2013

Modular Layer 2 (ML 2) consists of two drivers

Type Drivers

Type Drivers deal with Type specific attributes of the Network. The network types currently supported in ML2 plugin are (local, flat, vlan, gre and vxlan).

Type of the network is provided by the attribute NETWORK_TYPE

The name of the Physical network over which the Virtual Network is realized is provided by the attribute PHYSICAL_NETWORK

The id used for identifying the segment (vlan id , tunnel ID) is provided by  the attribute SEGMENTATION_ID 

Import methods in the Type Driver.

validate_provider_segment
This method is supposed to validate the segment against the provider network configuration.
e.g In case of VLAN Type Driver, this method would validate that the SEGMENTATION_ID is within the VLAN range as specified by the configuration.  

reserve_provider_segment
This method is reserves the resources in the Provider Network.
e.g In case of VLAN Type Driver, this method would allocate a vlan as specified by the SEGMENTATION_ID from its pool.

allocate_tenant_segment
This method is reserves the resources for the Tenant Network
e.g In case of VLAN Type Driver, 

release_segment





Mechanism Drivers

"A mechanism is a device designed to transform input forces and movement into a desired set of output forces and movement"

Mechanism drivers in the Neutron plugin tries to achieve something similar, by transforming the create/delete/update calls on Network/Ports(Resource) to the appropriate calls as understood by the Network device.

Mechanism drivers provide two types of  methods ACTION_RESOURCE_precommit, ACTION_RESOURCE_postcommit, where (ACTION can be create,update, and delete) and (RESOURCE can be network,subnet and port)

e.g create_network_precommit and create_network_postcommit

Precommit Phase.

Drivers can decide to store data to its private database and/or perform any necessary validations. External calls to the Network devices should not be made in this phase. Exceptions raised in this phase can cause the ACTION to be rolled-back (as everything happens in the transaction context)

Postcommit Phase.

Drivers provision the Network device during this phase. Exception raised during this phase can cause the ACTION to be negated in the case of CREATE calls.

e.g  Exceptions in create_network_postcommit can result in delete_network_* calls.

Look at class MechanismDriver(object):