ironic_inspector.common.lldp_parsers module

Names and mapping functions used to map LLDP TLVs to name/value pairs

class ironic_inspector.common.lldp_parsers.LLDPBasicMgmtParser(nv=None)[source]

Bases: LLDPParser

Class to handle parsing of 802.1AB Basic Management set

This class will also handle 802.1Q and 802.3 OUI TLVs.

add_capabilities(struct, name, data)[source]

Handle LLDP_TLV_SYS_CAPABILITIES

add_mgmt_address(struct, name, data)[source]

Handle LLDP_TLV_MGMT_ADDRESS

There can be multiple Mgmt Address TLVs, store in list.

handle_org_specific_tlv(struct, name, data)[source]

Handle Organizationally Unique ID TLVs

This class supports 802.1Q and 802.3 OUI TLVs.

See http://www.ieee802.org/1/pages/802.1Q-2014.html, Annex D and http://standards.ieee.org/about/get/802/802.3.html

class ironic_inspector.common.lldp_parsers.LLDPParser(node_info, nv=None)[source]

Bases: object

Base class to handle parsing of LLDP TLVs

Each class that inherits from this base class must provide a parser map. Parser maps are used to associate a LLDP TLV with a function handler and arguments necessary to parse the TLV and generate one or more name/value pairs. Each LLDP TLV maps to a tuple with the following fields:

function - handler function to generate name/value pairs

construct - name of construct definition for TLV

name - user-friendly name of TLV. For TLVs that generate only one name/value pair this is the name used

len_check - boolean indicating if length check should be done on construct

It’s valid to have a function handler of None, this is for TLVs that are not mapped to a name/value pair(e.g.LLDP_TLV_TTL).

Add name/value pairs for TLV Dot1_LinkAggregationId

This is in base class since it can be used by both dot1 and dot3.

add_nested_value(struct, name, data)[source]

Add a single nested name/value pair to the dict

add_single_value(struct, name, data)[source]

Add a single name/value pair to the nv dict

append_value(name, value)[source]

Add value to a list mapped to name

parse_tlv(tlv_type, data)[source]

Parse TLVs from mapping table

This functions takes the TLV type and the raw data for this TLV and gets a tuple from the parser_map. The construct field in the tuple contains the construct lib definition of the TLV which can be parsed to access individual fields. Once the TLV is parsed, the handler function for each TLV will store the individual fields as name/value pairs in nv_dict.

If the handler function does not exist, then no name/value pairs will be added to nv_dict, but since the TLV was handled, True will be returned.

Param:

tlv_type - type identifier for TLV

Param:

data - raw TLV value

Returns:

True if TLV in parser_map and data is valid, otherwise False.

set_value(name, value)[source]

Set name value pair in dictionary

The value for a name should not be changed if it exists.

class ironic_inspector.common.lldp_parsers.LLDPdot1Parser(node_info, nv=None)[source]

Bases: LLDPParser

Class to handle parsing of 802.1Q TLVs

add_dot1_port_protocol_vlan(struct, name, data)[source]

Handle dot1_PORT_PROTOCOL_VLANID

add_dot1_protocol_identities(struct, name, data)[source]

Handle dot1_PROTOCOL_IDENTITY

There can be multiple protocol ids TLVs, store in list

add_dot1_vlans(struct, name, data)[source]

Handle dot1_VLAN_NAME

There can be multiple vlan TLVs, add dictionary entry with id/vlan to list.

class ironic_inspector.common.lldp_parsers.LLDPdot3Parser(node_info, nv=None)[source]

Bases: LLDPParser

Class to handle parsing of 802.3 TLVs

add_dot3_macphy_config(struct, name, data)[source]

Handle dot3_MACPHY_CONFIG_STATUS