Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine_setup: cleanup after ARS removal #257

Merged
merged 3 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions packaging/setup/ovirt_engine_setup/engine/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,22 +234,6 @@ class FileLocations(object):
'nssdb',
)

ANSIBLE_RUNNER_SERVICE_CONF = os.path.join(
SYSCONFDIR,
'ansible-runner-service',
'config.yaml',
)

ANSIBLE_RUNNER_SERVICE_PROJECT = os.path.join(
OVIRT_ENGINE_DATADIR,
'ansible-runner-service-project',
)

ANSIBLE_RUNNER_PROJECT = os.path.join(
OVIRT_ENGINE_LOCALSTATEDIR,
'ansible-runner-project',
)

DIR_HTTPD = os.path.join(
SYSCONFDIR,
'httpd',
Expand All @@ -260,12 +244,6 @@ class FileLocations(object):
'www',
)

HTTPD_RUNNER_WSGI_SCRIPT = os.path.join(
DIR_WWW,
'runnner',
'runner.wsgi',
)

HTTPD_CONF_ANSIBLE_RUNNER_SERVICE = os.path.join(
DIR_HTTPD,
'conf.d',
Expand Down Expand Up @@ -367,8 +345,6 @@ class Defaults(object):

DEFAULT_CLEAR_TASKS_WAIT_PERIOD = 20

DEFAULT_ANSIBLE_RUNNER_SERVICE_PORT = '50001'

DEFAULT_DB_HOST = 'localhost'
DEFAULT_DB_PORT = 5432
DEFAULT_DB_DATABASE = 'engine'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from otopi import util

from . import ars_cleanup
from . import engine
from . import root

Expand All @@ -20,6 +21,7 @@
def createPlugins(context):
engine.Plugin(context=context)
root.Plugin(context=context)
ars_cleanup.Plugin(context=context)


# vim: expandtab tabstop=4 shiftwidth=4
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-service cleanup 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):
"""Apache ansible-runner-service cleanup 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