Exemple #1
0
def booth_cmd(lib, argv, modifiers):
    """
    routes booth command
    """
    if len(argv) < 1:
        usage.booth()
        sys.exit(1)

    sub_cmd, argv_next = argv[0], argv[1:]
    try:
        if sub_cmd == "help":
            usage.booth(argv)
        elif sub_cmd == "config":
            command.config_show(lib, argv_next, modifiers)
        elif sub_cmd == "setup":
            command.config_setup(lib, argv_next, modifiers)
        elif sub_cmd == "destroy":
            command.config_destroy(lib, argv_next, modifiers)
        elif sub_cmd == "ticket":
            if len(argv_next) < 1:
                raise CmdLineInputError()
            if argv_next[0] == "add":
                command.config_ticket_add(lib, argv_next[1:], modifiers)
            elif argv_next[0] == "remove":
                command.config_ticket_remove(lib, argv_next[1:], modifiers)
            elif argv_next[0] == "grant":
                command.ticket_grant(lib, argv_next[1:], modifiers)
            elif argv_next[0] == "revoke":
                command.ticket_revoke(lib, argv_next[1:], modifiers)
            else:
                raise CmdLineInputError()
        elif sub_cmd == "create":
            command.get_create_in_cluster(resource_create,
                                          resource_remove)(lib, argv_next,
                                                           modifiers)
        elif sub_cmd == "remove":
            command.get_remove_from_cluster(resource_remove)(lib, argv_next,
                                                             modifiers)
        elif sub_cmd == "restart":
            command.get_restart(resource_restart)(lib, argv_next, modifiers)
        elif sub_cmd == "sync":
            command.sync(lib, argv_next, modifiers)
        elif sub_cmd == "pull":
            command.pull(lib, argv_next, modifiers)
        elif sub_cmd == "enable":
            command.enable(lib, argv_next, modifiers)
        elif sub_cmd == "disable":
            command.disable(lib, argv_next, modifiers)
        elif sub_cmd == "start":
            command.start(lib, argv_next, modifiers)
        elif sub_cmd == "stop":
            command.stop(lib, argv_next, modifiers)
        elif sub_cmd == "status":
            command.status(lib, argv_next, modifiers)
        else:
            raise CmdLineInputError()
    except LibraryError as e:
        utils.process_library_reports(e.args)
    except CmdLineInputError as e:
        utils.exit_on_cmdline_input_errror(e, "booth", sub_cmd)
Exemple #2
0
def booth_cmd(lib, argv, modifiers):
    """
    routes booth command
    """
    if len(argv) < 1:
        usage.booth()
        sys.exit(1)

    sub_cmd, argv_next = argv[0], argv[1:]
    try:
        if sub_cmd == "help":
            usage.booth(argv)
        elif sub_cmd == "config":
            command.config_show(lib, argv_next, modifiers)
        elif sub_cmd == "setup":
            command.config_setup(lib, argv_next, modifiers)
        elif sub_cmd == "destroy":
            command.config_destroy(lib, argv_next, modifiers)
        elif sub_cmd == "ticket":
            if len(argv_next) < 1:
                raise CmdLineInputError()
            if argv_next[0] == "add":
                command.config_ticket_add(lib, argv_next[1:], modifiers)
            elif argv_next[0] == "remove":
                command.config_ticket_remove(lib, argv_next[1:], modifiers)
            elif argv_next[0] == "grant":
                command.ticket_grant(lib, argv_next[1:], modifiers)
            elif argv_next[0] == "revoke":
                command.ticket_revoke(lib, argv_next[1:], modifiers)
            else:
                raise CmdLineInputError()
        elif sub_cmd == "create":
            command.create_in_cluster(lib, argv_next, modifiers)
        elif sub_cmd == "remove":
            command.get_remove_from_cluster(resource_remove)(
                lib, argv_next, modifiers
            )
        elif sub_cmd == "restart":
            command.get_restart(resource_restart)(lib, argv_next, modifiers)
        elif sub_cmd == "sync":
            command.sync(lib, argv_next, modifiers)
        elif sub_cmd == "pull":
            command.pull(lib, argv_next, modifiers)
        elif sub_cmd == "enable":
            command.enable(lib, argv_next, modifiers)
        elif sub_cmd == "disable":
            command.disable(lib, argv_next, modifiers)
        elif sub_cmd == "start":
            command.start(lib, argv_next, modifiers)
        elif sub_cmd == "stop":
            command.stop(lib, argv_next, modifiers)
        elif sub_cmd == "status":
            command.status(lib, argv_next, modifiers)
        else:
            raise CmdLineInputError()
    except LibraryError as e:
        utils.process_library_reports(e.args)
    except CmdLineInputError as e:
        utils.exit_on_cmdline_input_errror(e, "booth", sub_cmd)
Exemple #3
0
 def test_lib_call_minimal(self):
     resource_restart = lambda x: x
     booth_cmd.get_restart(resource_restart)(self.lib, [],
                                             dict_to_modifiers(dict()))
     # The first arg going to the lib call is a lambda which we cannot get
     # in here. So we must check all the other parameters in a bit more
     # complicated way.
     self.assertEqual(self.lib.booth.restart.call_count, 1)
     call = self.lib.booth.restart.call_args
     self.assertEqual(call[1], dict(instance_name=None,
                                    allow_multiple=False))
Exemple #4
0
def booth_cmd(lib, argv, modifiers):
    try:
        create_router(
            {
                "help":
                lambda _lib, _argv, _modifiers: usage.booth(_argv),
                "config":
                command.config_show,
                "setup":
                command.config_setup,
                "destroy":
                command.config_destroy,
                "ticket":
                create_router(
                    {
                        "help":
                        lambda _lib, _argv, _modifiers: usage.booth(["ticket"]
                                                                    ),
                        "add":
                        command.config_ticket_add,
                        "delete":
                        command.config_ticket_remove,
                        "remove":
                        command.config_ticket_remove,
                        "grant":
                        command.ticket_grant,
                        "revoke":
                        command.ticket_revoke,
                    }, ["booth", "ticket"]),
                "create":
                command.create_in_cluster,
                "delete":
                command.get_remove_from_cluster(resource_remove),
                "remove":
                command.get_remove_from_cluster(resource_remove),
                "restart":
                command.get_restart(resource_restart),
                "sync":
                command.sync,
                "pull":
                command.pull,
                "enable":
                command.enable,
                "disable":
                command.disable,
                "start":
                command.start,
                "stop":
                command.stop,
                "status":
                command.status,
            }, ["booth"])(lib, argv, modifiers)
    except CmdLineInputError as e:
        utils.exit_on_cmdline_input_errror(e, "booth", "")
Exemple #5
0
             "add": command.config_ticket_add,
             "delete": command.config_ticket_remove,
             "remove": command.config_ticket_remove,
             "grant": command.ticket_grant,
             "revoke": command.ticket_revoke,
         },
         ["booth", "ticket"],
     ),
     "create":
     command.create_in_cluster,
     "delete":
     command.get_remove_from_cluster(resource_remove),
     "remove":
     command.get_remove_from_cluster(resource_remove),
     "restart":
     command.get_restart(resource_restart),
     "sync":
     command.sync,
     "pull":
     command.pull,
     "enable":
     command.enable,
     "disable":
     command.disable,
     "start":
     command.start,
     "stop":
     command.stop,
     "status":
     command.status,
 },
Exemple #6
0
    {
        "help": lambda lib, argv, modifiers: usage.booth(argv),
        "config": command.config_show,
        "setup": command.config_setup,
        "destroy": command.config_destroy,
        "ticket": create_router(
            {
                "help": lambda lib, argv, modifiers: usage.booth(["ticket"]),
                "add": command.config_ticket_add,
                "delete": command.config_ticket_remove,
                "remove": command.config_ticket_remove,
                "grant": command.ticket_grant,
                "revoke": command.ticket_revoke,
            },
            ["booth", "ticket"]
        ),
        "create": command.create_in_cluster,
        "delete": command.get_remove_from_cluster(resource_remove),
        "remove": command.get_remove_from_cluster(resource_remove),
        "restart": command.get_restart(resource_restart),
        "sync": command.sync,
        "pull": command.pull,
        "enable": command.enable,
        "disable": command.disable,
        "start": command.start,
        "stop": command.stop,
        "status": command.status,
    },
    ["booth"]
)