Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: setup: Add --reconfigure-optional-components ......................................................................
packaging: setup: Add --reconfigure-optional-components Change-Id: I4df3dd4f1966c30b42c9dd32d2df85a8b7cad387 Bug-Url: https://bugzilla.redhat.com/1072360 Signed-off-by: Yedidyah Bar David <[email protected]> --- M packaging/setup/bin/ovirt-engine-setup M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-common/base/core/__init__.py A packaging/setup/plugins/ovirt-engine-common/base/core/reconfigure.py 4 files changed, 108 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/35319/1 diff --git a/packaging/setup/bin/ovirt-engine-setup b/packaging/setup/bin/ovirt-engine-setup index 52b100a..30e13a5 100755 --- a/packaging/setup/bin/ovirt-engine-setup +++ b/packaging/setup/bin/ovirt-engine-setup @@ -29,6 +29,8 @@ Offline mode. --generate-answer=file Generate answer file. + --reconfigure-optional-components + Ask again about components that were disabled in previous run. --jboss-home=dir Use this jboss. @@ -69,6 +71,9 @@ --offline) environment="${environment} OVESETUP_CORE/offlinePackager=bool:True PACKAGER/yumpackagerEnabled=bool:False" ;; + --reconfigure-optional-components) + environment="${environment} OVESETUP_CORE/reconfigureOptionalComponents=bool:True" + ;; --help) usage ;; diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index 7e38d82..04b336b 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -48,6 +48,7 @@ summary=False, description=None, postinstallfile=False, + reconfigurable=False, answerfile_condition=lambda env: True, summary_condition=lambda env: True, ): @@ -59,6 +60,7 @@ summary=summary, description=description, postinstallfile=postinstallfile, + reconfigurable=reconfigurable, answerfile_condition=answerfile_condition, summary_condition=summary_condition, ) @@ -286,6 +288,9 @@ REMOTE_ENGINE = 'OVESETUP_CORE/remoteEngine' + RECONFIGURE_OPTIONAL_COMPONENTS = \ + 'OVESETUP_CORE/reconfigureOptionalComponents' + @util.export @util.codegen diff --git a/packaging/setup/plugins/ovirt-engine-common/base/core/__init__.py b/packaging/setup/plugins/ovirt-engine-common/base/core/__init__.py index 259ed5e..4b9273a 100644 --- a/packaging/setup/plugins/ovirt-engine-common/base/core/__init__.py +++ b/packaging/setup/plugins/ovirt-engine-common/base/core/__init__.py @@ -16,7 +16,7 @@ # -"""ovirt-host-remove core plugin.""" +"""base core plugin.""" from otopi import util @@ -27,6 +27,7 @@ from . import answerfile from . import uninstall from . import postinstall +from . import reconfigure @util.export @@ -36,6 +37,7 @@ answerfile.Plugin(context=context) uninstall.Plugin(context=context) postinstall.Plugin(context=context) + reconfigure.Plugin(context=context) # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-common/base/core/reconfigure.py b/packaging/setup/plugins/ovirt-engine-common/base/core/reconfigure.py new file mode 100644 index 0000000..d881b36 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-common/base/core/reconfigure.py @@ -0,0 +1,95 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2014 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +"""Reconfigure env plugin.""" + + +import os +import datetime +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import common +from otopi import plugin +from otopi import constants as otopicons + + +from ovirt_engine_setup import constants as osetupcons + + [email protected] +class Plugin(plugin.PluginBase): + """Reconfigure env plugin.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + after=( + otopicons.Stages.CORE_CONFIG_INIT, + ), + ) + def _init(self): + self.environment.setdefault( + osetupcons.CoreEnv.RECONFIGURE_OPTIONAL_COMPONENTS, + None + ) + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + before=( + osetupcons.Stages.DIALOG_TITLES_S_PRODUCT_OPTIONS, + ), + ) + def _customization(self): + if self.environment[ + osetupcons.CoreEnv.RECONFIGURE_OPTIONAL_COMPONENTS + ]: + consts = [] + for constobj in self.environment[ + osetupcons.CoreEnv.SETUP_ATTRS_MODULES + ]: + consts.extend(constobj.__dict__['__osetup_attrs__']) + for c in consts: + for k in c.__dict__.values(): + if ( + hasattr(k, '__osetup_attrs__') and + k.__osetup_attrs__['reconfigurable'] + ): + k = k.fget(None) + if ( + k in self.environment and + # We reset it only if it's disabled. + # Can't currently use this code to + # disable already-enabled components. + not self.environment[k] + ): + self.logger.debug( + 'Resetting optional component env key {key} ' + 'old value was {val}'.format( + key=k, + val=self.environment[k], + ) + ) + self.environment[k] = None + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/35319 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4df3dd4f1966c30b42c9dd32d2df85a8b7cad387 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yedidyah Bar David <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
