Merge changes Iacd2f028,I43a6d573,Ibb6c93bb
[osm/N2VC.git] / tests / charms / layers / proxy-ci / reactive / proxy_ci.py
1 from charmhelpers.core.hookenv import (
2 action_fail,
3 action_set,
4 status_set,
5 )
6 from charms.reactive import (
7 set_flag,
8 clear_flag,
9 when_not,
10 when,
11 )
12 import charms.sshproxy
13
14
15 @when_not('proxy-ci.installed')
16 def install_proxy_ci():
17 status_set('blocked', "Waiting for SSH credentials.")
18 set_flag('proxy-ci.installed')
19
20
21 @when('actions.test', 'proxy-ci.installed')
22 def test():
23 err = ''
24 try:
25 cmd = ['hostname']
26 result, err = charms.sshproxy._run(cmd)
27 if len(result) == 0:
28 raise Exception("Proxy failed")
29 except Exception as e:
30 action_fail('command failed: {}'.format(e))
31 else:
32 action_set({'output': result})
33 finally:
34 clear_flag('actions.test')