Frank Kobzik has uploaded a new change for review. Change subject: packaging: setup: create osinfo windows product keys from db ......................................................................
packaging: setup: create osinfo windows product keys from db This patch introduces a script that pulls ProductKey* values from db to osinfo repository on engine-setup (as the db values are no longer used). Change-Id: I876894e7ba5fcd28ee0d435b4a2561f662140174 Bug-Url: https://bugzilla.redhat.com/1012330 Signed-off-by: Frantisek Kobzik <fkob...@redhat.com> --- M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-setup/config/__init__.py A packaging/setup/plugins/ovirt-engine-setup/config/productkey_upgrade.py 3 files changed, 101 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/20112/1 diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index 50fb6cf..8726775 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -76,6 +76,10 @@ OVIRT_ENGINE_WEBSOCKET_PROXY_CONFIG = config.ENGINE_WEBSOCKET_PROXY_CONFIG OVIRT_ENGINE_NOTIFIER_SERVICE_CONFIG = \ config.ENGINE_NOTIFIER_SERVICE_CONFIG + OVIRT_ENGINE_OSINFO_REPOSITORY_DIR = os.path.join( + OVIRT_ENGINE_SYSCONFDIR, + 'osinfo.conf.d', + ) OVIRT_ENGINE_BINDIR = os.path.join( OVIRT_ENGINE_DATADIR, @@ -435,6 +439,11 @@ '20-setup-aio.conf' ) + EXTRACTED_PRODUCTKEYS = os.path.join( + OVIRT_ENGINE_OSINFO_REPOSITORY_DIR, + '10-productkeys.properties', + ) + @util.export class Defaults(object): diff --git a/packaging/setup/plugins/ovirt-engine-setup/config/__init__.py b/packaging/setup/plugins/ovirt-engine-setup/config/__init__.py index 52d499b..4eb1f37 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/config/__init__.py +++ b/packaging/setup/plugins/ovirt-engine-setup/config/__init__.py @@ -35,6 +35,7 @@ from . import iso_domain from . import macrange from . import websocket_proxy +from . import productkey_upgrade @util.export @@ -52,6 +53,7 @@ iso_domain.Plugin(context=context) macrange.Plugin(context=context) websocket_proxy.Plugin(context=context) + productkey_upgrade.Plugin(context=context) # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-setup/config/productkey_upgrade.py b/packaging/setup/plugins/ovirt-engine-setup/config/productkey_upgrade.py new file mode 100644 index 0000000..641ca0b --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/config/productkey_upgrade.py @@ -0,0 +1,90 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2013 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. +# + + +"""Product key plugin.""" + +import os +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import constants as otopicons +from otopi import util +from otopi import filetransaction +from otopi import plugin + + +from ovirt_engine_setup import constants as osetupcons + + +@util.export +class Plugin(plugin.PluginBase): + """Product key plugin.""" + + DB_TO_OSINFO = { + 'ProductKey2003': 'windows_2003', + 'ProductKey2003x64': 'windows_2003x64', + 'ProductKey2008': 'windows_2008', + 'ProductKey2008R2': 'windows_2008R2x64', + 'ProductKey2008x64': 'windows_2008x64', + 'ProductKey': 'windows_xp', + 'ProductKeyWindow7': 'windows_7', + 'ProductKeyWindow7x64': 'windows_7x64', + 'ProductKeyWindows8': 'windows_8', + 'ProductKeyWindows8x64': 'windows_8x64', + 'ProductKeyWindows2012x64': 'windows_2012x64', + } + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + after=( + osetupcons.Stages.DB_CONNECTION_AVAILABLE, + ), + condition=lambda self: not os.path.exists( + osetupcons.FileLocations.EXTRACTED_PRODUCTKEYS + ), + ) + def _misc(self): + content = [] + for key in self.DB_TO_OSINFO.keys(): + val = self.environment[ + osetupcons.DBEnv.STATEMENT + ].getVdcOption(key) + if val: + content.append( + 'os.%s.productKey.value=%s' % ( + self.DB_TO_OSINFO[key], + val, + ) + ) + + if content: + self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append( + filetransaction.FileTransaction( + name=osetupcons.FileLocations.EXTRACTED_PRODUCTKEYS, + content=content, + modifiedList=self.environment[ + otopicons.CoreEnv.MODIFIED_FILES + ], + ) + ) + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/20112 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I876894e7ba5fcd28ee0d435b4a2561f662140174 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Frank Kobzik <fkob...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches