def load(*argv): usage = """ Load an image on selected nodes in parallel {resa} """.format(resa=reservation_required) the_config = Config() the_imagesrepo = ImagesRepo() default_image = the_imagesrepo.default() default_timeout = the_config.value('nodes', 'load_default_timeout') default_bandwidth = the_config.value('networking', 'bandwidth') parser = ArgumentParser(usage=usage) parser.add_argument("-i", "--image", action='store', default=default_image, help="Specify image to load (default is {})" .format(default_image)) parser.add_argument("-t", "--timeout", action='store', default=default_timeout, type=float, help="Specify global timeout for the whole process, default={}" .format(default_timeout)) parser.add_argument("-b", "--bandwidth", action='store', default=default_bandwidth, type=int, help="Set bandwidth in Mibps for frisbee uploading - default={}" .format(default_bandwidth)) parser.add_argument("-c", "--curses", action='store_true', default=False, help="Use curses to provide term-based animation") # this is more for debugging parser.add_argument("-n", "--no-reset", dest='reset', action='store_false', default=True, help="""use this with nodes that are already running a frisbee image. They won't get reset, neither before or after the frisbee session""") add_selector_arguments(parser) args = parser.parse_args(argv) message_bus = asyncio.Queue() selector = selected_selector(args) if not selector.how_many(): parser.print_help() return 1 nodes = [Node(cmc_name, message_bus) for cmc_name in selector.cmc_names()] # send feedback message_bus.put_nowait({'selected_nodes': selector}) from rhubarbe.logger import logger logger.info("timeout is {}s".format(args.timeout)) logger.info("bandwidth is {} Mibps".format(args.bandwidth)) actual_image = the_imagesrepo.locate_image(args.image, look_in_global=True) if not actual_image: print("Image file {} not found - emergency exit".format(args.image)) exit(1) # send feedback message_bus.put_nowait({'loading_image': actual_image}) display_class = Display if not args.curses else DisplayCurses display = display_class(nodes, message_bus) loader = ImageLoader(nodes, image=actual_image, bandwidth=args.bandwidth, message_bus=message_bus, display=display) return loader.main(reset=args.reset, timeout=args.timeout)
def global_load_image(self, image_name): # locate image the_imagesrepo = ImagesRepo() actual_image = the_imagesrepo.locate_image(image_name, look_in_global=True) if not actual_image: self.print(f"image file {image_name} not found - emergency exit") exit(1) # load image self.verbose_msg(f"image={actual_image}") self.verbose_msg(f"bandwidth={self.bandwidth}") self.verbose_msg(f"timeout={self.load_timeout}") loader = ImageLoader(self.nodes, image=actual_image, bandwidth=self.bandwidth, message_bus=self.bus, display=self.display) self.print(f"loading image {actual_image}" f" (timeout = {self.load_timeout})") loader.main(reset=True, timeout=self.load_timeout) self.print("load done")
def load(*argv): usage = f""" Load an image on selected nodes in parallel {RESERVATION_REQUIRED} """ config = Config() config.check_binaries() imagesrepo = ImagesRepo() parser = ArgumentParser(usage=usage, formatter_class=ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--image", action='store', default=imagesrepo.default(), help="Specify image to load") parser.add_argument("-t", "--timeout", action='store', default=config.value('nodes', 'load_default_timeout'), type=float, help="Specify global timeout for the whole process") parser.add_argument("-b", "--bandwidth", action='store', default=config.value('networking', 'bandwidth'), type=int, help="Set bandwidth in Mibps for frisbee uploading") parser.add_argument("-c", "--curses", action='store_true', default=False, help="Use curses to provide term-based animation") # this is more for debugging parser.add_argument("-n", "--no-reset", dest='reset', action='store_false', default=True, help="""use this with nodes that are already running a frisbee image. They won't get reset, neither before or after the frisbee session""") add_selector_arguments(parser) args = parser.parse_args(argv) message_bus = asyncio.Queue() selector = selected_selector(args) if selector.is_empty(): parser.print_help() return 1 nodes = [ Node(cmc_name, message_bus) # pylint: disable=w0621 for cmc_name in selector.cmc_names() ] # send feedback message_bus.put_nowait({'selected_nodes': selector}) from rhubarbe.logger import logger logger.info(f"timeout is {args.timeout}s") logger.info(f"bandwidth is {args.bandwidth} Mibps") actual_image = imagesrepo.locate_image(args.image, look_in_global=True) if not actual_image: print(f"Image file {args.image} not found - emergency exit") exit(1) # send feedback message_bus.put_nowait({'loading_image': actual_image}) display_class = Display if not args.curses else DisplayCurses display = display_class(nodes, message_bus) loader = ImageLoader(nodes, image=actual_image, bandwidth=args.bandwidth, message_bus=message_bus, display=display) return loader.main(reset=args.reset, timeout=args.timeout)