ironic.common.neutron module¶
- ironic.common.neutron.PHYSNET_PARAM_NAME = 'provider:physical_network'¶
- Name of the neutron network API physical network parameter. 
- ironic.common.neutron.add_ports_to_network(task, network_uuid, security_groups=None)[source]¶
- Create neutron ports to boot the ramdisk. - Create neutron ports for each pxe_enabled port on task.node to boot the ramdisk. - If the config option ‘neutron.add_all_ports’ is set, neutron ports for non-pxe-enabled ports are also created – these neutron ports will not have any assigned IP addresses. - Parameters:
- task – a TaskManager instance. 
- network_uuid – UUID of a neutron network where ports will be created. 
- security_groups – List of Security Groups UUIDs to be used for network. 
 
- Raises:
- NetworkError 
- Returns:
- a dictionary in the form {port.uuid: neutron_port[‘id’]} 
 
- ironic.common.neutron.get_client(token=None, context=None, auth_from_config=False)[source]¶
- Retrieve a neutron client connection. - Parameters:
- context – request context, instance of ironic.common.context.RequestContext 
- auth_from_config – (boolean) When True, use auth values from conf parameters 
 
- Returns:
- A neutron client. 
 
- ironic.common.neutron.get_local_group_information(task, portgroup)[source]¶
- Extract the portgroup information. - The information is returned in the form of: - { 'id': portgroup.uuid, 'name': portgroup.name, 'bond_mode': portgroup.mode, 'bond_properties': { 'bond_propertyA': 'valueA', 'bond_propertyB': 'valueB', } } - Parameters:
- task – a task containing the Node object. 
- portgroup – Ironic portgroup object to extract data for. 
 
- Returns:
- port group information as a dict 
 
- ironic.common.neutron.get_neutron_port_data(port_id, vif_id, client=None, context=None, mac_address=None, iface_type='vif', bond_links=None)[source]¶
- Gather Neutron port and network configuration - Query Neutron for port and network configuration, return whatever is available. Apply a mac_address override, which may be useful for the caller if this is being executed prior to port attachments. - Parameters:
- port_id – ironic port/portgroup ID. 
- vif_id – Neutron port ID. 
- client – Optional a Neutron client object. 
- context (ironic.common.context.RequestContext) – request context 
- mac_address – An override ethernet mac address. 
- iface_type – Default interface type to denote a link to be. Likely ignored by cloud-init, but still best to be populated. Other applicable option is ‘phy’, or ‘bond’. 
- bond_links – A list of dictionaries of additional links which indicate the port is a bind. This value being set overrides the iface_type value to ‘bond’ 
 
- Raises:
- NetworkError 
- Returns:
- a dict holding network configuration information associated with this ironic or Neutron port. 
 
- ironic.common.neutron.get_node_portmap(task)[source]¶
- Extract the switch port information for the node. - The information is returned in the form of: - { port.uuid: { 'switch_id': 'abc', 'port_id': 'Po0/1', 'other_llc_key': 'val' } } - Parameters:
- task – a task containing the Node object. 
- Returns:
- port information as a dict 
 
- ironic.common.neutron.get_physnets_by_port_uuid(client, port_uuid)[source]¶
- Return the set of physical networks associated with a neutron port. - Query the network to which the port is attached and return the set of physical networks associated with the segments in that network. If a port is assigned to a subnet with a direct segment mapping, return the physnet associated with its segment instead. - Parameters:
- client – A Neutron client object. 
- port_uuid – UUID of a Neutron port to query. 
 
- Returns:
- A set of physical networks. 
- Raises:
- NetworkError if the network query fails. 
- Raises:
- InvalidParameterValue for missing network. 
 
- ironic.common.neutron.is_ovn_vtep_port(port_info)[source]¶
- Check if the current port is an OVN VTEP port - Parameters:
- port_info – an instance of ironic.objects.port.Port or port data as a port like object 
- Returns:
- Boolean indicating if the port is an OVN VTEP port 
 
- ironic.common.neutron.is_smartnic_port(port_data)[source]¶
- Check that the port is Smart NIC port - Parameters:
- port_data – an instance of ironic.objects.port.Port or port data as dict. 
- Returns:
- A boolean to indicate port as Smart NIC port. 
 
- ironic.common.neutron.remove_neutron_ports(task, params)[source]¶
- Deletes the neutron ports matched by params. - Parameters:
- task – a TaskManager instance. 
- params – Dict of params to filter ports. 
 
