cern_netset_extraction

Author: Athanasios Gkaraliakos email: a.gkaraliakos@gmail.com

The script is written on python >=2.6

Script to get IPv4 and/or IPv6 (if exists) for every machine in the given set

Depends on python-dns ” yum install python-dns “

This script was querying the CERNs network service to obtain the hostnames of machine in specified groupings and then

it was resolving the ipv4 and ipv6 addresses for all the hostnames. Then this list of lists is used from the ipset_manger.py script to create an ipset from all this ips.

Format: [[‘DB-51088.CERN.CH’, ‘137.138.161.23’, ‘2001:1458:201:ae::100:9’],
[‘DB-51089.CERN.CH’, ‘137.138.161.68’, ‘2001:1458:201:ae::100:36’]]
bin.netgroups_set_extraction.main()[source]

This is the main function. It parses the command line arguments and calls the appropriate function to handle each the job.

Returns:Does not return anything
bin.netgroups_set_extraction.netgroup_set_extractor(iptype, networksets, cmdcall=False, only_hostnames=False)[source]

This function is proxy between main and the rest of the script so it can be run both as script and as a module

Parameters:
  • iptype – Type of ip version IPv4 or IPv6 or both
  • networksets – Names of networks search to query for the LanDB service
  • cmdcall – Determines if the script is called from cmd
Returns:

Returns a list with host names and ip addresses or print to the screen if it called from the cmd