blob: 2b26212b9b1a4e6c55c024b16144f55e0ba7c2a3 [file] [log] [blame]
Adam Israela2a2d892017-03-30 21:39:26 -04001from charmhelpers.core.hookenv import (
2 action_fail,
3 action_set,
4)
5
6from charms.reactive import (
7 when,
8 remove_state as remove_flag,
9)
10import charms.sshproxy
11
12
13@when('actions.reboot')
14def reboot():
15 err = ''
16 try:
17 result, err = charms.sshproxy._run("reboot")
18 except:
19 action_fail('command failed:' + err)
20 else:
21 action_set({'outout': result})
22 finally:
23 remove_flag('actions.reboot')
24
25
26###############################################################################
27# Below is an example implementation of the start/stop/restart actions. #
28# To use this, copy the below code into your layer and add the appropriate #
29# command(s) necessary to perform the action. #
30###############################################################################
31
32# @when('actions.start')
33# def start():
34# err = ''
35# try:
36# cmd = "service myname start"
37# result, err = charms.sshproxy._run(cmd)
38# except:
39# action_fail('command failed:' + err)
40# else:
41# action_set({'outout': result})
42# finally:
43# remove_flag('actions.start')
44#
45#
46# @when('actions.stop')
47# def stop():
48# err = ''
49# try:
50# # Enter the command to stop your service(s)
51# cmd = "service myname stop"
52# result, err = charms.sshproxy._run(cmd)
53# except:
54# action_fail('command failed:' + err)
55# else:
56# action_set({'outout': result})
57# finally:
58# remove_flag('actions.stop')
59#
60#
61# @when('actions.restart')
62# def restart():
63# err = ''
64# try:
65# # Enter the command to restart your service(s)
66# cmd = "service myname restart"
67# result, err = charms.sshproxy._run(cmd)
68# except:
69# action_fail('command failed:' + err)
70# else:
71# action_set({'outout': result})
72# finally:
73# remove_flag('actions.restart')
74#
75#