示例#1
0
def _restart_zookeeper(msg):
    '''
    Restart Zookeeper by re-running the puppet scripts.

    '''
    hookenv.status_set('maintenance', msg)
    zookeeper = Zookeeper()
    zookeeper.install()
    hookenv.status_set('active', 'ready {}'.format(zookeeper.quorum_check()))
示例#2
0
def _restart_zookeeper(msg):
    '''
    Restart Zookeeper by re-running the puppet scripts.

    '''
    hookenv.status_set('maintenance', msg)
    zookeeper = Zookeeper()
    zookeeper.install()
    hookenv.status_set('active', 'ready {}'.format(zookeeper.quorum_check()))
def autostart_service():
    '''
    Attempt to restart the service if it is not running.

    '''
    zookeeper = Zookeeper()
    if zookeeper.is_running():
        hookenv.status_set('active',
                           'ready {}'.format(zookeeper.quorum_check()))
        return

    for i in range(3):
        hookenv.status_set('maintenance',
                           'attempting to restart zookeeper, '
                           'attempt: {}'.format(i+1))
        zookeeper.restart()
        if zookeeper.is_running():
            hookenv.status_set('active',
                               'ready {}'.format(zookeeper.quorum_check()))
            return

    hookenv.status_set('blocked', 'failed to start zookeeper; check syslog')
示例#4
0
def install_zookeeper():
    '''
    After Bigtop has done the initial setup, trigger a puppet install,
    via our Zooekeeper library.

    puppet will start the service, as a side effect.

    '''
    hookenv.status_set('maintenance', 'installing zookeeper')
    zookeeper = Zookeeper()
    # Prime data changed
    data_changed('zkpeer.nodes', zookeeper.read_peers())
    data_changed('zk.network_interface',
                 hookenv.config().get('network_interface'))
    zookeeper.install()
    zookeeper.open_ports()
    set_state('zookeeper.installed')
    set_state('zookeeper.started')
    hookenv.status_set('active', 'ready {}'.format(zookeeper.quorum_check()))
示例#5
0
def install_zookeeper():
    '''
    After Bigtop has done the initial setup, trigger a puppet install,
    via our Zooekeeper library.

    puppet will start the service, as a side effect.

    '''
    hookenv.status_set('maintenance', 'installing zookeeper')
    zookeeper = Zookeeper()
    # Prime data changed
    data_changed('zkpeer.nodes', zookeeper.read_peers())
    data_changed(
        'zk.network_interface',
        hookenv.config().get('network_interface'))
    zookeeper.install()
    zookeeper.open_ports()
    set_state('zookeeper.installed')
    set_state('zookeeper.started')
    hookenv.status_set('active', 'ready {}'.format(zookeeper.quorum_check()))
def configure():
    cfg = hookenv.config()
    zookeeper = Zookeeper()
    changed = any((
        data_changed('zkpeer.nodes', zookeeper.read_peers()),
        data_changed('zk.autopurge_purge_interval',
                     cfg.get('autopurge_purge_interval')),
        data_changed('zk.autopurge_snap_retain_count',
                     cfg.get('autopurge_snap_retain_count')),
        data_changed('zk.storage.data_dir',
                     unitdata.kv().get('zookeeper.storage.data_dir')),
    ))
    if changed or is_flag_set('zookeeper.force-reconfigure'):
        zookeeper.install()
        zookeeper.open_ports()
    clear_flag('zookeeper.force-reconfigure')
    set_flag('zookeeper.started')
    set_flag('zookeeper.configured')
    hookenv.status_set('active', 'ready {}'.format(zookeeper.quorum_check()))
    # set app version string for juju status output
    zoo_version = get_installed_version(SNAP_NAME) or 'unknown'
    hookenv.application_version_set(zoo_version)