示例#1
0
def dispatch_cmds(args):
    if args.debug:
        requests_log = logging.getLogger("python-tutum")
        requests_log.setLevel(logging.INFO)
        cli_log = logging.getLogger("cli")
        cli_log.setLevel(logging.DEBUG)
    if args.cmd == 'login':
        commands.login(args.username, args.password, args.email)
    elif args.cmd == 'action':
        if args.subcmd == 'inspect':
            commands.action_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.action_list(args.quiet, args.last)
        elif args.subcmd == 'logs':
            commands.action_logs(args.identifier, args.tail, args.follow)
    elif args.cmd == 'build':
        commands.build(args.tag, args.directory, args.sock)
    elif args.cmd == 'event':
        commands.event()
    elif args.cmd == 'exec':
        commands.container_exec(args.identifier, args.command)
    elif args.cmd == 'push':
        commands.image_push(args.name, args.public)
    elif args.cmd == 'run':
        commands.service_run(image=args.image,
                             name=args.name,
                             cpu_shares=args.cpushares,
                             memory=args.memory,
                             privileged=args.privileged,
                             target_num_containers=args.target_num_containers,
                             run_command=args.run_command,
                             entrypoint=args.entrypoint,
                             expose=args.expose,
                             publish=args.publish,
                             envvars=args.env,
                             envfiles=args.env_file,
                             tag=args.tag,
                             linked_to_service=args.link_service,
                             autorestart=args.autorestart,
                             autodestroy=args.autodestroy,
                             autoredeploy=args.autoredeploy,
                             roles=args.role,
                             sequential=args.sequential,
                             volume=args.volume,
                             volumes_from=args.volumes_from,
                             deployment_strategy=args.deployment_strategy,
                             sync=args.sync,
                             net=args.net,
                             pid=args.pid)
    elif args.cmd == 'service':
        if args.subcmd == 'create':
            commands.service_create(
                image=args.image,
                name=args.name,
                cpu_shares=args.cpushares,
                memory=args.memory,
                privileged=args.privileged,
                target_num_containers=args.target_num_containers,
                run_command=args.run_command,
                entrypoint=args.entrypoint,
                expose=args.expose,
                publish=args.publish,
                envvars=args.env,
                envfiles=args.env_file,
                tag=args.tag,
                linked_to_service=args.link_service,
                autorestart=args.autorestart,
                autodestroy=args.autodestroy,
                autoredeploy=args.autoredeploy,
                roles=args.role,
                sequential=args.sequential,
                volume=args.volume,
                volumes_from=args.volumes_from,
                deployment_strategy=args.deployment_strategy,
                sync=args.sync,
                net=args.net,
                pid=args.pid)
        elif args.subcmd == 'inspect':
            commands.service_inspect(args.identifier)
        elif args.subcmd == 'logs':
            commands.service_logs(args.identifier, args.tail, args.follow)
        elif args.subcmd == 'ps':
            commands.service_ps(args.quiet, args.status, args.stack)
        elif args.subcmd == 'redeploy':
            commands.service_redeploy(args.identifier, args.sync)
        elif args.subcmd == 'run':
            commands.service_run(
                image=args.image,
                name=args.name,
                cpu_shares=args.cpushares,
                memory=args.memory,
                privileged=args.privileged,
                target_num_containers=args.target_num_containers,
                run_command=args.run_command,
                entrypoint=args.entrypoint,
                expose=args.expose,
                publish=args.publish,
                envvars=args.env,
                envfiles=args.env_file,
                tag=args.tag,
                linked_to_service=args.link_service,
                autorestart=args.autorestart,
                autodestroy=args.autodestroy,
                autoredeploy=args.autoredeploy,
                roles=args.role,
                sequential=args.sequential,
                volume=args.volume,
                volumes_from=args.volumes_from,
                deployment_strategy=args.deployment_strategy,
                sync=args.sync,
                net=args.net,
                pid=args.pid)
        elif args.subcmd == 'scale':
            commands.service_scale(args.identifier, args.target_num_containers,
                                   args.sync)
        elif args.subcmd == 'set':
            commands.service_set(
                args.identifier,
                image=args.image,
                cpu_shares=args.cpushares,
                memory=args.memory,
                privileged=args.privileged,
                target_num_containers=args.target_num_containers,
                run_command=args.run_command,
                entrypoint=args.entrypoint,
                expose=args.expose,
                publish=args.publish,
                envvars=args.env,
                envfiles=args.env_file,
                tag=args.tag,
                linked_to_service=args.link_service,
                autorestart=args.autorestart,
                autodestroy=args.autodestroy,
                autoredeploy=args.autoredeploy,
                roles=args.role,
                sequential=args.sequential,
                redeploy=args.redeploy,
                volume=args.volume,
                volumes_from=args.volumes_from,
                deployment_strategy=args.deployment_strategy,
                sync=args.sync,
                net=args.net,
                pid=args.pid)
        elif args.subcmd == 'start':
            commands.service_start(args.identifier, args.sync)
        elif args.subcmd == 'stop':
            commands.service_stop(args.identifier, args.sync)
        elif args.subcmd == 'terminate':
            commands.service_terminate(args.identifier, args.sync)
        elif args.subcmd == 'env':
            if args.envsubcmd == 'add':
                commands.service_env_add(args.identifier,
                                         envvars=args.env,
                                         envfiles=args.env_file,
                                         redeploy=args.redeploy,
                                         sync=args.sync)
            elif args.envsubcmd == 'list':
                commands.service_env_list(args.identifier, args.quiet,
                                          args.user, args.image, args.tutum)
            elif args.envsubcmd == 'remove':
                commands.service_env_remove(args.identifier,
                                            names=args.name,
                                            redeploy=args.redeploy,
                                            sync=args.sync)
            elif args.envsubcmd == 'set':
                commands.service_env_set(args.identifier,
                                         envvars=args.env,
                                         envfiles=args.env_file,
                                         redeploy=args.redeploy,
                                         sync=args.sync)
            elif args.envsubcmd == 'update':
                commands.service_env_update(args.identifier,
                                            envvars=args.env,
                                            envfiles=args.env_file,
                                            redeploy=args.redeploy,
                                            sync=args.sync)
    elif args.cmd == 'container':
        if args.subcmd == 'exec':
            commands.container_exec(args.identifier, args.command)
        elif args.subcmd == 'inspect':
            commands.container_inspect(args.identifier)
        elif args.subcmd == 'logs':
            commands.container_logs(args.identifier, args.tail, args.follow)
        elif args.subcmd == 'redeploy':
            commands.container_redeploy(args.identifier, args.sync)
        elif args.subcmd == 'ps':
            commands.container_ps(args.quiet, args.status, args.service,
                                  args.no_trunc)
        elif args.subcmd == 'start':
            commands.container_start(args.identifier, args.sync)
        elif args.subcmd == 'stop':
            commands.container_stop(args.identifier, args.sync)
        elif args.subcmd == 'terminate':
            commands.container_terminate(args.identifier, args.sync)
    elif args.cmd == 'image':
        if args.subcmd == 'list':
            commands.image_list(args.quiet, args.jumpstarts, args.private,
                                args.user, args.all, args.no_trunc)
        elif args.subcmd == 'register':
            commands.image_register(args.image_name, args.description,
                                    args.username, args.password, args.sync)
        elif args.subcmd == 'push':
            commands.image_push(args.name, args.public)
        elif args.subcmd == 'rm':
            commands.image_rm(args.image_name, args.sync)
        elif args.subcmd == 'search':
            commands.image_search(args.query)
        elif args.subcmd == 'update':
            commands.image_update(args.image_name, args.username,
                                  args.password, args.description, args.sync)
        elif args.subcmd == 'inspect':
            commands.image_inspect(args.identifier)
        elif args.subcmd == 'tag':
            if args.imagetagsubcmd == 'list':
                commands.image_tag_list(args.jumpstarts, args.private,
                                        args.user, args.all, args.identifier)
            elif args.imagetagsubcmd == 'inspect':
                commands.image_tag_inspect(args.identifier)
            elif args.imagetagsubcmd == 'build':
                commands.image_tag_build(args.identifier, args.sync)
    elif args.cmd == 'node':
        if args.subcmd == 'inspect':
            commands.node_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.node_list(args.quiet)
        elif args.subcmd == 'rm':
            commands.node_rm(args.identifier, args.sync)
        elif args.subcmd == 'upgrade':
            commands.node_upgrade(args.identifier, args.sync)
        elif args.subcmd == 'byo':
            commands.node_byo()
    elif args.cmd == 'nodecluster':
        if args.subcmd == 'create':
            commands.nodecluster_create(args.target_num_nodes, args.name,
                                        args.provider, args.region,
                                        args.nodetype, args.sync)
        elif args.subcmd == 'inspect':
            commands.nodecluster_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.nodecluster_list(args.quiet)
        elif args.subcmd == 'provider':
            commands.nodecluster_show_providers(args.quiet)
        elif args.subcmd == 'region':
            commands.nodecluster_show_regions(args.provider)
        elif args.subcmd == 'nodetype':
            commands.nodecluster_show_types(args.provider, args.region)
        elif args.subcmd == 'rm':
            commands.nodecluster_rm(args.identifier, args.sync)
        elif args.subcmd == 'az':
            commands.nodecluster_az(args.quiet)
        elif args.subcmd == 'scale':
            commands.nodecluster_scale(args.identifier, args.target_num_nodes,
                                       args.sync)
        elif args.subcmd == 'upgrade':
            commands.nodecluster_upgrade(args.identifier, args.sync)
    elif args.cmd == 'tag':
        if args.subcmd == 'add':
            commands.tag_add(args.identifier, args.tag)
        elif args.subcmd == 'list':
            commands.tag_list(args.identifier, args.quiet)
        elif args.subcmd == 'rm':
            commands.tag_rm(args.identifier, args.tag)
        elif args.subcmd == 'set':
            commands.tag_set(args.identifier, args.tag)
    elif args.cmd == 'volume':
        if args.subcmd == 'list':
            commands.volume_list(args.quiet)
        if args.subcmd == 'inspect':
            commands.volume_inspect(args.identifier)
    elif args.cmd == 'volumegroup':
        if args.subcmd == 'list':
            commands.volumegroup_list(args.quiet)
        if args.subcmd == 'inspect':
            commands.volumegroup_inspect(args.identifier)
    elif args.cmd == 'trigger':
        if args.subcmd == 'create':
            commands.trigger_create(args.identifier, args.name, args.operation)
        elif args.subcmd == 'list':
            commands.trigger_list(args.identifier, args.quiet)
        elif args.subcmd == 'rm':
            commands.trigger_rm(args.identifier, args.trigger)
    elif args.cmd == 'stack':
        if args.subcmd == 'create':
            commands.stack_create(args.name, args.file, args.sync)
        elif args.subcmd == 'inspect':
            commands.stack_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.stack_list(args.quiet)
        elif args.subcmd == 'redeploy':
            commands.stack_redeploy(args.identifier, args.sync)
        elif args.subcmd == 'start':
            commands.stack_start(args.identifier, args.sync)
        elif args.subcmd == 'stop':
            commands.stack_stop(args.identifier, args.sync)
        elif args.subcmd == 'terminate':
            commands.stack_terminate(args.identifier, args.sync)
        elif args.subcmd == 'up':
            commands.stack_up(args.name, args.file, args.sync)
        elif args.subcmd == 'update':
            commands.stack_update(args.identifier, args.file, args.sync)
        elif args.subcmd == 'export':
            commands.stack_export(args.identifier, args.file)
    elif args.cmd == 'up':
        commands.stack_up(args.name, args.file, args.sync)
