Import of core OSM charm layers
[osm/SO.git] / charms / layers / vnfproxy / reactive / vnfproxy.py
diff --git a/charms/layers/vnfproxy/reactive/vnfproxy.py b/charms/layers/vnfproxy/reactive/vnfproxy.py
new file mode 100644 (file)
index 0000000..2b26212
--- /dev/null
@@ -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')
+#
+#