plugin_script: stop action gets hint why it is called
Upon stop action the script is called the following way: script.sh stop [$HINT] $HINT is not used if the stop is result of tuned shutdown. $HINT is set to "profile_switch" if the stop is result of profile switch. Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
parent
a2b0741eac
commit
671cd73a57
2 changed files with 15 additions and 10 deletions
|
|
@ -506,19 +506,21 @@ stop() {
|
|||
#
|
||||
|
||||
process() {
|
||||
case "$1" in
|
||||
ARG="$1"
|
||||
shift
|
||||
case "$ARG" in
|
||||
start)
|
||||
start
|
||||
start "$@"
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
stop "$@"
|
||||
RETVAL=$?
|
||||
;;
|
||||
verify)
|
||||
if declare -f verify &> /dev/null;
|
||||
then
|
||||
verify
|
||||
verify "$@"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ class ScriptPlugin(base.Plugin):
|
|||
def _instance_cleanup(self, instance):
|
||||
pass
|
||||
|
||||
def _call_scripts(self, scripts, argument):
|
||||
def _call_scripts(self, scripts, arguments):
|
||||
for script in scripts:
|
||||
environ = os.environ
|
||||
environ.update(self._variables.get_env())
|
||||
log.info("calling script '%s' with argument '%s'" % (script, argument))
|
||||
log.info("calling script '%s' with arguments '%s'" % (script, str(arguments)))
|
||||
log.debug("using environment '%s'" % str(environ.items()))
|
||||
try:
|
||||
proc = Popen([script, argument], stdout=PIPE, stderr=PIPE, close_fds=True, env=environ, \
|
||||
proc = Popen([script] + arguments, stdout=PIPE, stderr=PIPE, close_fds=True, env=environ, \
|
||||
cwd = os.path.dirname(script))
|
||||
out, err = proc.communicate()
|
||||
if proc.returncode:
|
||||
|
|
@ -50,13 +50,13 @@ class ScriptPlugin(base.Plugin):
|
|||
|
||||
def _instance_apply_static(self, instance):
|
||||
super(self.__class__, self)._instance_apply_static(instance)
|
||||
self._call_scripts(instance._scripts, "start")
|
||||
self._call_scripts(instance._scripts, ["start"])
|
||||
|
||||
def _instance_verify_static(self, instance):
|
||||
ret = True
|
||||
if super(self.__class__, self)._instance_verify_static(instance) == False:
|
||||
ret = False
|
||||
if self._call_scripts(instance._scripts, "verify") == True:
|
||||
if self._call_scripts(instance._scripts, ["verify"]) == True:
|
||||
log.info(consts.STR_VERIFY_PROFILE_OK % instance._scripts)
|
||||
else:
|
||||
log.error(consts.STR_VERIFY_PROFILE_FAIL % instance._scripts)
|
||||
|
|
@ -64,5 +64,8 @@ class ScriptPlugin(base.Plugin):
|
|||
return ret
|
||||
|
||||
def _instance_unapply_static(self, instance, profile_switch = False):
|
||||
self._call_scripts(reversed(instance._scripts), "stop")
|
||||
args = ["stop"]
|
||||
if profile_switch:
|
||||
args = args + ["profile_switch"]
|
||||
self._call_scripts(reversed(instance._scripts), args)
|
||||
super(self.__class__, self)._instance_unapply_static(instance, profile_switch)
|
||||
|
|
|
|||
Loading…
Reference in a new issue