ironic_inspector/plugins/standard.py
def before_update(self, introspection_data, node_info, **kwargs):
        """Create new ports and drop ports that are not present in the data."""
        interfaces = introspection_data.get('interfaces')
        if CONF.processing.add_ports != 'disabled':
            node_info.create_ports(list(interfaces.values()))

        if CONF.processing.keep_ports == 'present':
            expected_macs = {
                iface['mac']
                for iface in introspection_data['all_interfaces'].values()
            }
        elif CONF.processing.keep_ports == 'added':
            expected_macs = set(introspection_data['macs'])

        node_provision_state = node_info.node().provision_state
        if node_provision_state in ir_utils.VALID_ACTIVE_STATES:
            LOG.debug('Node %(node)s is %(state)s; '
                      'not modifying / deleting its ports',
                      {'node': node_info.uuid,
                       'state': node_provision_state})
            return

        if CONF.processing.keep_ports != 'all':
            # list is required as we modify underlying dict
            for port in list(node_info.ports().values()):
                if port.address not in expected_macs:
                    LOG.info("Deleting port %(port)s as its MAC %(mac)s is "
                             "not in expected MAC list %(expected)s",
                             {'port': port.id,
                              'mac': port.address,
                              'expected': list(sorted(expected_macs))},
                             node_info=node_info, data=introspection_data)
                    node_info.delete_port(port)

        if (CONF.processing.overwrite_existing
                and CONF.processing.update_pxe_enabled):
            # Make sure is_pxe_enabled is up-to-date
            ports = node_info.ports()
            for iface in introspection_data['interfaces'].values():
                try:
                    port = ports[iface['mac']]
                except KeyError:
                    continue

                real_pxe = iface.get('pxe', True)
                if port.is_pxe_enabled != real_pxe:
                    LOG.info('Fixing is_pxe_enabled=%(val)s on port %(port)s '
                             'to match introspected data',
                             {'port': port.address, 'val': real_pxe},
                             node_info=node_info, data=introspection_data)
                    node_info.patch_port(port, [{'op': 'replace',
                                                 'path': '/pxe_enabled',
                                                 'value': real_pxe}])
Create new ports and drop ports that are not present in the data.
Create new ports and drop ports that are not present in the data.
Create new ports and drop ports that are not present in the data .
def before_update(self, introspection_data, node_info, **kwargs):
        interfaces = introspection_data.get('interfaces')
        if CONF.processing.add_ports != 'disabled':
            node_info.create_ports(list(interfaces.values()))
        if CONF.processing.keep_ports == 'present':
            expected_macs = {
                iface['mac']
                for iface in introspection_data['all_interfaces'].values()
            }
        elif CONF.processing.keep_ports == 'added':
            expected_macs = set(introspection_data['macs'])
        node_provision_state = node_info.node().provision_state
        if node_provision_state in ir_utils.VALID_ACTIVE_STATES:
            LOG.debug('Node %(node)s is %(state)s; '
                      'not modifying / deleting its ports',
                      {'node': node_info.uuid,
                       'state': node_provision_state})
            return
        if CONF.processing.keep_ports != 'all':
            for port in list(node_info.ports().values()):
                if port.address not in expected_macs:
                    LOG.info("Deleting port %(port)s as its MAC %(mac)s is "
                             "not in expected MAC list %(expected)s",
                             {'port': port.id,
                              'mac': port.address,
                              'expected': list(sorted(expected_macs))},
                             node_info=node_info, data=introspection_data)
                    node_info.delete_port(port)
        if (CONF.processing.overwrite_existing
                and CONF.processing.update_pxe_enabled):
            ports = node_info.ports()
            for iface in introspection_data['interfaces'].values():
                try:
                    port = ports[iface['mac']]
                except KeyError:
                    continue
                real_pxe = iface.get('pxe', True)
                if port.is_pxe_enabled != real_pxe:
                    LOG.info('Fixing is_pxe_enabled=%(val)s on port %(port)s '
                             'to match introspected data',
                             {'port': port.address, 'val': real_pxe},
                             node_info=node_info, data=introspection_data)
                    node_info.patch_port(port, [{'op': 'replace',
                                                 'path': '/pxe_enabled',
                                                 'value': real_pxe}])
def before_update ( self , introspection_data , node_info , ** kwargs ) : interfaces = introspection_data . get ( 'interfaces' ) if CONF . processing . add_ports != 'disabled' : node_info . create_ports ( list ( interfaces . values ( ) ) ) if CONF . processing . keep_ports == 'present' : expected_macs = { iface [ 'mac' ] for iface in introspection_data [ 'all_interfaces' ] . values ( ) } elif CONF . processing . keep_ports == 'added' : expected_macs = set ( introspection_data [ 'macs' ] ) node_provision_state = node_info . node ( ) . provision_state if node_provision_state in ir_utils . VALID_ACTIVE_STATES : LOG . debug ( 'Node %(node)s is %(state)s; ' 'not modifying / deleting its ports' , { 'node' : node_info . uuid , 'state' : node_provision_state } ) return if CONF . processing . keep_ports != 'all' : for port in list ( node_info . ports ( ) . values ( ) ) : if port . address not in expected_macs : LOG . info ( "Deleting port %(port)s as its MAC %(mac)s is " "not in expected MAC list %(expected)s" , { 'port' : port . id , 'mac' : port . address , 'expected' : list ( sorted ( expected_macs ) ) } , node_info = node_info , data = introspection_data ) node_info . delete_port ( port ) if ( CONF . processing . overwrite_existing and CONF . processing . update_pxe_enabled ) : ports = node_info . ports ( ) for iface in introspection_data [ 'interfaces' ] . values ( ) : try : port = ports [ iface [ 'mac' ] ] except KeyError : continue real_pxe = iface . get ( 'pxe' , True ) if port . is_pxe_enabled != real_pxe : LOG . info ( 'Fixing is_pxe_enabled=%(val)s on port %(port)s ' 'to match introspected data' , { 'port' : port . address , 'val' : real_pxe } , node_info = node_info , data = introspection_data ) node_info . patch_port ( port , [ { 'op' : 'replace' , 'path' : '/pxe_enabled' , 'value' : real_pxe } ] )
Create new ports and drop ports that are not present in the data.
Create new ports and drop ports that are not present in the data .
"""Create new ports and drop ports that are not present in the data.""" # list is required as we modify underlying dict # Make sure is_pxe_enabled is up-to-date
self
introspection_data
node_info