7 import parser as parsermodule
10 from nodecommon import *
13 def network_config_to_str(net):
16 static_keys = ['method', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'mac', 'is_primary']
18 str += "%15s == %s\n" % (k, net[k])
24 fb = database.dbLoad("findbad")
26 parser = parsermodule.getParser()
27 parser.set_defaults(nodelist=None,
33 parser.add_option("", "--nodelist", dest="nodelist", metavar="list.txt",
34 help="Use all nodes in the given file for operation.")
35 parser = parsermodule.getParser(['defaults'], parser)
36 config = parsermodule.parse_args(parser)
38 # COLLECT nodegroups, nodes and node lists
39 for node in config.args:
42 n = api.GetNodes(node)[0]
44 net = api.GetNodeNetworks(n['nodenetwork_ids'])[0]
47 node_keys = ['boot_state', 'key', 'last_updated', 'last_contact']
50 print "%15s == %s" % (k, diff_time(n[k]))
52 print "%15s == %s" % (k, n[k])
54 print network_config_to_str(net)
57 # print k, "==" , net[k]
59 print "Error with %s" % node
60 import traceback; print traceback.print_exc()
66 print " ---- Nodes in the %s Node Group ----" % group_str
70 print nodegroup_display(node, fb)
73 elif config.add and config.nodegroup:
74 for node in hostnames:
75 print "Adding %s to %s nodegroup" % (node, config.nodegroup)
76 api.AddNodeToNodeGroup(node, config.nodegroup)
79 for node in hostnames:
80 print "Deleting %s from %s nodegroup" % (node, config.nodegroup)
81 api.DeleteNodeFromNodeGroup(node, config.nodegroup)
84 print "no other options supported."
86 if __name__ == "__main__":