示例#2
0
def main():
    if len(sys.argv) == 1:
        sys.argv.append('-h')
    elif len(sys.argv) == 2 and sys.argv[1] in ['cluster', 'build', 'container', 'image', ]:
        sys.argv.append('-h')
    elif len(sys.argv) == 3:
        if sys.argv[1] == 'cluster' and sys.argv[2] in ['alias', 'inspect', 'logs', 'redeploy', 'run', 'scale', 'set',
                                                    'start', 'stop', 'terminate']:
            sys.argv.append('-h')
        elif sys.argv[1] == 'container' and sys.argv[2] in ['inspect', 'logs', 'redeploy', 'run', 'start', 'stop',
                                                            'terminate']:
            sys.argv.append('-h')
        elif sys.argv[1] == 'image' and sys.argv[2] in ['register', 'push', 'rm', 'search', 'update']:
            sys.argv.append('-h')

    # dispatch commands
    args = parser.parse_args()
    if args.debug:
        requests_log = logging.getLogger("python-tutum")
        requests_log.setLevel(logging.INFO)
    if args.cmd == 'login':
        commands.login()
    if args.cmd == 'build':
        commands.build(args.tag, args.directory, args.quiet, args.no_cache)
    elif args.cmd == 'cluster':
        if args.subcmd == 'alias':
            commands.cluster_alias(args.identifier, args.dns)
        elif args.subcmd == 'inspect':
            commands.cluster_inspect(args.identifier)
        elif args.subcmd == 'logs':
            commands.cluster_logs(args.identifier)
        elif args.subcmd == 'open':
            commands.cluster_open()
        elif args.subcmd == 'ps':
            commands.cluster_ps(args.quiet, args.status)
        elif args.subcmd == 'redeploy':
            commands.cluster_redeploy(args.identifier, args.tag)
        elif args.subcmd == 'run':
            commands.cluster_run(image=args.image, name=args.name, container_size=args.container_size,
                             target_num_containers=args.target_num_containers, run_command=args.run_command,
                             entrypoint=args.entrypoint, container_ports=args.port, container_envvars=args.env,
                             linked_to_cluster=args.link_cluster, linked_to_container=args.link_container,
                             autorestart=args.autorestart,
                             autoreplace=args.autoreplace, autodestroy=args.autodestroy, roles=args.role,
                             sequential=args.sequential, web_public_dns=args.web_public_dns)
        elif args.subcmd == 'scale':
            commands.cluster_scale(args.identifier, args.target_num_containers)
        elif args.subcmd == 'set':
            commands.cluster_set(args.autorestart, args.autoreplace, args.autodestroy, args.identifier)
        elif args.subcmd == 'start':
            commands.cluster_start(args.identifier)
        elif args.subcmd == 'stop':
            commands.cluster_stop(args.identifier)
        elif args.subcmd == 'terminate':
            commands.cluster_terminate(args.identifier)
    elif args.cmd == 'container':
        if args.subcmd == 'inspect':
            commands.container_inspect(args.identifier)
        elif args.subcmd == 'logs':
            commands.container_logs(args.identifier)
        elif args.subcmd == 'ps':
            commands.container_ps(args.identifier, args.quiet, args.status)
        elif args.subcmd == 'redeploy':
            commands.container_redeploy(args.identifier, args.tag)
        elif args.subcmd == 'run':
            commands.container_run(image=args.image, name=args.name, container_size=args.container_size,
                             run_command=args.run_command, entrypoint=args.entrypoint, container_ports=args.port,
                             container_envvars=args.env,
                             linked_to_cluster=args.link_cluster, linked_to_container=args.link_container,
                             autorestart=args.autorestart,autoreplace=args.autoreplace, autodestroy=args.autodestroy,
                             roles=args.role, web_public_dns=args.web_public_dns)
        elif args.subcmd == 'start':
            commands.container_start(args.identifier)
        elif args.subcmd == 'stop':
            commands.container_stop(args.identifier)
        elif args.subcmd == 'terminate':
            commands.container_terminate(args.identifier)
    elif args.cmd == 'image':
        if args.subcmd == 'list':
            commands.image_list(args.quiet, args.jumpstarts, args.linux)
        elif args.subcmd == 'register':
            commands.image_register(args.image_name, args.description)
        elif args.subcmd == 'push':
            commands.image_push(args.name, args.public)
        elif args.subcmd == 'rm':
            commands.image_rm(args.image_name)
        elif args.subcmd == 'search':
            commands.image_search(args.query)
        elif args.subcmd == 'update':
            commands.image_update(args.image_name, args.username, args.password, args.description)