- Raises:
- NetworkError 
 
- ironic.common.neutron.remove_ports_from_network(task, network_uuid)[source]¶
- Deletes the neutron ports created for booting the ramdisk. - Parameters:
- task – a TaskManager instance. 
- network_uuid – UUID of a neutron network ports will be deleted from. 
 
- Raises:
- NetworkError 
 
- ironic.common.neutron.rollback_ports(task, network_uuid)[source]¶
- Attempts to delete any ports created by cleaning/provisioning - Purposefully will not raise any exceptions so error handling can continue. - Parameters:
- task – a TaskManager instance. 
- network_uuid – UUID of a neutron network. 
 
 
- ironic.common.neutron.unbind_neutron_port(port_id, client=None, context=None, reset_mac=True)[source]¶
- Unbind a neutron port - Remove a neutron port’s binding profile and host ID so that it returns to an unbound state. - Parameters:
- port_id – Neutron port ID. 
- client – Optional a Neutron client object. 
- context (ironic.common.context.RequestContext) – request context 
- reset_mac – reset mac address 
 
- Raises:
- NetworkError 
 
- ironic.common.neutron.unbind_neutron_port_if_bound(port_id, client=None, context=None)[source]¶
- Check and if bound, unbind a neutron port. - A wrapper around unbind_neutron_port which checks if the port is already bound, and if so then triggers the port to be unbound. This is critical early on if a user has pre-bound the port. - If the port is missing from Neutron, then a NetworkError exception will also be raised because in this code path, we explicitly expect the port to already exist and be accessible. - Parameters:
- port_id – Neutron Port ID 
- client – Optional Neutron client. 
- context (ironic.common.context.RequestContext) – request context 
 
- Raises:
- NetworkError 
 
- ironic.common.neutron.update_neutron_port(context, port_id, attrs, client=None)[source]¶
- Undate a neutron port - Uses neutron client from conf client to update a neutron client an unbound state. - Parameters:
- context – request context, instance of ironic.common.context.RequestContext 
- port_id – Neutron port ID. 
- attrs – The attributes to update on the port 
- client – Optional Neutron client 
 
 
- ironic.common.neutron.update_port_address(port_id, address, context=None, client=None)[source]¶
- Update a port’s mac address. - Parameters:
- port_id – Neutron port id. 
- address – new MAC address. 
- context (ironic.common.context.RequestContext) – request context 
- client – A neutron client object. 
 
- Raises:
- FailedToUpdateMacOnPort 
 
- ironic.common.neutron.validate_network(uuid_or_name, net_type='network', context=None)[source]¶
- Check that the given network is present. - Parameters:
- uuid_or_name – network UUID or name 
- net_type – human-readable network type for error messages 
- context (ironic.common.context.RequestContext) – request context 
 
- Returns:
- network UUID 
- Raises:
- MissingParameterValue if uuid_or_name is empty 
- Raises:
- NetworkError on failure to contact Neutron 
- Raises:
- InvalidParameterValue for missing or duplicated network 
 
- ironic.common.neutron.validate_port_info(node, port)[source]¶
- Check that port contains enough information for deploy. - Neutron network interface requires that local_link_information field is filled before we can use this port. - Parameters:
- node – Ironic node object. 
- port – Ironic port object. 
 
- Returns:
- True if port info is valid, False otherwise. 
 
- ironic.common.neutron.wait_for_host_agent(client, host_id, target_state='up')[source]¶
- Wait for neutron agent to become target state - Parameters:
- client – A Neutron client object. 
- host_id – Agent host_id 
- target_state – up: wait for up status, down: wait for down status 
 
- Returns:
- boolean indicates the agent state matches param value target_state_up. 
- Raises:
- exception.Invalid if ‘target_state’ is not valid. 
- Raises:
- exception.NetworkError if host status didn’t match the required status after max retry attempts. 
 
- ironic.common.neutron.wait_for_port_status(client, port_id, status, fail_on_binding_failure=None)[source]¶
- Wait for port status to be the desired status - Parameters:
- client – A Neutron client object. 
- port_id – Neutron port_id 
- status – Port’s target status, can be ACTIVE, DOWN … etc. 
- fail_on_binding_failure – Whether to raise exception if port binding fails. 
 
- Returns:
- boolean indicates that the port status matches the required value passed by param status. 
- Raises:
- InvalidParameterValue if the port does not exist. 
- Raises:
- exception.NetworkError if port status didn’t match the required status after max retry attempts. 
 
