networking_baremetal.plugins.ml2 package¶
Submodules¶
networking_baremetal.plugins.ml2.baremetal_l2vni_mapping module¶
- class networking_baremetal.plugins.ml2.baremetal_l2vni_mapping.L2vniMechanismDriver¶
Bases:
MechanismDriverML2 mechanism driver for L2VNI binding
This mechanism driver is called on port binding to facilitate the VTEP to VLAN binding necessary for EVPN networks to attach to baremetal ports, which may then connect to the environment through an EVPN connection, or through direct port attachments
- bind_port(context)¶
Attempt to bind a port.
- Parameters:
context – PortContext instance describing the port
This method is called outside any transaction to attempt to establish a port binding using this mechanism driver. Bindings may be created at each of multiple levels of a hierarchical network, and are established from the top level downward. At each level, the mechanism driver determines whether it can bind to any of the network segments in the context.segments_to_bind property, based on the value of the context.host property, any relevant port or network attributes, and its own knowledge of the network topology. At the top level, context.segments_to_bind contains the static segments of the port’s network. At each lower level of binding, it contains static or dynamic segments supplied by the driver that bound at the level above. If the driver is able to complete the binding of the port to any segment in context.segments_to_bind, it must call context.set_binding with the binding details. If it can partially bind the port, it must call context.continue_binding with the network segments to be used to bind at the next lower level.
If the binding results are committed after bind_port returns, they will be seen by all mechanism drivers as update_port_precommit and update_port_postcommit calls. But if some other thread or process concurrently binds or updates the port, these binding results will not be committed, and update_port_precommit and update_port_postcommit will not be called on the mechanism drivers with these results. Because binding results can be discarded rather than committed, drivers should avoid making persistent state changes in bind_port, or else must ensure that such state changes are eventually cleaned up.
Implementing this method explicitly declares the mechanism driver as having the intention to bind ports. This is inspected by the QoS service to identify the available QoS rules you can use with ports.
- property connectivity¶
Return the mechanism driver connectivity type
The possible values are “l2”, “l3” and “legacy” (default).
- Returns:
a string in (“l2”, “l3”, “legacy”)
- initialize()¶
Perform driver initialization.
Called after all drivers have been loaded and the database has been initialized. No abstract methods defined below will be called prior to this method being called.
- update_port_postcommit(context)¶
Update a port.
- Parameters:
context – PortContext instance describing the new state of the port, as well as the original state prior to the update_port call.
Called after the transaction completes. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will result in the deletion of the resource.
update_port_postcommit is called for all changes to the port state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
networking_baremetal.plugins.ml2.baremetal_mech module¶
- class networking_baremetal.plugins.ml2.baremetal_mech.BaremetalMechanismDriver¶
Bases:
SimpleAgentMechanismDriverBase- property connectivity¶
Return the mechanism driver connectivity type
The possible values are “l2”, “l3” and “legacy” (default).
- Returns:
a string in (“l2”, “l3”, “legacy”)
- create_network_postcommit(context)¶
Create a network.
Called after the transaction commits. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will cause the deletion of the resource.
- Parameters:
context – NetworkContext instance describing the new network.
- create_network_precommit(context)¶
Allocate resources for a new network.
Create a new network, allocating resources as necessary in the database. Called inside transaction context on session. Call cannot block. Raising an exception will result in a rollback of the current transaction.
- Parameters:
context – NetworkContext instance describing the new network.
- create_port_postcommit(context)¶
Create a port.
Called after the transaction completes. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will result in the deletion of the resource.
- Parameters:
context – PortContext instance describing the port.
- create_port_precommit(context)¶
Allocate resources for a new port.
Create a new port, allocating resources as necessary in the database. Called inside transaction context on session. Call cannot block. Raising an exception will result in a rollback of the current transaction.
- Parameters:
context – PortContext instance describing the port.
- create_subnet_postcommit(context)¶
Create a subnet.
Called after the transaction commits. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will cause the deletion of the resource.
- Parameters:
context – SubnetContext instance describing the new subnet.
- create_subnet_precommit(context)¶
Allocate resources for a new subnet.
Create a new subnet, allocating resources as necessary in the database. Called inside transaction context on session. Call cannot block. Raising an exception will result in a rollback of the current transaction.
- Parameters:
context – SubnetContext instance describing the new subnet.
- delete_network_postcommit(context)¶
Delete a network.
Called after the transaction commits. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Runtime errors are not expected, and will not prevent the resource from being deleted.
- Parameters:
context – NetworkContext instance describing the current state of the network, prior to the call to delete it.
- delete_network_precommit(context)¶
Delete resources for a network.
Delete network resources previously allocated by this mechanism driver for a network. Called inside transaction context on session. Runtime errors are not expected, but raising an exception will result in rollback of the transaction.
- Parameters:
context – NetworkContext instance describing the current state of the network, prior to the call to delete it.
- delete_port_postcommit(context)¶
Delete a port.
state of the port, prior to the call to delete it. Called after the transaction completes. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Runtime errors are not expected, and will not prevent the resource from being deleted.
- Parameters:
context – PortContext instance describing the current state of the port, prior to the call to delete it.
- delete_port_precommit(context)¶
Delete resources of a port.
Called inside transaction context on session. Runtime errors are not expected, but raising an exception will result in rollback of the transaction.
- Parameters:
context – PortContext instance describing the current state of the port, prior to the call to delete it.
- delete_subnet_postcommit(context)¶
Delete a subnet.a
Called after the transaction commits. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Runtime errors are not expected, and will not prevent the resource from being deleted.
- Parameters:
context – SubnetContext instance describing the current state of the subnet, prior to the call to delete it.
- delete_subnet_precommit(context)¶
Delete resources for a subnet.
Delete subnet resources previously allocated by this mechanism driver for a subnet. Called inside transaction context on session. Runtime errors are not expected, but raising an exception will result in rollback of the transaction.
- Parameters:
context – SubnetContext instance describing the current state of the subnet, prior to the call to delete it.
- get_allowed_network_types(agent)¶
Return the agent’s or driver’s allowed network types.
For example: return (‘flat’, …). You can also refer to the configuration the given agent exposes.
- get_mappings(agent)¶
Return the agent’s bridge or interface mappings.
For example: agent[‘configurations’].get(‘bridge_mappings’, {}).
- try_to_bind_segment_for_agent(context, segment, agent)¶
Try to bind with segment for agent.
- Parameters:
context – PortContext instance describing the port
segment – segment dictionary describing segment to bind
agent – agents_db entry describing agent to bind
- Returns:
True iff segment has been bound for agent
- Neutron segments api-ref:
- Example segment dictionary: {‘segmentation_id’: ‘segmentation_id’,
‘network_type’: ‘network_type’, ‘id’: ‘segment_uuid’}
Called outside any transaction during bind_port() so that derived MechanismDrivers can use agent_db data along with built-in knowledge of the corresponding agent’s capabilities to attempt to bind to the specified network segment for the agent.
If the segment can be bound for the agent, this function must call context.set_binding() with appropriate values and then return True. Otherwise, it must return False.
- update_network_postcommit(context)¶
Update a network.
Called after the transaction commits. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will cause the deletion of the resource. update_network_postcommit is called for all changes to the network state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
- Parameters:
context – NetworkContext instance describing the new state of the network, as well as the original state prior to the update_network call.
- update_network_precommit(context)¶
Update resources of a network.
Update values of a network, updating the associated resources in the database. Called inside transaction context on session. Raising an exception will result in rollback of the transaction. update_network_precommit is called for all changes to the network state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
- Parameters:
context – NetworkContext instance describing the new state of the network, as well as the original state prior to the update_network call.
- update_port_postcommit(context)¶
Update a port.
Called after the transaction completes. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will result in the deletion of the resource. update_port_postcommit is called for all changes to the port state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
- Parameters:
context – PortContext instance describing the new state of the port, as well as the original state prior to the update_port call.
- update_port_precommit(context)¶
Update resources of a port.
Called inside transaction context on session to complete a port update as defined by this mechanism driver. Raising an exception will result in rollback of the transaction. update_port_precommit is called for all changes to the port state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
- Parameters:
context – PortContext instance describing the new state of the port, as well as the original state prior to the update_port call.
- update_subnet_postcommit(context)¶
Update a subnet.
Called after the transaction commits. Call can block, though will block the entire process so care should be taken to not drastically affect performance. Raising an exception will cause the deletion of the resource. update_subnet_postcommit is called for all changes to the subnet state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
- Parameters:
context – SubnetContext instance describing the new state of the subnet, as well as the original state prior to the update_subnet call.
- update_subnet_precommit(context)¶
Update resources of a subnet.
Update values of a subnet, updating the associated resources in the database. Called inside transaction context on session. Raising an exception will result in rollback of the transaction. update_subnet_precommit is called for all changes to the subnet state. It is up to the mechanism driver to ignore state or state changes that it does not know or care about.
- Parameters:
context – SubnetContext instance describing the new state of the subnet, as well as the original state prior to the update_subnet call.