blob: 2b26212b9b1a4e6c55c024b16144f55e0ba7c2a3 [file] [log] [blame]
from charmhelpers.core.hookenv import (
action_fail,
action_set,
)
from charms.reactive import (
when,
remove_state as remove_flag,
)
import charms.sshproxy
@when('actions.reboot')
def reboot():
err = ''
try:
result, err = charms.sshproxy._run("reboot")
except:
action_fail('command failed:' + err)
else:
action_set({'outout': result})
finally:
remove_flag('actions.reboot')
###############################################################################
# Below is an example implementation of the start/stop/restart actions. #
# To use this, copy the below code into your layer and add the appropriate #
# command(s) necessary to perform the action. #
###############################################################################
# @when('actions.start')
# def start():
# err = ''
# try:
# cmd = "service myname start"
# result, err = charms.sshproxy._run(cmd)
# except:
# action_fail('command failed:' + err)
# else:
# action_set({'outout': result})
# finally:
# remove_flag('actions.start')
#
#
# @when('actions.stop')
# def stop():
# err = ''
# try:
# # Enter the command to stop your service(s)
# cmd = "service myname stop"
# result, err = charms.sshproxy._run(cmd)
# except:
# action_fail('command failed:' + err)
# else:
# action_set({'outout': result})
# finally:
# remove_flag('actions.stop')
#
#
# @when('actions.restart')
# def restart():
# err = ''
# try:
# # Enter the command to restart your service(s)
# cmd = "service myname restart"
# result, err = charms.sshproxy._run(cmd)
# except:
# action_fail('command failed:' + err)
# else:
# action_set({'outout': result})
# finally:
# remove_flag('actions.restart')
#
#