This patch adds better status messages by differentiating between
configuration settings received and the verification of ssh credentials.
Signed-off-by: Adam Israel <adam.israel@canonical.com>
remove_state as remove_flag,
set_state as set_flag,
when,
remove_state as remove_flag,
set_state as set_flag,
when,
-from subprocess import (
- Popen,
- CalledProcessError,
- PIPE,
-)
+# from subprocess import (
+# Popen,
+# CalledProcessError,
+# PIPE,
+# )
+@when('config.changed', 'sshproxy.configured')
+ """Verify the configuration.
+ Verify that the charm has been configured
+ """
+ (validated, output) = charms.sshproxy.verify_ssh_credentials()
+ if not validated:
+ status_set('blocked', 'Unable to verify SSH credentials: {}'.format(
+ output
+ ))
if all(k in cfg for k in ['mode']):
if cfg['mode'] in ['ping', 'pong']:
set_flag('pingpong.configured')
if all(k in cfg for k in ['mode']):
if cfg['mode'] in ['ping', 'pong']:
set_flag('pingpong.configured')
status_set('blocked', 'Waiting for configuration')
status_set('blocked', 'Waiting for configuration')
+@when('config.changed')
+@when_not('sshproxy.configured')
+def invalid_credentials():
+ status_set('blocked', 'Waiting for SSH credentials.')
+ pass
+
+
def is_ping():
if cfg['mode'] == 'ping':
return True
def is_ping():
if cfg['mode'] == 'ping':
return True