Пример #1
0
def main():
    parser = parse_options()
    (options, args) = parser.parse_args()
    args = json.dumps(args)

    if options.verbose:
        import xtrace
        xtrace.start()

    conn = establish_connection()
    cur = conn.cursor()

    clean_args(options, args, parser)
    existing_values = check_for_already_existing_values(options, cur)
    insert_host(options, cur, existing_values)
    conn.commit()
    cur.close()
Пример #2
0
debug = 0
hostprint = 0

for x in args:
    if '-d' in x:
        debug = 1
    if '-p' in x:
        hostprint = 1
args = [x for x in args if not '-d' in x and not '-p' in x]

hostdict = {}
global working_subnet
working_subnet = []
hosts = []
if debug:
    xtrace.start()


def prepare_host_lists(subnetstring, hostdict, hosts):
    serverURL = 'https://ipplan.internal.com/api/server.php'
    client = xmlrpclib.Server(serverURL)
    for subnet in client.ipplan.FetchBase(1, 0, 0, "", 0, ""):
        if subnet['baseaddr'] == subnetstring:
            baseindex = subnet['baseindex']
            working_subnet = client.ipplan.FetchSubnet(baseindex)
            for ip in working_subnet:
                if 'internal' in ip['hname']:
                    hname = ip['hname']
                    ipaddr = ip['ipaddr']
                    hostdict[hname] = {}
                    hostdict[hname]['ipaddr'] = ipaddr
debug=0
hostprint = 0

for x in args:
    if '-d' in x:
        debug = 1
    if '-p' in x:
        hostprint = 1
args = [ x for x in args if not '-d' in x and not '-p' in x ]

hostdict = {}
global working_subnet
working_subnet = []
hosts = []
if debug:
    xtrace.start()

def prepare_host_lists(subnetstring,hostdict,hosts):
    serverURL='https://ipplan.internal.com/api/server.php'
    client = xmlrpclib.Server(serverURL)
    for subnet in client.ipplan.FetchBase(1,0,0,"",0,""):
        if subnet['baseaddr'] == subnetstring:
            baseindex = subnet['baseindex']
            working_subnet = client.ipplan.FetchSubnet(baseindex)
            for ip in working_subnet:
                if 'internal' in ip['hname']:
                    hname = ip['hname']
                    ipaddr = ip['ipaddr']
                    hostdict[hname] = {}
                    hostdict[hname]['ipaddr'] = ipaddr
                    hosts += [hname]