X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=tests%2Fcharms%2Flayers%2Fsimple%2Freactive%2Fsimple.py;h=af6644bdd6ae44847f319abfc348faaab173d0c0;hp=228be3c3ffaf70fb4c2829d71d90204403a937ba;hb=b2a07f566be558a8b59b8b5dedfe8da5ae1b0132;hpb=bf79352ca652b228c5c216564cc512b635e3c5e4 diff --git a/tests/charms/layers/simple/reactive/simple.py b/tests/charms/layers/simple/reactive/simple.py index 228be3c..af6644b 100644 --- a/tests/charms/layers/simple/reactive/simple.py +++ b/tests/charms/layers/simple/reactive/simple.py @@ -11,6 +11,7 @@ from charms.reactive import ( when_not, ) import charms.sshproxy +import os @when('sshproxy.configured') @@ -31,14 +32,23 @@ def install_simple_proxy_charm(): @when('actions.touch') def touch(): + if not in_action_context(): + clear_flag('actions.touch') + return + err = '' try: filename = action_get('filename') cmd = ['touch {}'.format(filename)] result, err = charms.sshproxy._run(cmd) - except: + except Exception: action_fail('command failed:' + err) else: action_set({'output': result}) finally: clear_flag('actions.touch') + + +def in_action_context(): + """Determine whether we're running on an action context.""" + return 'JUJU_ACTION_UUID' in os.environ