blob: 17bf5f4bb5fa373e0794ee82675dd8afe240f196 [file] [log] [blame]
Adam Israel5e08a0e2018-09-06 19:22:47 -04001from charmhelpers.core.hookenv import (
2 action_fail,
3 action_set,
4 action_get,
5 status_set,
6)
7from charms.reactive import (
8 clear_flag,
9 set_flag,
10 when,
11 when_not,
12)
13
14
15@when_not('native-ci.installed')
16def install_native_ci_charm():
17 set_flag('native-ci.installed')
18 status_set('active', 'Ready!')
19
20
21@when('actions.test', 'native-ci.installed')
22def test():
23 try:
24 result = True
25 except Exception as e:
26 action_fail('command failed: {}'.format(e))
27 else:
28 action_set({'output': result})
29 finally:
30 clear_flag('actions.test')
31
32
33@when('actions.testint', 'native-ci.installed')
34def testint():
35 try:
36 # Test the value is an int by performing a mathmatical operation on it.
37 intval = action_get('intval')
38 intval = intval + 1
39 except Exception as e:
40 action_fail('command failed: {}'.format(e))
41 else:
42 action_set({'output': intval})
43 finally:
44 clear_flag('actions.testint')