changes for 3.0
[monitor.git] / nodeconfig.py
index d8a8c12..ac84ec3 100755 (executable)
@@ -4,7 +4,7 @@
 import plc
 api = plc.getAuthAPI()
 
-from optparse import OptionParser
+import parser as parsermodule
 from sets import Set
 
 from nodecommon import *
@@ -21,10 +21,9 @@ def network_config_to_str(net):
        
 
 def main():
-       from config import config
        fb = database.dbLoad("findbad")
 
-       parser = OptionParser()
+       parser = parsermodule.getParser()
        parser.set_defaults(nodelist=None,
                                                list=False,
                                                add=False,
@@ -33,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:
@@ -42,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']
@@ -59,6 +58,8 @@ def main():
                except:
                        print "Error with %s" % node
                        import traceback; print traceback.print_exc()
+                       from nodecommon import email_exception
+                       email_exception()
                        pass
 
        # commands: