1 from charmhelpers
.core
.hookenv
import (
7 from charms
.reactive
import (
13 import charms
.sshproxy
17 @when('sshproxy.configured')
18 @when_not('simple.installed')
19 def install_simple_proxy_charm():
20 """Post-install actions.
22 This function will run when two conditions are met:
23 1. The 'sshproxy.configured' state is set
24 2. The 'simple.installed' state is not set
26 This ensures that the workload status is set to active only when the SSH
27 proxy is properly configured.
29 set_flag('simple.installed')
30 status_set('active', 'Ready!')
33 @when('actions.touch')
35 if not in_action_context():
36 clear_flag('actions.touch')
41 filename
= action_get('filename')
42 cmd
= ['touch {}'.format(filename
)]
43 result
, err
= charms
.sshproxy
._run
(cmd
)
45 action_fail('command failed:' + err
)
47 action_set({'output': result
})
49 clear_flag('actions.touch')
52 def in_action_context():
53 """Determine whether we're running on an action context."""
54 return 'JUJU_ACTION_UUID' in os
.environ