ironic.drivers.modules.network.common module

class ironic.drivers.modules.network.common.NeutronVIFPortIDMixin[source]

Bases: VIFPortIDMixin

VIF port ID mixin class for neutron network interfaces.

Mixin class that provides VIF-related network interface methods for neutron network interfaces. On VIF attach/detach, the associated neutron port will be updated.

get_node_network_data(task)[source]

Get network configuration data for node ports.

Pull network data from ironic node object if present, otherwise collect it for Neutron VIFs.

Parameters:

task – A TaskManager instance.

Raises:

InvalidParameterValue, if the network interface configuration is invalid.

Raises:

MissingParameterValue, if some parameters are missing.

Returns:

a dict holding network configuration information adhering Nova network metadata layout (network_data.json).

port_changed(task, port_obj)[source]

Handle any actions required when a port changes

Parameters:
  • task – a TaskManager instance.

  • port_obj – a changed Port object from the API before it is saved to database.

Raises:

FailedToUpdateDHCPOptOnPort, Conflict

portgroup_changed(task, portgroup_obj)[source]

Handle any actions required when a portgroup changes

Parameters:
  • task – a TaskManager instance.

  • portgroup_obj – a changed Portgroup object from the API before it is saved to database.

Raises:

FailedToUpdateDHCPOptOnPort, Conflict

vif_attach(task, vif_info)[source]

Attach a virtual network interface to a node

Attach a virtual interface to a node. When selecting a port or portgroup to attach the virtual interface to, the following ordered criteria are applied:

  • Require ports or portgroups to have a physical network that is either None or one of the VIF’s allowed physical networks.

  • Prefer ports or portgroups with a physical network field which is not None.

  • Prefer portgroups to ports.

  • Prefer ports with PXE enabled.

Parameters:
  • task – A TaskManager instance.

  • vif_info – a dictionary of information about a VIF. It must have an ‘id’ key, whose value is a unique identifier for that VIF.

Raises:

NetworkError, VifAlreadyAttached, NoFreePhysicalPorts

Raises:

PortgroupPhysnetInconsistent if one of the node’s portgroups has ports which are not all assigned the same physical network.

vif_detach(task, vif_id)[source]

Detach a virtual network interface from a node

Parameters:
  • task – A TaskManager instance.

  • vif_id – A VIF ID to detach

Raises:

VifNotAttached if VIF not attached.

Raises:

NetworkError if unbind Neutron port failed.

class ironic.drivers.modules.network.common.VIFPortIDMixin[source]

Bases: object

VIF port ID mixin class for non-neutron network interfaces.

Mixin class that provides VIF-related network interface methods for non-neutron network interfaces. There are no effects due to VIF attach/detach that are external to ironic.

NOTE: This does not yet support the full set of VIF methods, as it does not provide vif_attach, vif_detach, port_changed, or portgroup_changed.

get_current_vif(task, p_obj)[source]

Returns the currently used VIF associated with port or portgroup

We are booting the node only in one network at a time, and presence of cleaning_vif_port_id means we’re doing cleaning, of provisioning_vif_port_id - provisioning, of rescuing_vif_port_id - rescuing. Otherwise it’s a tenant network

Parameters:
  • task – A TaskManager instance.

  • p_obj – Ironic port or portgroup object.

Returns:

VIF ID associated with p_obj or None.

vif_list(task)[source]

List attached VIF IDs for a node

Parameters:

task – A TaskManager instance.

Returns:

List of VIF dictionaries, each dictionary will have an ‘id’ entry with the ID of the VIF.

ironic.drivers.modules.network.common.get_free_port_like_object(task, vif_id, physnets, vif_info={})[source]

Find free port-like object (portgroup or port) VIF will be attached to.

Ensures that the VIF is not already attached to this node. When selecting a port or portgroup to attach the virtual interface to, the following ordered criteria are applied:

  • Require ports or portgroups to have a physical network that is either None or one of the VIF’s allowed physical networks.

  • Prefer ports or portgroups with a physical network field which is not None.

  • Prefer portgroups to ports.

  • Prefer ports with PXE enabled.

Parameters:
  • task – a TaskManager instance.

  • vif_id – Name or UUID of a VIF.

  • physnets – Set of physical networks on which the VIF may be attached. This is governed by the segments of the VIF’s network. An empty set indicates that the ports’ physical networks should be ignored.

  • vif_info – dict that may contain extra information, such as port_uuid

Raises:

VifAlreadyAttached, if VIF is already attached to the node.

Raises:

NoFreePhysicalPorts, if there is no port-like object VIF can be attached to.

Raises:

PortgroupPhysnetInconsistent if one of the node’s portgroups has ports which are not all assigned the same physical network.

Returns:

port-like object VIF will be attached to.

ironic.drivers.modules.network.common.plug_port_to_tenant_network(task, port_like_obj, client=None)[source]

Plug port like object to tenant network.

Parameters:
  • task – A TaskManager instance.

  • port_like_obj – port-like object to plug.

  • client – Neutron client instance.

Raises:

NetworkError if failed to update Neutron port.

Raises:

VifNotAttached if tenant VIF is not associated with port_like_obj.