def run_command_with_args(command, args): if command == "info": commands.info(args.hosts, None) elif command == "install": commands.install(args.hub, args.clients, package=args.package, bootstrap=args.bootstrap, hub_package=args.hub_package, client_package=args.client_package, version=args.version, demo=args.demo, call_collect=args.call_collect, edition=args.edition) elif command == "uninstall": all_hosts = ((args.hosts or []) + (args.hub or []) + (args.clients or [])) commands.uninstall(all_hosts) elif command == "packages": commands.packages(tags=args.tags, version=args.version, edition=args.edition) elif command == "run": commands.run(hosts=args.hosts, raw=args.raw, command=args.remote_command) elif command == "sudo": commands.sudo(hosts=args.hosts, raw=args.raw, command=args.remote_command) elif command == "scp": commands.scp(hosts=args.hosts, files=args.args) elif command == "spawn": if args.list_platforms: commands.list_platforms() return if args.init_config: commands.init_cloud_config() return if args.name and "," in args.name: user_error("Group --name may not contain commas") # else if args.role.endswith("s"): # role should be singular args.role = args.role[:-1] commands.spawn(args.platform, args.count, args.role, args.name) elif command == "destroy": group_name = args.name if args.name else None commands.destroy(group_name) else: user_error("Unknown command: '{}'".format(command))
def run_command_with_args(command, args): if command == "info": return commands.info(args.hosts, None) elif command == "install": if args.trust_keys: trust_keys = args.trust_keys.split(",") else: trust_keys = None return commands.install( args.hub, args.clients, package=args.package, bootstrap=args.bootstrap, hub_package=args.hub_package, client_package=args.client_package, version=args.version, demo=args.demo, call_collect=args.call_collect, edition=args.edition, remote_download=args.remote_download, trust_keys=trust_keys) elif command == "uninstall": all_hosts = ((args.hosts or []) + (args.hub or []) + (args.clients or [])) return commands.uninstall(all_hosts) elif command == "packages": log.warning("packages command is deprecated, please use the new command: download") return commands.download(tags=args.tags, version=args.version, edition=args.edition) elif command == "list": return commands.list_command(tags=args.tags, version=args.version, edition=args.edition) elif command == "download": return commands.download(tags=args.tags, version=args.version, edition=args.edition) elif command == "run": return commands.run(hosts=args.hosts, raw=args.raw, command=args.remote_command) elif command == "sudo": return commands.sudo(hosts=args.hosts, raw=args.raw, command=args.remote_command) elif command == "scp": return commands.scp(hosts=args.hosts, files=args.args) elif command == "spawn": if args.list_platforms: return commands.list_platforms() if args.init_config: return commands.init_cloud_config() if args.name and "," in args.name: user_error("Group --name may not contain commas") if args.aws and args.gcp: user_error("--aws and --gcp cannot be used at the same time") if args.role.endswith("s"): # role should be singular args.role = args.role[:-1] if args.gcp: provider = Providers.GCP else: # AWS is currently also the default provider = Providers.AWS if args.network: user_error("--network not supported for AWS") if args.no_public_ip: user_error("--no-public-ip not supported for AWS") if args.network and (args.network.count("/") != 1): user_error("Invalid network specified, needs to be in the network/subnet format") return commands.spawn(args.platform, args.count, args.role, args.name, provider=provider, size=args.size, network=args.network, public_ip=not args.no_public_ip, extend_group=args.append) elif command == "destroy": group_name = args.name if args.name else None return commands.destroy(group_name) elif command == "deploy": return commands.deploy(args.hub, args.directory) else: user_error("Unknown command: '{}'".format(command))