Exemple #1
0
def start_vault():
    # start or restart vault
    vault.opportunistic_restart()

    @tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=10),
                    stop=tenacity.stop_after_attempt(10),
                    retry=tenacity.retry_if_result(lambda b: not b))
    def _check_vault_running():
        return service_running('vault')

    if _check_vault_running():
        set_flag('started')
        clear_flag('failed.to.start')
        if config('totally-unsecure-auto-unlock'):
            vault.prepare_vault()
    else:
        set_flag('failed.to.start')
def file_change_auto_unlock_mode():
    log("Calling opportunistic_restart", level=DEBUG)
    vault.opportunistic_restart()
    if config('totally-unsecure-auto-unlock'):
        vault.prepare_vault()
 def test_opportunistic_restart_no_restart(self, can_restart, service_start,
                                           log):
     can_restart.return_value = False
     vault.opportunistic_restart()
     service_start.assert_called_once_with('vault')