MAJOR=7
MINOR=6
DEVNAME=loop6
DEVTYPE=disk
DISKSEQ=11
  7   ˆl–Ðz¾”ªi?u2 ¸&î2Ò˜´o�þFØäYÀFlNºëÀþÂ„hMŸÁÀ¿ ?÷     #! /usr/bin/python3

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2007-2020 VMware, Inc. or its affiliates.  All rights reserved.

from __future__ import print_function

from optparse import OptionParser, TitledHelpFormatter

import base64
import copy
import json
import os
import socket
import ssl
import traceback

try:
    from signal import signal, SIGPIPE, SIG_DFL
    signal(SIGPIPE, SIG_DFL)
except ImportError:
    pass

import sys


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


if sys.version_info[0] < 2 or (sys.version_info[0] == 2 and sys.version_info[1] < 6):
    eprint("Sorry, rabbitmqadmin requires at least Python 2.6 (2.7.9 when HTTPS is enabled).")
    sys.exit(1)

if sys.version_info[0] == 2:
    from ConfigParser import ConfigParser, NoSectionError
    import httplib
    import urlparse
    from urllib import quote_plus
    from urllib import quote

    def b64(s):
        return base64.b64encode(s)
else:
    from configparser import ConfigParser, NoSectionError
    import http.client as httplib
    import urllib.parse as urlparse
    from urllib.parse import quote_plus
    from urllib.parse import quote

    def b64(s):
        return base64.b64encode(s.encode('utf-8')).decode('utf-8')

if sys.version_info[0] == 2:
    class ConnectionError(OSError):
        pass

    class ConnectionRefusedError(ConnectionError):
        pass

VERSION = '3.10.8'

LISTABLE = {'connections': {'vhost': False, 'cols': ['name', 'user', 'channels']},
            'channels':    {'vhost': False, 'cols': ['name', 'user']},
            'consumers':   {'vhost': True},
            'exchanges':   {'vhost': True,  'cols': ['name', 'type']},
            'queues':      {'vhost': True,  'cols': ['name', 'messages']},
            'bindings':    {'vhost': True,  'cols': ['source', 'destination',
                                                     'routing_key']},
            'users':       {'vhost': False},
            'vhosts':      {'vhost': False, 'cols': ['name', 'messages']},
            'permissions': {'vhost': False},
            'nodes':       {'vhost': False, 'cols': ['name', 'type', 'mem_used']},
            'parameters':  {'vhost': False, 'json': ['value']},
            'policies':    {'vhost': False, 'json': ['definition']},
            'operator_policies': {'vhost': False, 'json': ['definition']},
            'vhost_limits': {'vhost': False, 'json': ['value']}}

SHOWABLE = {'overview': {'vhost': False, 'cols': ['rabbitmq_version',
                                                  'cluster_name',
                                                  'queue_totals.messages',
                                                  'object_totals.queues']}}

PROMOTE_COLUMNS = ['vhost', 'name', 'type',
                   'source', 'destination', 'destination_type', 'routing_key']

URIS = {
    'exchange':    '/exchanges/{vhost}/{name}',
    'queue':       '/queues/{vhost}/{name}',
    'binding':     '/bindings/{vhost}/e/{source}/{destination_char}/{destination}',
    'binding_del': '/bindings/{vhost}/e/{source}/{destination_char}/{destination}/{properties_key}',
    'vhost':       '/vhosts/{name}',
    'user':        '/users/{name}',
    'permission':  '/permissions/{vhost}/{user}',
    'parameter':   '/parameters/{component}/{vhost}/{name}',
    'policy':      '/policies/{vhost}/{name}',
    'operator_policy': '/operator-policies/{vhost}/{name}',
    'vhost_limit': '/vhost-limits/{vhost}/{name}'
    }


def queue_upload_fixup(upload):
    # rabbitmq/rabbitmq-management#761
    #
    # In general, the fixup_upload argument can be used to fixup/change the
    # upload dict after all argument parsing is complete.
    #
    # This simplifies setting the queue type for a new queue by allowing the
    # user to use a queue_