handle the case where there is no data in db yet.
[monitor.git] / getconf.py
index 205f0ff..1f84674 100755 (executable)
@@ -1,10 +1,11 @@
 #!/usr/bin/python
 
-import plc
+from monitor.wrapper import plc
+from monitor import config
+import monitor.parser as parsermodule
 api = plc.getAuthAPI()
 import sys
 import os
-import monitorconfig
 
 def getconf(hostname, force=False, media=None):
        n = api.GetNodes(hostname)
@@ -21,23 +22,21 @@ def getconf(hostname, force=False, media=None):
 
        args = {}
        if not media:
-               args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (monitorconfig.MONITOR_HOSTNAME, hostname)
-               args['url_list'] += "   http://%s/bootcds/%s.iso" % (monitorconfig.MONITOR_HOSTNAME, hostname)
+               args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (config.MONITOR_HOSTNAME, hostname)
+               args['url_list'] += "   http://%s/bootcds/%s.iso" % (config.MONITOR_HOSTNAME, hostname)
        else:
                if media == "usb":
-                       args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (monitorconfig.MONITOR_HOSTNAME, hostname)
+                       args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (config.MONITOR_HOSTNAME, hostname)
                elif media == "iso":
-                       args['url_list']  = "   http://%s/bootcds/%s.iso" % (monitorconfig.MONITOR_HOSTNAME, hostname)
+                       args['url_list']  = "   http://%s/bootcds/%s.iso" % (config.MONITOR_HOSTNAME, hostname)
                else:
-                       args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (monitorconfig.MONITOR_HOSTNAME, hostname)
-                       args['url_list'] += "   http://%s/bootcds/%s.iso" % (monitorconfig.MONITOR_HOSTNAME, hostname)
+                       args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (config.MONITOR_HOSTNAME, hostname)
+                       args['url_list'] += "   http://%s/bootcds/%s.iso" % (config.MONITOR_HOSTNAME, hostname)
                        
 
        return args
 
 if __name__ == '__main__':
-       import parser as parsermodule
-
        parser = parsermodule.getParser()
        parser.set_defaults(media='both', force=False)
        parser.add_option("", "--media", dest="media", metavar="usb, iso, both", 
@@ -46,7 +45,7 @@ if __name__ == '__main__':
                                                help="""Force the recreation of the usb images.""")
        parser = parsermodule.getParser(['defaults'], parser)
 
-       config = parsesrmodule.parse_args(parser)
+       config = parsermodule.parse_args(parser)
 
        ret = {'url_list' : ''} 
        for i in config.args: