From 701cf8d2c4ac8dc7f25d8e6bd2c72b00cd3c66ed Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 22 Nov 2018 10:27:38 +0000 Subject: [PATCH] Add action to restart services Adds an action to charms to trigger a service restart. Depends-On: Ic3521c08cdaa207e1391a32e03e53b276c51b309 Change-Id: I1d509d0bc2c3fb77348edef6810fcdc30cdc9ab8 --- actions.yaml | 12 ++++++++---- actions/os_actions.py | 7 +++++++ actions/restart-services | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) create mode 120000 actions/restart-services diff --git a/actions.yaml b/actions.yaml index 4887910..9b10028 100644 --- a/actions.yaml +++ b/actions.yaml @@ -1,11 +1,15 @@ -"pause": - "description": | +pause: + description: | Pause services. If the deployment is clustered using the hacluster charm, the corresponding hacluster unit on the node must first be paused as well. Not doing so may lead to an interruption of service. -"resume": - "description": | +resume: + description: | Resume services. If the deployment is clustered using the hacluster charm, the corresponding hacluster unit on the node must be resumed as well. +restart-services: + description: | + Restart services. + Restart the services the charm manages. diff --git a/actions/os_actions.py b/actions/os_actions.py index eebab2b..b5a8bcf 100755 --- a/actions/os_actions.py +++ b/actions/os_actions.py @@ -47,11 +47,18 @@ def resume_action(*args): charm_instance._assess_status() +def restart_services(*args): + """Run the resume action.""" + with charms_openstack.charm.provide_charm_instance() as charm_instance: + charm_instance.restart_services() + + # Actions to function mapping, to allow for illegal python action names that # can map to a python function. ACTIONS = { "pause": pause_action, "resume": resume_action, + "restart-services": restart_services, } diff --git a/actions/restart-services b/actions/restart-services new file mode 120000 index 0000000..93db417 --- /dev/null +++ b/actions/restart-services @@ -0,0 +1 @@ +os_actions.py \ No newline at end of file