def duplicate(vm, background, count, all_, filter): """Duplicate a broker-procured vm COMMAND: broker duplicate <vm hostname>|<local id>|all :param vm: Hostname or local id of host :param background: run a new broker subprocess to carry out command :param all_: Click option all :param filter: a filter string matching broker's specification """ if background: helpers.fork_broker() inventory = helpers.load_inventory(filter=filter) for num, host in enumerate(inventory): if str(num ) in vm or host["hostname"] in vm or host["name"] in vm or all_: broker_args = host.get("_broker_args") if broker_args: if count: broker_args["_count"] = count logger.info(f"Duplicating: {host['hostname']}") broker_inst = Broker(**broker_args) broker_inst.checkout() else: logger.warning( f"Unable to duplicate {host['hostname']}, no _broker_args found" )
def checkout(ctx, background, nick, count, args_file, **kwargs): """Checkout or "create" a Virtual Machine broker instance COMMAND: broker checkout --workflow "workflow-name" --workflow-arg1 something or COMMAND: broker checkout --nick "nickname" :param ctx: clicks context object :param background: run a new broker subprocess to carry out command :param nick: shortcut for arguments saved in settings.yaml, passed in as a string :param args_file: this broker argument wil be replaced with the contents of the file passed in """ broker_args = helpers.clean_dict(kwargs) if nick: broker_args["nick"] = nick if count: broker_args["_count"] = count if args_file: broker_args["args_file"] = args_file # if additional arguments were passed, include them in the broker args # strip leading -- characters broker_args.update({(key[2:] if key.startswith("--") else key): val for key, val in zip(ctx.args[::2], ctx.args[1::2])}) if background: helpers.fork_broker() broker_inst = Broker(**broker_args) broker_inst.checkout()