~thedac/charms/trusty/rabbitmq-server/backport-cluster-race-fixes

« back to all changes in this revision

Viewing changes to hooks/rabbit_utils.py

  • Committer: james.page at ubuntu
  • Date: 2015-03-26 13:07:43 UTC
  • mfrom: (82.2.3 rabbitmq-server)
  • Revision ID: james.page@ubuntu.com-20150326130743-opg59sdo60s2lx6j
Merge in trunk charm changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
    Returns a list of all the available vhosts
81
81
    """
82
82
    try:
83
 
        output = subprocess.check_output([RABBITMQ_CTL, 'list_vhosts', '-q'])
 
83
        output = subprocess.check_output([RABBITMQ_CTL, 'list_vhosts'])
84
84
 
85
 
        return output.rstrip().split('\n')
 
85
        # NOTE(jamespage): Earlier rabbitmqctl versions append "...done"
 
86
        #                  to the output of list_vhosts
 
87
        if '...done' in output:
 
88
            return output.split('\n')[1:-2]
 
89
        else:
 
90
            return output.split('\n')[1:-1]
86
91
    except Exception as ex:
87
92
        # if no vhosts, just raises an exception
88
93
        log(str(ex), level='DEBUG')
102
107
 
103
108
 
104
109
def user_exists(user):
105
 
    cmd = [RABBITMQ_CTL, 'list_users', '-q']
 
110
    cmd = [RABBITMQ_CTL, 'list_users']
106
111
    out = subprocess.check_output(cmd)
107
 
    for line in out.rstrip().split('\n'):
 
112
    for line in out.split('\n')[1:]:
108
113
        _user = line.split('\t')[0]
109
114
        if _user == user:
110
115
            admin = line.split('\t')[1]
570
575
        if svcs:
571
576
            _map.append((f, svcs))
572
577
    return OrderedDict(_map)
 
578
 
 
579
 
 
580
def services():
 
581
    ''' Returns a list of services associate with this charm '''
 
582
    _services = []
 
583
    for v in restart_map().values():
 
584
        _services = _services + v
 
585
    return list(set(_services))