示例#3
0
文件: tutum_cli.py 项目: kelvinn/cli
def dispatch_cmds(args):
    if args.debug:
        requests_log = logging.getLogger("python-tutum")
        requests_log.setLevel(logging.INFO)
        cli_log = logging.getLogger("cli")
        cli_log.setLevel(logging.DEBUG)
    if args.cmd == "login":
        commands.login(args.username, args.password, args.email)
    elif args.cmd == "action":
        if args.subcmd == "inspect":
            commands.action_inspect(args.identifier)
        elif args.subcmd == "list":
            commands.action_list(args.quiet, args.last)
        elif args.subcmd == "logs":
            commands.action_logs(args.identifier, args.tail, args.follow)
    elif args.cmd == "build":
        commands.build(args.tag, args.directory, args.sock)
    elif args.cmd == "event":
        commands.event()
    elif args.cmd == "exec":
        commands.container_exec(args.identifier, args.command)
    elif args.cmd == "push":
        commands.image_push(args.name, args.public)
    elif args.cmd == "run":
        commands.service_run(
            image=args.image,
            name=args.name,
            cpu_shares=args.cpushares,
            memory=args.memory,
            privileged=args.privileged,
            target_num_containers=args.target_num_containers,
            run_command=args.run_command,
            entrypoint=args.entrypoint,
            expose=args.expose,
            publish=args.publish,
            envvars=args.env,
            envfiles=args.env_file,
            tag=args.tag,
            linked_to_service=args.link_service,
            autorestart=args.autorestart,
            autodestroy=args.autodestroy,
            autoredeploy=args.autoredeploy,
            roles=args.role,
            sequential=args.sequential,
            volume=args.volume,
            volumes_from=args.volumes_from,
            deployment_strategy=args.deployment_strategy,
            sync=args.sync,
            net=args.net,
            pid=args.pid,
        )
    elif args.cmd == "service":
        if args.subcmd == "create":
            commands.service_create(
                image=args.image,
                name=args.name,
                cpu_shares=args.cpushares,
                memory=args.memory,
                privileged=args.privileged,
                target_num_containers=args.target_num_containers,
                run_command=args.run_command,
                entrypoint=args.entrypoint,
                expose=args.expose,
                publish=args.publish,
                envvars=args.env,
                envfiles=args.env_file,
                tag=args.tag,
                linked_to_service=args.link_service,
                autorestart=args.autorestart,
                autodestroy=args.autodestroy,
                autoredeploy=args.autoredeploy,
                roles=args.role,
                sequential=args.sequential,
                volume=args.volume,
                volumes_from=args.volumes_from,
                deployment_strategy=args.deployment_strategy,
                sync=args.sync,
                net=args.net,
                pid=args.pid,
            )
        elif args.subcmd == "inspect":
            commands.service_inspect(args.identifier)
        elif args.subcmd == "logs":
            commands.service_logs(args.identifier, args.tail, args.follow)
        elif args.subcmd == "ps":
            commands.service_ps(args.quiet, args.status, args.stack)
        elif args.subcmd == "redeploy":
            commands.service_redeploy(args.identifier, args.sync)
        elif args.subcmd == "run":
            commands.service_run(
                image=args.image,
                name=args.name,
                cpu_shares=args.cpushares,
                memory=args.memory,
                privileged=args.privileged,
                target_num_containers=args.target_num_containers,
                run_command=args.run_command,
                entrypoint=args.entrypoint,
                expose=args.expose,
                publish=args.publish,
                envvars=args.env,
                envfiles=args.env_file,
                tag=args.tag,
                linked_to_service=args.link_service,
                autorestart=args.autorestart,
                autodestroy=args.autodestroy,
                autoredeploy=args.autoredeploy,
                roles=args.role,
                sequential=args.sequential,
                volume=args.volume,
                volumes_from=args.volumes_from,
                deployment_strategy=args.deployment_strategy,
                sync=args.sync,
                net=args.net,
                pid=args.pid,
            )
        elif args.subcmd == "scale":
            commands.service_scale(args.identifier, args.target_num_containers, args.sync)
        elif args.subcmd == "set":
            commands.service_set(
                args.identifier,
                image=args.image,
                cpu_shares=args.cpushares,
                memory=args.memory,
                privileged=args.privileged,
                target_num_containers=args.target_num_containers,
                run_command=args.run_command,
                entrypoint=args.entrypoint,
                expose=args.expose,
                publish=args.publish,
                envvars=args.env,
                envfiles=args.env_file,
                tag=args.tag,
                linked_to_service=args.link_service,
                autorestart=args.autorestart,
                autodestroy=args.autodestroy,
                autoredeploy=args.autoredeploy,
                roles=args.role,
                sequential=args.sequential,
                redeploy=args.redeploy,
                volume=args.volume,
                volumes_from=args.volumes_from,
                deployment_strategy=args.deployment_strategy,
                sync=args.sync,
                net=args.net,
                pid=args.pid,
            )
        elif args.subcmd == "start":
            commands.service_start(args.identifier, args.sync)
        elif args.subcmd == "stop":
            commands.service_stop(args.identifier, args.sync)
        elif args.subcmd == "terminate":
            commands.service_terminate(args.identifier, args.sync)
        elif args.subcmd == "env":
            if args.envsubcmd == "add":
                commands.service_env_add(
                    args.identifier, envvars=args.env, envfiles=args.env_file, redeploy=args.redeploy, sync=args.sync
                )
            elif args.envsubcmd == "list":
                commands.service_env_list(args.identifier, args.quiet, args.user, args.image, args.tutum)
            elif args.envsubcmd == "remove":
                commands.service_env_remove(args.identifier, names=args.name, redeploy=args.redeploy, sync=args.sync)
            elif args.envsubcmd == "set":
                commands.service_env_set(
                    args.identifier, envvars=args.env, envfiles=args.env_file, redeploy=args.redeploy, sync=args.sync
                )
            elif args.envsubcmd == "update":
                commands.service_env_update(
                    args.identifier, envvars=args.env, envfiles=args.env_file, redeploy=args.redeploy, sync=args.sync
                )
    elif args.cmd == "container":
        if args.subcmd == "exec":
            commands.container_exec(args.identifier, args.command)
        elif args.subcmd == "inspect":
            commands.container_inspect(args.identifier)
        elif args.subcmd == "logs":
            commands.container_logs(args.identifier, args.tail, args.follow)
        elif args.subcmd == "redeploy":
            commands.container_redeploy(args.identifier, args.sync)
        elif args.subcmd == "ps":
            commands.container_ps(args.quiet, args.status, args.service, args.no_trunc)
        elif args.subcmd == "start":
            commands.container_start(args.identifier, args.sync)
        elif args.subcmd == "stop":
            commands.container_stop(args.identifier, args.sync)
        elif args.subcmd == "terminate":
            commands.container_terminate(args.identifier, args.sync)
    elif args.cmd == "image":
        if args.subcmd == "list":
            commands.image_list(args.quiet, args.jumpstarts, args.private, args.user, args.all, args.no_trunc)
        elif args.subcmd == "register":
            commands.image_register(args.image_name, args.description, args.username, args.password, args.sync)
        elif args.subcmd == "push":
            commands.image_push(args.name, args.public)
        elif args.subcmd == "rm":
            commands.image_rm(args.image_name, args.sync)
        elif args.subcmd == "search":
            commands.image_search(args.query)
        elif args.subcmd == "update":
            commands.image_update(args.image_name, args.username, args.password, args.description, args.sync)
        elif args.subcmd == "inspect":
            commands.image_inspect(args.identifier)
        elif args.subcmd == "tag":
            if args.imagetagsubcmd == "list":
                commands.image_tag_list(args.jumpstarts, args.private, args.user, args.all, args.identifier)
            elif args.imagetagsubcmd == "inspect":
                commands.image_tag_inspect(args.identifier)
            elif args.imagetagsubcmd == "build":
                commands.image_tag_build(args.identifier, args.sync)
    elif args.cmd == "node":
        if args.subcmd == "inspect":
            commands.node_inspect(args.identifier)
        elif args.subcmd == "list":
            commands.node_list(args.quiet)
        elif args.subcmd == "rm":
            commands.node_rm(args.identifier, args.sync)
        elif args.subcmd == "upgrade":
            commands.node_upgrade(args.identifier, args.sync)
        elif args.subcmd == "byo":
            commands.node_byo()
    elif args.cmd == "nodecluster":
        if args.subcmd == "create":
            commands.nodecluster_create(
                args.target_num_nodes, args.name, args.provider, args.region, args.nodetype, args.sync
            )
        elif args.subcmd == "inspect":
            commands.nodecluster_inspect(args.identifier)
        elif args.subcmd == "list":
            commands.nodecluster_list(args.quiet)
        elif args.subcmd == "provider":
            commands.nodecluster_show_providers(args.quiet)
        elif args.subcmd == "region":
            commands.nodecluster_show_regions(args.provider)
        elif args.subcmd == "nodetype":
            commands.nodecluster_show_types(args.provider, args.region)
        elif args.subcmd == "rm":
            commands.nodecluster_rm(args.identifier, args.sync)
        elif args.subcmd == "az":
            commands.nodecluster_az(args.quiet)
        elif args.subcmd == "scale":
            commands.nodecluster_scale(args.identifier, args.target_num_nodes, args.sync)
        elif args.subcmd == "upgrade":
            commands.nodecluster_upgrade(args.identifier, args.sync)
    elif args.cmd == "tag":
        if args.subcmd == "add":
            commands.tag_add(args.identifier, args.tag)
        elif args.subcmd == "list":
            commands.tag_list(args.identifier, args.quiet)
        elif args.subcmd == "rm":
            commands.tag_rm(args.identifier, args.tag)
        elif args.subcmd == "set":
            commands.tag_set(args.identifier, args.tag)
    elif args.cmd == "volume":
        if args.subcmd == "list":
            commands.volume_list(args.quiet)
        if args.subcmd == "inspect":
            commands.volume_inspect(args.identifier)
    elif args.cmd == "volumegroup":
        if args.subcmd == "list":
            commands.volumegroup_list(args.quiet)
        if args.subcmd == "inspect":
            commands.volumegroup_inspect(args.identifier)
    elif args.cmd == "trigger":
        if args.subcmd == "create":
            commands.trigger_create(args.identifier, args.name, args.operation)
        elif args.subcmd == "list":
            commands.trigger_list(args.identifier, args.quiet)
        elif args.subcmd == "rm":
            commands.trigger_rm(args.identifier, args.trigger)
    elif args.cmd == "stack":
        if args.subcmd == "create":
            commands.stack_create(args.name, args.file, args.sync)
        elif args.subcmd == "inspect":
            commands.stack_inspect(args.identifier)
        elif args.subcmd == "list":
            commands.stack_list(args.quiet)
        elif args.subcmd == "redeploy":
            commands.stack_redeploy(args.identifier, args.sync)
        elif args.subcmd == "start":
            commands.stack_start(args.identifier, args.sync)
        elif args.subcmd == "stop":
            commands.stack_stop(args.identifier, args.sync)
        elif args.subcmd == "terminate":
            commands.stack_terminate(args.identifier, args.sync)
        elif args.subcmd == "up":
            commands.stack_up(args.name, args.file, args.sync)
        elif args.subcmd == "update":
            commands.stack_update(args.identifier, args.file, args.sync)
        elif args.subcmd == "export":
            commands.stack_export(args.identifier, args.file)
    elif args.cmd == "up":
        commands.stack_up(args.name, args.file, args.sync)
