diff --git a/wile_coyote/bin/anvil b/wile_coyote/bin/anvil index a2e0e35ba9386ce8986efdca2bacce2f38b68ce8..7c06ee3911a7bbda28bc8271d87926737342855b 100755 --- a/wile_coyote/bin/anvil +++ b/wile_coyote/bin/anvil @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python3 """Anvil, wile_coyote test tool, erases, uploads and checks certificates validity onto test instances of Vault, Redis and Consul. diff --git a/wile_coyote/bin/cert2json b/wile_coyote/bin/cert2json index 1a76da25217c1f2206ad49623a1a2aa074def853..bb55abb3949bed0aba716131ac0406d606406dce 100755 --- a/wile_coyote/bin/cert2json +++ b/wile_coyote/bin/cert2json @@ -22,7 +22,7 @@ from docopt import docopt import wile_coyote.tools -PROCESSES=6 +PROCESSES = 6 WEB_BASE = REDIS_HOST = wile_coyote.tools.WEB_BASE ARGS = docopt(__doc__) PROVIDER = ARGS['--provider'] diff --git a/wile_coyote/tools/__init__.py b/wile_coyote/tools/__init__.py index 342dac58980afa382cdf4bc84a16aeba6539af2c..94f862eac161b718fa7a15017535512532e84c86 100644 --- a/wile_coyote/tools/__init__.py +++ b/wile_coyote/tools/__init__.py @@ -12,6 +12,7 @@ for loader, module_name, is_pkg in pkgutil.walk_packages(__path__): config = configparser.RawConfigParser() config.read(wile_coyote.common.constants.CRED_CONF, encoding="utf8") + ATOMIC_MSG = 'Atomic Check: ' VAULT_HOST = config.get('acme', 'vault_host') REDIS_HOST = config.get('acme', 'redis_host') REDIS_TOKEN = config.get('acme', 'redis_token') diff --git a/wile_coyote/tools/consul_kit.py b/wile_coyote/tools/consul_kit.py index b4a9245efb7419a090105fbfab8e16d3eabcb72b..693fc03f4c8c59affa1e87436d6f11b414a1c495 100644 --- a/wile_coyote/tools/consul_kit.py +++ b/wile_coyote/tools/consul_kit.py @@ -79,6 +79,7 @@ def put(key, value, log_file, leader): def test(log_file, leader): """ Check consul connection """ + ATOMIC_CHECK = wile_coyote.tools.ATOMIC_MSG token = wile_coyote.tools.CONSUL_TOKEN rnd = ''.join([random.choice(string.ascii_letters) for _ in range(8)]) c_client = Consul(host=leader, port='443', token=token, scheme='https') @@ -86,9 +87,9 @@ def test(log_file, leader): try: _ = c_client.kv.put('do_not_delete', rnd) except Exception as err: - log.handler(f'could not write test key to {leader}: {err}', + log.handler(f'{ATOMIC_CHECK}could not write test key to {leader}: {err}', log_file, True) log.handler(wile_coyote.common.constants.GIVEUP, log_file) os._exit(1) else: - log.handler(f'successfully wrote Consul test key to {leader}', log_file) + log.handler(f'{ATOMIC_CHECK}successfully wrote Consul test key to {leader}', log_file) diff --git a/wile_coyote/tools/redis_kit.py b/wile_coyote/tools/redis_kit.py index 020e8d90dc234d669ca97c490d8605018e893756..a22cfcb17f5e3de1d2fdd44d36eb42de8552ac1a 100644 --- a/wile_coyote/tools/redis_kit.py +++ b/wile_coyote/tools/redis_kit.py @@ -54,6 +54,7 @@ def save(log_file): def test(log_file): """ Check Redis connection """ + ATOMIC_CHECK = wile_coyote.tools.ATOMIC_MSG host = wile_coyote.tools.REDIS_HOST token = wile_coyote.tools.REDIS_TOKEN rnd = ''.join([random.choice(string.ascii_letters) for _ in range(8)]) @@ -62,9 +63,9 @@ def test(log_file): try: _ = r_client.set('do_not_delete', rnd) except Exception as err: - log.handler(f'could not write test key to {host}: {err}', + log.handler(f'{ATOMIC_CHECK}could not write test key to {host}: {err}', log_file, True) log.handler('giving up...', log_file) os._exit(1) else: - log.handler(f'successfully wrote Redis test key to {host}', log_file) + log.handler(f'{ATOMIC_CHECK}successfully wrote Redis test key to {host}', log_file) diff --git a/wile_coyote/tools/vault_kit.py b/wile_coyote/tools/vault_kit.py index aa0c74f0ec7b329a0dc14a079089b4f528251555..44528108723070f81e8e444690f796afaaf7e9c7 100644 --- a/wile_coyote/tools/vault_kit.py +++ b/wile_coyote/tools/vault_kit.py @@ -79,6 +79,7 @@ def put_v2(key, value, log_file, unit='nomad', mount_point='nomad'): def test(log_file): """ Check Vault connection """ + ATOMIC_CHECK = wile_coyote.tools.ATOMIC_MSG disable_warnings(InsecureRequestWarning) # pylint: disable=E1101 host = wile_coyote.tools.VAULT_HOST token = wile_coyote.tools.config.get('acme', f'vault_token_puppet') @@ -89,9 +90,9 @@ def test(log_file): try: _ = v_client.write(key_name, value=rnd) except Exception as err: # pylint: disable=w0703 - log.handler(f'could not write key {key_name} to Vault {host}: {err}', + log.handler(f'{ATOMIC_CHECK}could not write key {key_name} to Vault {host}: {err}', log_file, True) log.handler(wile_coyote.common.constants.GIVEUP, log_file) os._exit(1) else: - log.handler(f'successfully wrote Vault test key to {host}', log_file) + log.handler(f'{ATOMIC_CHECK}successfully wrote Vault test key to {host}', log_file)