Fix 1015. Remove non used paramiko dependencies at k8s_helm_conn
[osm/N2VC.git] / tests / charms / layers / broken / reactive / simple.py
1 # Copyright 2019 Canonical Ltd.
2 #
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
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 from charmhelpers.core.hookenv import (
16 action_get,
17 action_fail,
18 action_set,
19 status_set,
20 )
21 from charms.reactive import (
22 clear_flag,
23 set_flag,
24 when,
25 when_not,
26 )
27 import charms.sshproxy
28
29
30 @when('sshproxy.configured')
31 @when_not('simple.installed')
32 def install_simple_proxy_charm():
33 """Post-install actions.
34
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
38
39 This ensures that the workload status is set to active only when the SSH
40 proxy is properly configured.
41 """
42 set_flag('simple.installed')
43 status_set('active', 'Ready!')
44
45
46 @when('actions.touch')
47 def touch():
48 raise Exception("I am broken.")
49 err = ''
50 try:
51 filename = action_get('filename')
52 cmd = ['touch {}'.format(filename)]
53 result, err = charms.sshproxy._run(cmd)
54 except Exception:
55 action_fail('command failed:' + err)
56 else:
57 action_set({'output': result})
58 finally:
59 clear_flag('actions.touch')