X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nodeconfig.py;h=ac84ec338f68cf021d0949bdcd10ab2f61fc1330;hb=refs%2Fheads%2F1.0;hp=61d31f930a3a95ae0550cd34c227bac5f7c4261d;hpb=6496f5b4a0220e4055fee76c97f92293f9559117;p=monitor.git diff --git a/nodeconfig.py b/nodeconfig.py index 61d31f9..ac84ec3 100755 --- a/nodeconfig.py +++ b/nodeconfig.py @@ -2,20 +2,28 @@ import plc -import auth -api = plc.PLC(auth.auth, auth.plc) +api = plc.getAuthAPI() -from optparse import OptionParser +import parser as parsermodule from sets import Set from nodecommon import * import database +def network_config_to_str(net): + + str = "" + static_keys = ['method', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'mac', 'is_primary'] + for k in static_keys: + str += "%15s == %s\n" % (k, net[k]) + + return str + + def main(): - from config import config fb = database.dbLoad("findbad") - parser = OptionParser() + parser = parsermodule.getParser() parser.set_defaults(nodelist=None, list=False, add=False, @@ -24,8 +32,8 @@ def main(): ) parser.add_option("", "--nodelist", dest="nodelist", metavar="list.txt", help="Use all nodes in the given file for operation.") - config = config(parser) - config.parse_args() + parser = parsermodule.getParser(['defaults'], parser) + config = parsermodule.parse_args(parser) # COLLECT nodegroups, nodes and node lists for node in config.args: @@ -33,7 +41,7 @@ def main(): try: n = api.GetNodes(node)[0] #print n - net = api.GetNodeNetworks(n['nodenetwork_ids'])[0] + net = api.GetInterfaces(n['interface_ids'])[0] #print net node_keys = ['boot_state', 'key', 'last_updated', 'last_contact'] @@ -43,15 +51,15 @@ def main(): else: print "%15s == %s" % (k, n[k]) - static_keys = ['method', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'mac', 'is_primary'] - for k in static_keys: - print "%15s == %s" % (k, net[k]) + print network_config_to_str(net) #for k in net.keys(): # print k, "==" , net[k] except: print "Error with %s" % node import traceback; print traceback.print_exc() + from nodecommon import email_exception + email_exception() pass # commands: