Exemple #1
0
def hammer_options(args):
    options = optparse.OptionParser(
        prog="hammer",
        usage="%prog -X EXCHANGE [options] MESSAGE [MESSAGE2 MESSAGE3 ...]",
        description="Pumps messages into an AMQP broker.")
    options.add_option("-X",
                       "--exchange",
                       action="store",
                       default="amq.fanout",
                       help="the exchange to publish on (default: %default)")
    options.add_option(
        "-n",
        "--number",
        action="store",
        type="int",
        default=1,
        help="the number of times to repeat each message (default: %default)")
    options.add_option(
        "--routing-key",
        action="store",
        default="",
        metavar="KEY",
        help="the routing key to use when sending messages (default: unset)")
    add_connection_options(options)
    return options.parse_args(args)
Exemple #2
0
def qcat_options(args):
    options = optparse.OptionParser(
        prog="qcat",
        usage="%prog -Q QUEUE [options]",
        description="Consumes and displays messages from an AMQP queue."
    )
    options.add_option("-Q", "--queue",
                       action="store",
                       help="the queue to consume from")
    options.add_option("--drain",
                       action="store_true",
                       default=False,
                       help="if set, the consume transaction will be committed at exit, removing all displayed messages from the queue permanently. Otherwise, the transaction will be rolled back at exit, allowing messages to be redelivered.")
    add_connection_options(options)
    queue_config_group = optparse.OptionGroup(
        options,
        "Broker setup options",
        "The following options allow qcat to create and bind queues. If none of them are set, qcat can only operate on pre-existing queues."
    )
    queue_config_group.add_option("--declare-queue",
                                  action="store_true",
                                  default=False,
                                  help="ensures QUEUE exists by declaring it before consuming messages")
    queue_config_group.add_option("--declare-exchange",
                                  action="store_true",
                                  default=False,
                                  help="ensures EXCHANGE exists as a TYPE exchange by declaring it before consuming messages")
    queue_config_group.add_option("--bind-queue",
                                  action="store_true",
                                  default=False,
                                  help="ensures QUEUE is bound to EXCHANGE using KEY before consuming messages")
    queue_config_group.add_option("-X", "--exchange",
                                  action="store",
                                  default="amq.direct",
                                  help="the exchange to declare or bind against (default: %default)")
    queue_config_group.add_option("-T", "--exchange-type",
                                  action="store",
                                  default="direct",
                                  metavar="TYPE",
                                  help="the exchange type to declare (default: %default)")
    queue_config_group.add_option("-D", "--durable",
                                  action="store_true",
                                  default=False,
                                  help="if set, queues and exchanges will be declared as durable")
    queue_config_group.add_option("-A", "--auto-delete",
                                  action="store_true",
                                  default=False,
                                  help="if set, queues and exchanges will be declared as auto-deleteable")
    queue_config_group.add_option("--routing-key",
                                  action="store",
                                  default="",
                                  metavar="KEY",
                                  help="the routing key to use when binding the queue to its exchange (default: unset)")
    options.add_option_group(queue_config_group)
    return options.parse_args(args)
Exemple #3
0
def purge_options(args):
    options = optparse.OptionParser(
        prog="qpurge",
        usage="%prog -Q QUEUE",
        description="Purges messages from an AMQP queue."
    )
    options.add_option("-Q", "--queue",
                       action="store",
                       help="the queue to purge")
    add_connection_options(options)
    return options.parse_args(args)
Exemple #4
0
def rmx_options(args):
    options = optparse.OptionParser(
        prog="rmx",
        usage="%prog [options] exchange1 [exchange2 exchange3...]",
        description="Removes exchanges from an AMQP broker.")
    options.add_option(
        "-u",
        "--if-unused",
        action="store_true",
        default=False,
        help="if set, the exchanges will be deleted only if they're not in use"
    )
    add_connection_options(options)
    return options.parse_args(args)
Exemple #5
0
def bindq_options(args):
    options = optparse.OptionParser(
        prog="bindq",
        usage="%prog [options] queue exchange",
        description="Binds a queue to an exchange in an AMQP broker.")
    options.add_option(
        "--routing-key",
        action="store",
        default="",
        metavar="KEY",
        help=
        "the routing key to use when binding the queue from its exchange (default: unset)"
    )
    add_connection_options(options)
    return options.parse_args(args)
Exemple #6
0
def mkq_options(args):
    options = optparse.OptionParser(
        prog="mkq",
        usage="%prog [options] queue1 [queue2 queue3...]",
        description="Declares queues in an AMQP broker.")
    options.add_option(
        "-D",
        "--durable",
        action="store_true",
        default=False,
        help=
        "if set, the created queues will be declared as durable and will survive broker restarts"
    )
    add_connection_options(options)
    return options.parse_args(args)
Exemple #7
0
def mkx_options(args):
    options = optparse.OptionParser(
        prog="mkx",
        usage="%prog [options] exchange1 [exchange2 exchange3...]",
        description="Declares exchanges in an AMQP broker.")
    options.add_option(
        "-D",
        "--durable",
        action="store_true",
        default=False,
        help=
        "if set, the created queues will be declared as durable and will survive broker restarts"
    )
    options.add_option("-T",
                       "--exchange-type",
                       action="store",
                       default="direct",
                       metavar="TYPE",
                       help="the exchange type to declare (default: %default)")
    add_connection_options(options)
    return options.parse_args(args)
Exemple #8
0
def rmq_options(args):
    options = optparse.OptionParser(
        prog="rmq",
        usage="%prog [options] queue1 [queue2 queue3...]",
        description="Removes queues from an AMQP broker.")
    options.add_option(
        "-u",
        "--if-unused",
        action="store_true",
        default=False,
        help="if set, the queues will be deleted only if they're not in use")
    options.add_option(
        "-e",
        "--if-empty",
        action="store_true",
        default=False,
        help=
        "if set, the queues will be deleted only if they hold no undelivered messages"
    )
    add_connection_options(options)
    return options.parse_args(args)