def configure_nodename():
    '''Set RABBITMQ_NODENAME to something that's resolvable by my peers'''
    nodename = rabbit.get_local_nodename()
    log('configuring nodename', level=INFO)
    if (nodename and
            rabbit.get_node_name() != 'rabbit@%s' % nodename):
        log('forcing nodename=%s' % nodename, level=INFO)
        # would like to have used the restart_on_change decorator, but
        # need to stop it under current nodename prior to updating env
        log('Stopping rabbitmq-server.')
        service_stop('rabbitmq-server')
        rabbit.update_rmq_env_conf(hostname='rabbit@%s' % nodename,
                                   ipv6=config('prefer-ipv6'))
        log('Starting rabbitmq-server.')
        service_restart('rabbitmq-server')
        rabbit.wait_app()
def update_cookie(leaders_cookie=None):
    # sync cookie
    if leaders_cookie:
        cookie = leaders_cookie
    else:
        cookie = peer_retrieve('cookie')
    cookie_local = None
    with open(rabbit.COOKIE_PATH, 'r') as f:
        cookie_local = f.read().strip()

    if cookie_local == cookie:
        log('Cookie already synchronized with peer.')
        return

    service_stop('rabbitmq-server')
    with open(rabbit.COOKIE_PATH, 'wb') as out:
        out.write(cookie)
    service_restart('rabbitmq-server')
    rabbit.wait_app()
Example #3
0
def update_cookie(leaders_cookie=None):
    # sync cookie
    if leaders_cookie:
        cookie = leaders_cookie
    else:
        cookie = peer_retrieve('cookie')
    cookie_local = None
    with open(rabbit.COOKIE_PATH, 'r') as f:
        cookie_local = f.read().strip()

    if cookie_local == cookie:
        log('Cookie already synchronized with peer.')
        return

    service_stop('rabbitmq-server')
    with open(rabbit.COOKIE_PATH, 'wb') as out:
        out.write(cookie)
    if not is_unit_paused_set():
        service_restart('rabbitmq-server')
        rabbit.wait_app()
def update_cookie(leaders_cookie=None):
    # sync cookie
    if leaders_cookie:
        cookie = leaders_cookie
    else:
        cookie = peer_retrieve('cookie')
    cookie_local = None
    with open(rabbit.COOKIE_PATH, 'r') as f:
        cookie_local = f.read().strip()

    if cookie_local == cookie:
        log('Cookie already synchronized with peer.')
        return
    elif not is_restart_permitted():
        raise Exception("rabbitmq-server must be restarted but not permitted")

    service_stop('rabbitmq-server')
    with open(rabbit.COOKIE_PATH, 'wb') as out:
        out.write(cookie.encode('ascii'))
    if not is_unit_paused_set():
        service_restart('rabbitmq-server')
        rabbit.wait_app()
Example #5
0
 def test_rabbitmqctl_wait_success(self, check_call):
     check_call.return_value = 0
     self.assertTrue(rabbit_utils.wait_app())
Example #6
0
 def test_rabbitmqctl_wait_fail(self, check_call):
     check_call.side_effect = (rabbit_utils.subprocess.CalledProcessError(
         1, 'cmd'))
     with self.assertRaises(rabbit_utils.subprocess.CalledProcessError):
         rabbit_utils.wait_app()
 def test_rabbitmqctl_wait_success(self, check_call):
     check_call.return_value = 0
     self.assertTrue(rabbit_utils.wait_app())
 def test_rabbitmqctl_wait_fail(self, check_call):
     check_call.side_effect = (rabbit_utils.subprocess.
                               CalledProcessError(1, 'cmd'))
     with self.assertRaises(rabbit_utils.subprocess.CalledProcessError):
         rabbit_utils.wait_app()
 def test_rabbitmqctl_wait_success(self, check_call, local_nodename):
     check_call.return_value = 0
     local_nodename.return_value = 'rabbitmq-server-0'
     self.assertTrue(rabbit_utils.wait_app())
 def test_rabbitmqctl_wait_fail(self, check_call, local_nodename):
     check_call.side_effect = (rabbit_utils.subprocess.CalledProcessError(
         1, 'cmd'))
     local_nodename.return_value = 'rabbitmq-server-0'
     with self.assertRaises(rabbit_utils.subprocess.CalledProcessError):
         rabbit_utils.wait_app()