-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/apache/runner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# | ||
# ovirt-engine-setup -- ovirt engine setup | ||
# | ||
# Copyright oVirt Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# | ||
|
||
|
||
"""Apache ansible-runner plugin.""" | ||
|
||
|
||
import gettext | ||
import os | ||
|
||
from otopi import constants as otopicons | ||
from otopi import plugin | ||
from otopi import util | ||
|
||
from ovirt_engine_setup import constants as osetupcons | ||
from ovirt_engine_setup.engine import constants as oenginecons | ||
from ovirt_engine_setup.engine_common import constants as oengcommcons | ||
from ovirt_engine_setup.transactions import RemoveFileTransaction | ||
|
||
|
||
def _(m): | ||
return gettext.dgettext(message=m, domain='ovirt-engine-setup') | ||
|
||
|
||
@util.export | ||
class Plugin(plugin.PluginBase): | ||
"""Cleanup of the ansible-runner plugin.""" | ||
|
||
def __init__(self, context): | ||
super(Plugin, self).__init__(context=context) | ||
|
||
@plugin.event( | ||
stage=plugin.Stages.STAGE_MISC, | ||
condition=lambda self: self.environment[ | ||
oenginecons.CoreEnv.ENABLE | ||
] and not self.environment[ | ||
osetupcons.CoreEnv.DEVELOPER_MODE | ||
] and os.path.exists( | ||
oenginecons.FileLocations.HTTPD_CONF_ANSIBLE_RUNNER_SERVICE | ||
), | ||
) | ||
def _misc(self): | ||
if not self._can_remove( | ||
oenginecons.FileLocations.HTTPD_CONF_ANSIBLE_RUNNER_SERVICE | ||
): | ||
return | ||
|
||
self.environment[oengcommcons.ApacheEnv.NEED_RESTART] = True | ||
|
||
self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append( | ||
RemoveFileTransaction( | ||
oenginecons.FileLocations.HTTPD_CONF_ANSIBLE_RUNNER_SERVICE | ||
) | ||
) | ||
|
||
def _can_remove(self, installed_file): | ||
""" | ||
Return True if installed_file can be removed safely. Return False if | ||
the file was not installed by previous setup, or was changed. | ||
""" | ||
uninstall_info = self.environment[ | ||
osetupcons.CoreEnv.UNINSTALL_FILES_INFO | ||
].get(installed_file) | ||
|
||
# Did we install this file? | ||
if not uninstall_info: | ||
return False | ||
|
||
# Did it change since we installed it? | ||
if uninstall_info.get("changed"): | ||
self.logger.warn( | ||
_( | ||
"Cannot remove {}, file was changed" | ||
).format(installed_file) | ||
) | ||
return False | ||
|
||
return True | ||
|
||
|
||
# vim: expandtab tabstop=4 shiftwidth=4 |