6 api = plc.PLC(auth.auth, auth.plc)
8 from optparse import OptionParser
11 from nodecommon import *
15 from config import config
16 fb = database.dbLoad("findbad")
18 parser = OptionParser()
19 parser.set_defaults(nodelist=None,
25 parser.add_option("", "--nodelist", dest="nodelist", metavar="list.txt",
26 help="Use all nodes in the given file for operation.")
27 config = config(parser)
30 # COLLECT nodegroups, nodes and node lists
31 for node in config.args:
34 n = api.GetNodes(node)[0]
36 net = api.GetNodeNetworks(n['nodenetwork_ids'])[0]
39 node_keys = ['boot_state', 'key', 'last_updated', 'last_contact']
42 print "%15s == %s" % (k, diff_time(n[k]))
44 print "%15s == %s" % (k, n[k])
46 static_keys = ['method', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'mac', 'is_primary']
48 print "%15s == %s" % (k, net[k])
51 # print k, "==" , net[k]
53 print "Error with %s" % node
54 import traceback; print traceback.print_exc()
60 print " ---- Nodes in the %s Node Group ----" % group_str
64 print nodegroup_display(node, fb)
67 elif config.add and config.nodegroup:
68 for node in hostnames:
69 print "Adding %s to %s nodegroup" % (node, config.nodegroup)
70 api.AddNodeToNodeGroup(node, config.nodegroup)
73 for node in hostnames:
74 print "Deleting %s from %s nodegroup" % (node, config.nodegroup)
75 api.DeleteNodeFromNodeGroup(node, config.nodegroup)
78 print "no other options supported."
80 if __name__ == "__main__":