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.
SEGMENTS_PARAM_NAME
= 'segments'¶ Name of the neutron network API segments 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_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_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.
- 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_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.
update_neutron_port
(context, port_id, update_body, 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.
update_body – Body of update
client – Optional Neutron client
-
ironic.common.neutron.
update_port_address
(port_id, address, context=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
- 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)[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.
- 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.