6 api = plc.PLC(auth.auth, auth.plc)
8 from optparse import OptionParser
11 from nodecommon import *
15 from config import config
16 fb = soltesz.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(net[k]))
44 print "%15s == %s" % (k, net[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
59 print " ---- Nodes in the %s Node Group ----" % group_str
63 print nodegroup_display(node, fb)
66 elif config.add and config.nodegroup:
67 for node in hostnames:
68 print "Adding %s to %s nodegroup" % (node, config.nodegroup)
69 api.AddNodeToNodeGroup(node, config.nodegroup)
72 for node in hostnames:
73 print "Deleting %s from %s nodegroup" % (node, config.nodegroup)
74 api.DeleteNodeFromNodeGroup(node, config.nodegroup)
77 print "no other options supported."
79 if __name__ == "__main__":