Changeset 9728 in genesis for tools


Ignore:
Timestamp:
Nov 21, 2011, 6:46:50 PM (13 years ago)
Author:
rick
Message:

Better logging and re-use of sockets to allow disconnect and re-connects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r9697 r9728  
    400400          ip_list.append(addr)
    401401        else:
    402           print "## IP '%s' in '%s' not valid" % (addr, config['nodename'])
     402          logger.error("## IP '%s' in '%s' not valid" % (addr, config['nodename']))
    403403    return sorted(ip_list)
    404404
     
    730730          return True
    731731      handler = MyCGIHTTPRequestHandler
     732      SocketServer.allow_reuse_address = True
    732733      httpd = SocketServer.TCPServer(("", PORT), handler)
    733734      httpd.server_name = 'localhost'
    734735      httpd.server_port = PORT
    735736
    736       print "serving at port", PORT
     737      logger.info("serving at port %s", PORT)
    737738      try:
    738739        httpd.serve_forever()
    739740      except KeyboardInterrupt:
    740741        httpd.shutdown()
     742        logger.info("All done goodbye")
    741743    elif sys.argv[1] == "test":
    742744      os.environ['PATH_INFO'] = "/".join(sys.argv[2:])
     
    753755        for config in files:
    754756          items['config'] = config
    755           print "## Generating %(node)s %(config)s" % items
     757          logger.info("## Generating %(node)s %(config)s" % items)
    756758          f = open("%(wdir)s/%(config)s" % items, "w")
    757759          f.write(generate_config(node, config, datadump))
     
    763765        sql = """INSERT IGNORE INTO nodes (name, name_ns, longitude, latitude)
    764766        VALUES ('%(nodename)s', '%(nodename)s', %(latitude)s, %(longitude)s);""" % datadump;
    765         print sql
    766767        sql = """INSERT IGNORE INTO users_nodes (user_id, node_id, owner)
    767768        VALUES (
     
    769770          (SELECT id FROM nodes WHERE name = '%(nodename)s'),
    770771          'Y');""" % datadump
    771         print sql
    772772        #for config in files:
    773773        #  items['config'] = config
     
    787787              VALUES ((SELECT id FROM nodes WHERE name = '%(nodename)s'), 'ap',
    788788              '%(ssid)s', 'IEEE 802.11b', %(channel)s, 'active');""" % ifacedump
    789             print sql
    790789    elif sys.argv[1] == "full-export":
    791790      hosts = {}
     
    801800      datadumps = dict()
    802801      for host in get_hostlist():
    803         print "# Processing: ", host
     802        logger.info("# Processing: %s", host)
    804803        datadump = get_yaml(host)
    805804        datadumps[get_fqdn(datadump)] = datadump
Note: See TracChangeset for help on using the changeset viewer.