示例#4
0
def dispatch_cmds(args):
    if args.debug:
        requests_log = logging.getLogger("python-tutum")
        requests_log.setLevel(logging.INFO)
        cli_log = logging.getLogger("cli")
        cli_log.setLevel(logging.DEBUG)
    if args.cmd == 'login':
        commands.login(args.username, args.password, args.email)
    elif args.cmd == 'build':
        commands.build(args.tag, args.directory, args.sock)
    elif args.cmd == 'event':
        commands.event()
    elif args.cmd == 'exec':
        commands.container_exec(args.identifier, args.command)
    elif args.cmd == 'push':
        commands.image_push(args.name, args.public)
    elif args.cmd == 'run':
        commands.service_run(image=args.image, name=args.name, cpu_shares=args.cpushares,
                                 memory=args.memory, privileged=args.privileged,
                                 target_num_containers=args.target_num_containers, run_command=args.run_command,
                                 entrypoint=args.entrypoint, expose=args.expose, publish=args.publish, envvars=args.env,
                                 envfiles=args.env_file,
                                 tag=args.tag, linked_to_service=args.link_service,
                                 autorestart=args.autorestart, autodestroy=args.autodestroy,
                                 autoredeploy=args.autoredeploy, roles=args.role,
                                 sequential=args.sequential, volume=args.volume, volumes_from=args.volumes_from,
                                 deployment_strategy=args.deployment_strategy, sync=args.sync)
    elif args.cmd == 'service':
        if args.subcmd == 'create':
            commands.service_create(image=args.image, name=args.name, cpu_shares=args.cpushares,
                                    memory=args.memory, privileged=args.privileged,
                                    target_num_containers=args.target_num_containers, run_command=args.run_command,
                                    entrypoint=args.entrypoint, expose=args.expose, publish=args.publish,
                                    envvars=args.env, envfiles=args.env_file,
                                    tag=args.tag, linked_to_service=args.link_service,
                                    autorestart=args.autorestart, autodestroy=args.autodestroy,
                                    autoredeploy=args.autoredeploy, roles=args.role,
                                    sequential=args.sequential, volume=args.volume, volumes_from=args.volumes_from,
                                    deployment_strategy=args.deployment_strategy, sync=args.sync)
        elif args.subcmd == 'inspect':
            commands.service_inspect(args.identifier)
        elif args.subcmd == 'logs':
            commands.service_logs(args.identifier, args.tail, args.follow)
        elif args.subcmd == 'ps':
            commands.service_ps(args.quiet, args.status, args.stack)
        elif args.subcmd == 'redeploy':
            commands.service_redeploy(args.identifier, args.sync)
        elif args.subcmd == 'run':
            commands.service_run(image=args.image, name=args.name, cpu_shares=args.cpushares,
                                 memory=args.memory, privileged=args.privileged,
                                 target_num_containers=args.target_num_containers, run_command=args.run_command,
                                 entrypoint=args.entrypoint, expose=args.expose, publish=args.publish, envvars=args.env,
                                 envfiles=args.env_file,
                                 tag=args.tag, linked_to_service=args.link_service,
                                 autorestart=args.autorestart, autodestroy=args.autodestroy,
                                 autoredeploy=args.autoredeploy, roles=args.role,
                                 sequential=args.sequential, volume=args.volume, volumes_from=args.volumes_from,
                                 deployment_strategy=args.deployment_strategy, sync=args.sync)
        elif args.subcmd == 'scale':
            commands.service_scale(args.identifier, args.target_num_containers, args.sync)
        elif args.subcmd == 'set':
            commands.service_set(args.identifier, image=args.image, cpu_shares=args.cpushares,
                                 memory=args.memory, privileged=args.privileged,
                                 target_num_containers=args.target_num_containers, run_command=args.run_command,
                                 entrypoint=args.entrypoint, expose=args.expose, publish=args.publish, envvars=args.env,
                                 envfiles=args.env_file,
                                 tag=args.tag, linked_to_service=args.link_service,
                                 autorestart=args.autorestart, autodestroy=args.autodestroy,
                                 autoredeploy=args.autoredeploy, roles=args.role,
                                 sequential=args.sequential, redeploy=args.redeploy,
                                 volume=args.volume, volumes_from=args.volumes_from,
                                 deployment_strategy=args.deployment_strategy, sync=args.sync)
        elif args.subcmd == 'start':
            commands.service_start(args.identifier, args.sync)
        elif args.subcmd == 'stop':
            commands.service_stop(args.identifier, args.sync)
        elif args.subcmd == 'terminate':
            commands.service_terminate(args.identifier, args.sync)
    elif args.cmd == 'container':
        if args.subcmd == 'exec':
            commands.container_exec(args.identifier, args.command)
        elif args.subcmd == 'inspect':
            commands.container_inspect(args.identifier)
        elif args.subcmd == 'logs':
            commands.container_logs(args.identifier, args.tail, args.follow)
        elif args.subcmd == 'redeploy':
            commands.container_redeploy(args.identifier, args.sync)
        elif args.subcmd == 'ps':
            commands.container_ps(args.quiet, args.status, args.service, args.no_trunc)
        elif args.subcmd == 'start':
            commands.container_start(args.identifier, args.sync)
        elif args.subcmd == 'stop':
            commands.container_stop(args.identifier, args.sync)
        elif args.subcmd == 'terminate':
            commands.container_terminate(args.identifier, args.sync)
    elif args.cmd == 'image':
        if args.subcmd == 'list':
            commands.image_list(args.quiet, args.jumpstarts, args.linux)
        elif args.subcmd == 'register':
            commands.image_register(args.image_name, args.description, args.username, args.password, args.sync)
        elif args.subcmd == 'push':
            commands.image_push(args.name, args.public)
        elif args.subcmd == 'rm':
            commands.image_rm(args.image_name, args.sync)
        elif args.subcmd == 'search':
            commands.image_search(args.query)
        elif args.subcmd == 'update':
            commands.image_update(args.image_name, args.username, args.password, args.description, args.sync)
    elif args.cmd == 'node':
        if args.subcmd == 'inspect':
            commands.node_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.node_list(args.quiet)
        elif args.subcmd == 'rm':
            commands.node_rm(args.identifier, args.sync)
        elif args.subcmd == 'upgrade':
            commands.node_upgrade(args.identifier, args.sync)
        elif args.subcmd == 'byo':
            commands.node_byo()
    elif args.cmd == 'nodecluster':
        if args.subcmd == 'create':
            commands.nodecluster_create(args.target_num_nodes, args.name, args.provider, args.region, args.nodetype,
                                        args.sync)
        elif args.subcmd == 'inspect':
            commands.nodecluster_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.nodecluster_list(args.quiet)
        elif args.subcmd == 'provider':
            commands.nodecluster_show_providers(args.quiet)
        elif args.subcmd == 'region':
            commands.nodecluster_show_regions(args.provider)
        elif args.subcmd == 'nodetype':
            commands.nodecluster_show_types(args.provider, args.region)
        elif args.subcmd == 'rm':
            commands.nodecluster_rm(args.identifier, args.sync)
        elif args.subcmd == 'scale':
            commands.nodecluster_scale(args.identifier, args.target_num_nodes, args.sync)
        elif args.subcmd == 'upgrade':
            commands.nodecluster_upgrade(args.identifier, args.sync)
    elif args.cmd == 'tag':
        if args.subcmd == 'add':
            commands.tag_add(args.identifier, args.tag)
        elif args.subcmd == 'list':
            commands.tag_list(args.identifier, args.quiet)
        elif args.subcmd == 'rm':
            commands.tag_rm(args.identifier, args.tag)
        elif args.subcmd == 'set':
            commands.tag_set(args.identifier, args.tag)
    elif args.cmd == 'volume':
        if args.subcmd == 'list':
            commands.volume_list(args.quiet)
        if args.subcmd == 'inspect':
            commands.volume_inspect(args.identifier)
    elif args.cmd == 'volumegroup':
        if args.subcmd == 'list':
            commands.volumegroup_list(args.quiet)
        if args.subcmd == 'inspect':
            commands.volumegroup_inspect(args.identifier)
    elif args.cmd == 'trigger':
        if args.subcmd == 'create':
            commands.trigger_create(args.identifier, args.name, args.operation)
        elif args.subcmd == 'list':
            commands.trigger_list(args.identifier, args.quiet)
        elif args.subcmd == 'rm':
            commands.trigger_rm(args.identifier, args.trigger)
    elif args.cmd == 'stack':
        if args.subcmd == 'create':
            commands.stack_create(args.name, args.file, args.sync)
        elif args.subcmd == 'inspect':
            commands.stack_inspect(args.identifier)
        elif args.subcmd == 'list':
            commands.stack_list(args.quiet)
        elif args.subcmd == 'redeploy':
            commands.stack_redeploy(args.identifier, args.sync)
        elif args.subcmd == 'start':
            commands.stack_start(args.identifier, args.sync)
        elif args.subcmd == 'stop':
            commands.stack_stop(args.identifier, args.sync)
        elif args.subcmd == 'terminate':
            commands.stack_terminate(args.identifier, args.sync)
        elif args.subcmd == 'up':
            commands.stack_up(args.name, args.file, args.sync)
        elif args.subcmd == 'update':
            commands.stack_update(args.identifier, args.file, args.sync)
        elif args.subcmd == 'export':
            commands.stack_export(args.identifier, args.file)
    elif args.cmd == 'up':
        commands.stack_up(args.name, args.file, args.sync)