示例#1
0
 def list_names(self, listable_type):
     list_str = '%s list %s name' % (self.call_args, listable_type)
     (options, args) = self.parser.parse_args(shlex.split(list_str))
     mgmt = Management(options, args[1:])
     uri = mgmt.list_show_uri(LISTABLE, 'list', mgmt.args[1:])
     output_json = mgmt.get(uri)
     listables = simplejson.loads(output_json)
     return listables
示例#2
0
 def declare_exchange(self, xp):
     if xp == "events":
         ex_name = self.mgmt_cfg["events_xp"]
     else:
         ex_name = self.mgmt_cfg["system_exchange"]
     cmd_str = '{0} declare exchange name="{1}" durable=false auto_delete=true type=topic'.format(
         self.call_args, ex_name)
     (options, args) = self.parser.parse_args(shlex.split(cmd_str))
     mgmt = Management(options, args[1:])
     mgmt.invoke_declare()
示例#3
0
    def bind_queue(self, xp, queue_name, binding):
        if xp == "events":
            ex_name = self.mgmt_cfg["events_xp"]
        else:
            ex_name = self.mgmt_cfg["system_exchange"]

        if queue_name.startswith(self.sysname):
            qqueue_name = queue_name
        else:
            qqueue_name = ".".join([ex_name, queue_name])

        cmd_str = '{0} declare binding source="{1}" destination="{2}" destination_type=queue routing_key="{3}"'.format(
            self.call_args, ex_name, qqueue_name, binding)
        (options, args) = self.parser.parse_args(shlex.split(cmd_str))
        mgmt = Management(options, args[1:])
        mgmt.invoke_declare()
示例#4
0
    def declare_queue(self, xp, queue_name):
        if xp == "events":
            ex_name = self.mgmt_cfg["events_xp"]
        else:
            ex_name = self.mgmt_cfg["system_exchange"]

        if queue_name.startswith(self.sysname):
            qqueue_name = queue_name
        else:
            qqueue_name = ".".join([ex_name, queue_name])

        cmd_str = '{0} declare queue name="{1}" durable=false auto_delete=false'.format(
            self.call_args, qqueue_name)
        (options, args) = self.parser.parse_args(shlex.split(cmd_str))
        mgmt = Management(options, args[1:])
        mgmt.invoke_declare()
示例#5
0
 def delete_names_with_prefix(self, deletable_type, deleteable,
                              name_prefix):
     deleted = []
     for d in deleteable:
         try:
             if d['name'].startswith(name_prefix):
                 delete_cmd = '%s delete %s name="%s"' % (
                     self.call_args, deletable_type, d['name'])
                 (options,
                  args) = self.parser.parse_args(shlex.split(delete_cmd))
                 mgmt = Management(options, args[1:])
                 mgmt.invoke_delete()
                 deleted.append(d['name'])
         except KeyError:
             # Some has no key 'name'
             pass
     return deleted