1 # Copyright 2019 Canonical Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from charmhelpers
.core
.hookenv
import (
21 from charms
.reactive
import (
27 import charms
.sshproxy
30 @when('sshproxy.configured')
31 @when_not('simple.installed')
32 def install_simple_proxy_charm():
33 """Post-install actions.
35 This function will run when two conditions are met:
36 1. The 'sshproxy.configured' state is set
37 2. The 'simple.installed' state is not set
39 This ensures that the workload status is set to active only when the SSH
40 proxy is properly configured.
42 set_flag('simple.installed')
43 status_set('active', 'Ready!')
46 @when('actions.touch')
48 raise Exception("I am broken.")
51 filename
= action_get('filename')
52 cmd
= ['touch {}'.format(filename
)]
53 result
, err
= charms
.sshproxy
._run
(cmd
)
55 action_fail('command failed:' + err
)
57 action_set({'output': result
})
59 clear_flag('actions.touch')