control error when no vhosts

This commit is contained in:
yolanda.robla@canonical.com 2014-03-03 18:58:29 +01:00
parent dd41612cfb
commit 93a83396fd
1 changed files with 11 additions and 7 deletions

View File

@ -23,13 +23,17 @@ LIB_PATH = '/var/lib/rabbitmq/'
def vhost_exists(vhost):
cmd = [RABBITMQ_CTL, 'list_vhosts']
out = subprocess.check_output(cmd)
for line in out.split('\n')[1:]:
if line == vhost:
utils.juju_log('INFO', 'vhost (%s) already exists.' % vhost)
return True
return False
try:
cmd = [RABBITMQ_CTL, 'list_vhosts']
out = subprocess.check_output(cmd)
for line in out.split('\n')[1:]:
if line == vhost:
utils.juju_log('INFO', 'vhost (%s) already exists.' % vhost)
return True
return False
except:
# if no vhosts, just raises an exception
return False
def create_vhost(vhost):