X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=charms%2Flayers%2Fvnfproxy%2Freactive%2Fvnfproxy.py;fp=charms%2Flayers%2Fvnfproxy%2Freactive%2Fvnfproxy.py;h=2b26212b9b1a4e6c55c024b16144f55e0ba7c2a3;hb=a2a2d89587a21693f398ce77f8c049805150c368;hp=0000000000000000000000000000000000000000;hpb=d3bbe5cc32a34e4eb19df3337cd68efd3fd43866;p=osm%2FSO.git diff --git a/charms/layers/vnfproxy/reactive/vnfproxy.py b/charms/layers/vnfproxy/reactive/vnfproxy.py new file mode 100644 index 00000000..2b26212b --- /dev/null +++ b/charms/layers/vnfproxy/reactive/vnfproxy.py @@ -0,0 +1,75 @@ +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') +# +#