def main(): ank_version = pkg_resources.get_distribution("AutoNetkit").version log.info("AutoNetkit %s" % ank_version) import optparse opt = optparse.OptionParser() opt.add_option('--file', '-f', default=None, help="Load topology from FILE") opt.add_option('--monitor', '-m', action="store_true", default=False, help="Monitor input file for changes") options, arguments = opt.parse_args() input_filename = options.file if not options.file: input_filename = "ank.graphml" anm = build_network(input_filename) anm.save() nidb = compile_network(anm) render.render(nidb) #deploy_network() if options.monitor: try: log.info("Monitoring for updates...") while True: time.sleep(0.2) if change_monitor.check_for_change(input_filename, anm): try: log.info("Input graph updated, recompiling network") anm = build_network(input_filename) anm.save() nidb = compile_network(anm) render.render(nidb) log.info("Monitoring for updates...") except: # TODO: remove this, add proper warning log.warn("Unable to build network") pass except KeyboardInterrupt: log.info("Exiting")
def main(): ank_version = pkg_resources.get_distribution("AutoNetkit").version log.info("AutoNetkit %s" % ank_version) import optparse opt = optparse.OptionParser() opt.add_option('--file', '-f', default= None, help="Load topology from FILE") opt.add_option('--monitor', '-m', action="store_true", default= False, help="Monitor input file for changes") options, arguments = opt.parse_args() input_filename = options.file if not options.file: input_filename = "ank.graphml" anm = build_network(input_filename) anm.save() nidb = compile_network(anm) render.render(nidb) #deploy_network() if options.monitor: try: log.info("Monitoring for updates...") while True: time.sleep(0.2) if change_monitor.check_for_change(input_filename, anm): try: log.info("Input graph updated, recompiling network") anm = build_network(input_filename) anm.save() nidb = compile_network(anm) render.render(nidb) log.info("Monitoring for updates...") except: # TODO: remove this, add proper warning log.warn("Unable to build network") pass except KeyboardInterrupt: log.info("Exiting")
def main(): ank_version = pkg_resources.get_distribution("AutoNetkit").version log.info("AutoNetkit %s" % ank_version) import optparse opt = optparse.OptionParser() opt.add_option('--file', '-f', default= None, help="Load topology from FILE") opt.add_option('--monitor', '-m', action="store_true", default= False, help="Monitor input file for changes") opt.add_option('--debug', action="store_true", default= False, help="Debug mode") opt.add_option('--compile', action="store_true", default= False, help="Compile") opt.add_option('--deploy', action="store_true", default= False, help="Deploy") opt.add_option('--measure', action="store_true", default= False, help="Measure") options, arguments = opt.parse_args() input_filename = options.file if not options.file: input_filename = "ank.graphml" if options.debug: #TODO: fix this import logging logger = logging.getLogger("ANK") logger.setLevel(logging.DEBUG) if options.compile: anm = build_network(input_filename) anm.save() nidb = compile_network(anm) nidb.save() render.remove_dirs(["rendered/nectar1/nklab/"]) render.render(nidb) else: anm = AbstractNetworkModel() anm.restore_latest() nidb = NIDB() nidb.restore_latest() if options.deploy: deploy_network(nidb) if options.measure: measure_network(nidb) if options.monitor: try: log.info("Monitoring for updates...") while True: time.sleep(0.2) if change_monitor.check_for_change(input_filename, anm): try: log.info("Input graph updated, recompiling network") if options.compile: nidb = compile_network(anm) render.remove_dirs(["rendered/nectar1/nklab/"]) render.render(nidb) if options.deploy: deploy_network(nidb) if options.measure: measure_network(nidb) log.info("Monitoring for updates...") except: # TODO: remove this, add proper warning log.warn("Unable to build network") pass except KeyboardInterrupt: log.info("Exiting")