ironic_inspector/plugins/local_link_connection.py
def before_update(self, introspection_data, node_info, **kwargs):
        """Process LLDP data and patch Ironic port local link connection"""
        inventory = utils.get_inventory(introspection_data)

        ironic_ports = node_info.ports()

        for iface in inventory['interfaces']:
            if iface['name'] not in introspection_data['all_interfaces']:
                continue

            mac_address = iface['mac_address']
            port = ironic_ports.get(mac_address)
            if not port:
                LOG.debug("Skipping LLC processing for interface %s, matching "
                          "port not found in Ironic.", mac_address,
                          node_info=node_info, data=introspection_data)
                continue

            lldp_data = iface.get('lldp')
            if lldp_data is None:
                LOG.warning("No LLDP Data found for interface %s",
                            mac_address, node_info=node_info,
                            data=introspection_data)
                continue

            patches = []
            # First check if lldp data was already processed by lldp_basic
            # plugin which stores data in 'all_interfaces'
            proc_data = introspection_data['all_interfaces'][iface['name']]

            for name, item in LLDP_PROC_DATA_MAPPING.items():
                patch = self._get_lldp_processed_patch(name, item,
                                                       proc_data, port,
                                                       node_info)
                if patch is not None:
                    patches.append(patch)

            # If no processed lldp data was available then parse raw lldp data
            if not patches:
                for tlv_type, tlv_value in lldp_data:
                    patch = self._get_local_link_patch(tlv_type, tlv_value,
                                                       port, node_info)
                    if patch is not None:
                        patches.append(patch)

            try:
                node_info.patch_port(port, patches)
            except exceptions.BadRequestException as e:
                LOG.warning("Failed to update port %(uuid)s: %(error)s",
                            {'uuid': port.id, 'error': e},
                            node_info=node_info)
Process LLDP data and patch Ironic port local link connection
Process LLDP data and patch Ironic port local link connection
Process LLDP data and patch Ironic port local link connection
def before_update(self, introspection_data, node_info, **kwargs):
        inventory = utils.get_inventory(introspection_data)
        ironic_ports = node_info.ports()
        for iface in inventory['interfaces']:
            if iface['name'] not in introspection_data['all_interfaces']:
                continue
            mac_address = iface['mac_address']
            port = ironic_ports.get(mac_address)
            if not port:
                LOG.debug("Skipping LLC processing for interface %s, matching "
                          "port not found in Ironic.", mac_address,
                          node_info=node_info, data=introspection_data)
                continue
            lldp_data = iface.get('lldp')
            if lldp_data is None:
                LOG.warning("No LLDP Data found for interface %s",
                            mac_address, node_info=node_info,
                            data=introspection_data)
                continue
            patches = []
            proc_data = introspection_data['all_interfaces'][iface['name']]
            for name, item in LLDP_PROC_DATA_MAPPING.items():
                patch = self._get_lldp_processed_patch(name, item,
                                                       proc_data, port,
                                                       node_info)
                if patch is not None:
                    patches.append(patch)
            if not patches:
                for tlv_type, tlv_value in lldp_data:
                    patch = self._get_local_link_patch(tlv_type, tlv_value,
                                                       port, node_info)
                    if patch is not None:
                        patches.append(patch)
            try:
                node_info.patch_port(port, patches)
            except exceptions.BadRequestException as e:
                LOG.warning("Failed to update port %(uuid)s: %(error)s",
                            {'uuid': port.id, 'error': e},
                            node_info=node_info)
def before_update ( self , introspection_data , node_info , ** kwargs ) : inventory = utils . get_inventory ( introspection_data ) ironic_ports = node_info . ports ( ) for iface in inventory [ 'interfaces' ] : if iface [ 'name' ] not in introspection_data [ 'all_interfaces' ] : continue mac_address = iface [ 'mac_address' ] port = ironic_ports . get ( mac_address ) if not port : LOG . debug ( "Skipping LLC processing for interface %s, matching " "port not found in Ironic." , mac_address , node_info = node_info , data = introspection_data ) continue lldp_data = iface . get ( 'lldp' ) if lldp_data is None : LOG . warning ( "No LLDP Data found for interface %s" , mac_address , node_info = node_info , data = introspection_data ) continue patches = [ ] proc_data = introspection_data [ 'all_interfaces' ] [ iface [ 'name' ] ] for name , item in LLDP_PROC_DATA_MAPPING . items ( ) : patch = self . _get_lldp_processed_patch ( name , item , proc_data , port , node_info ) if patch is not None : patches . append ( patch ) if not patches : for tlv_type , tlv_value in lldp_data : patch = self . _get_local_link_patch ( tlv_type , tlv_value , port , node_info ) if patch is not None : patches . append ( patch ) try : node_info . patch_port ( port , patches ) except exceptions . BadRequestException as e : LOG . warning ( "Failed to update port %(uuid)s: %(error)s" , { 'uuid' : port . id , 'error' : e } , node_info = node_info )
Process LLDP data and patch Ironic port local link connection
Process LLDP data and patch Ironic port local link connection
"""Process LLDP data and patch Ironic port local link connection""" # First check if lldp data was already processed by lldp_basic # plugin which stores data in 'all_interfaces' # If no processed lldp data was available then parse raw lldp data
self
introspection_data
node_info