def run(self, node, platform, whitelist=[], blacklist=[]):
        results = {'added': [], 'existing': []}

        self.connect(platform)

        NodeId = self.get_node_id(node)

        Discoverdinterfaces = self.invoke('Orion.NPM.Interfaces',
                                          'DiscoverInterfacesOnNode',
                                          NodeId)

        add_interfaces = []
        for interface in Discoverdinterfaces['DiscoveredInterfaces']:
            # Unmonitored interfaces have an InterfaceID of 0.
            if not interface['InterfaceID'] == 0:
                self.logger.info("Skipping {} as monitored (I:{})".format(
                    interface['Caption'],
                    interface['InterfaceID']))
                results['existing'].append(
                    {interface['Caption']: interface['InterfaceID']})
                continue

            if interface['Caption'] in blacklist:
                self.logger.info("Skipping {} as in blacklist".format(
                    interface['Caption']))
                continue
            elif interface['Caption'] in whitelist:
                self.logger.info("Adding {} as in whitelist".format(
                    interface['Caption']))
                add_interfaces.append(interface)
            elif not whitelist:
                add_interfaces.append(interface)
            else:
                continue

        additions = self.invoke('Orion.NPM.Interfaces',
                                'AddInterfacesOnNode',
                                NodeId,
                                add_interfaces,
                                'AddDefaultPollers')

        for i in additions['DiscoveredInterfaces']:
            results['added'].append({i['Caption']: i['InterfaceID']})

        return results
Discover and add interfaces on an Orion node
dataset/ETHPy150Open StackStorm/st2contrib/packs/orion/actions/node_discover_and_add_interfaces.py/NodeDiscoverAndAddInterfaces.run