X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=tests%2Fcharms%2Flayers%2Fproxy-ci%2Freactive%2Fproxy_ci.py;fp=tests%2Fcharms%2Flayers%2Fproxy-ci%2Freactive%2Fproxy_ci.py;h=30e4eea3036ea1fe30afff829eab0f130c772f06;hp=0000000000000000000000000000000000000000;hb=5e08a0e8fa4fd9d0156d28f8f4e53e5b176c704a;hpb=427f57893cb4bf8aebc0b6f56d0cb3f178d23cf1 diff --git a/tests/charms/layers/proxy-ci/reactive/proxy_ci.py b/tests/charms/layers/proxy-ci/reactive/proxy_ci.py new file mode 100644 index 0000000..30e4eea --- /dev/null +++ b/tests/charms/layers/proxy-ci/reactive/proxy_ci.py @@ -0,0 +1,34 @@ +from charmhelpers.core.hookenv import ( + action_fail, + action_set, + status_set, +) +from charms.reactive import ( + set_flag, + clear_flag, + when_not, + when, +) +import charms.sshproxy + + +@when_not('proxy-ci.installed') +def install_metrics_ci(): + status_set('blocked', "Waiting for SSH credentials.") + set_flag('proxy-ci.installed') + + +@when('actions.test', 'proxy-ci.installed') +def test(): + err = '' + try: + cmd = ['hostname'] + result, err = charms.sshproxy._run(cmd) + if len(result) == 0: + raise Exception("Proxy failed") + except Exception as e: + action_fail('command failed: {}'.format(e)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.test')