Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: osinfo: move sysprep defaults out of /etc ......................................................................
packaging: osinfo: move sysprep defaults out of /etc when moved to using conf.d structure, there is no reason why storing sysprep files in /etc as user can install his own osinfo config and overwrite product defaults reference with his own. this simplifies pushing product changes without the rpmsave/rpmnew hell and enables support to understand site customization. upgrade is comparing current install sysprep files and keep these that are different from product default at existing location, creating osinfo configuration for these. the move to osinfo neglected the ability of user to specify different setting for sysprep in database, we also fix that. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1030500 Change-Id: I26a853c12ca091f340d6ebed2c10726462ec576a Signed-off-by: Alon Bar-Lev <alo...@redhat.com> --- M ovirt-engine.spec.in M packaging/conf/osinfo-defaults.properties R packaging/conf/sysprep/sysprep.2k12x64 R packaging/conf/sysprep/sysprep.2k3 R packaging/conf/sysprep/sysprep.2k8 R packaging/conf/sysprep/sysprep.2k8x64 R packaging/conf/sysprep/sysprep.w7 R packaging/conf/sysprep/sysprep.w7x64 R packaging/conf/sysprep/sysprep.w8 R packaging/conf/sysprep/sysprep.w8x64 R packaging/conf/sysprep/sysprep.xp M packaging/setup/ovirt_engine_setup/constants.py M packaging/setup/plugins/ovirt-engine-setup/config/options.py M packaging/setup/plugins/ovirt-engine-setup/legacy/__init__.py A packaging/setup/plugins/ovirt-engine-setup/legacy/osinfo.py 15 files changed, 190 insertions(+), 82 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/84/22384/1 diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in index a9432d3..6cca81d 100644 --- a/ovirt-engine.spec.in +++ b/ovirt-engine.spec.in @@ -668,6 +668,10 @@ touch "%{buildroot}%{engine_pki}/cert.template" touch "%{buildroot}%{engine_pki}/database.txt" touch "%{buildroot}%{engine_pki}/serial.txt" +install -d "%{buildroot}%{engine_etc}/sysprep" +for f in 2k12x64 2k3 2k8 2k8x86 2k8x64 w7 w7x64 w8 w8x64 xp; do + touch "%{buildroot}%{engine_etc}/sysprep/sysprep.${f}" +done install -d "%{buildroot}%{_sysconfdir}/firewalld/services" touch "%{buildroot}%{_sysconfdir}/firewalld/services/ovirt.xml" @@ -754,12 +758,12 @@ %attr(-, %{engine_user}, %{engine_group}) %{engine_state}/content %attr(-, %{engine_user}, %{engine_group}) %{engine_state}/deployments %config %{_sysconfdir}/logrotate.d/ovirt-engine -%config(noreplace) %{engine_etc}/sysprep %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_state} %dir %{engine_data}/bin %dir %{engine_data}/ui-plugins %dir %{engine_ear} %{engine_data}/conf/osinfo-defaults.properties +%{engine_data}/conf/sysprep/ %{engine_data}/files/ %{engine_data}/manual/ %{engine_ear}/META-INF @@ -826,6 +830,10 @@ %ghost %config(noreplace) %{engine_pki}/database.txt %ghost %config(noreplace) %{engine_pki}/serial.txt +# backward compatibility (pre-3.3.3) +# do not remove sysprep files +%ghost %config(noreplace) %{engine_etc}/sysprep/ + %files setup %config %{_sysconfdir}/logrotate.d/ovirt-engine-setup diff --git a/packaging/conf/osinfo-defaults.properties b/packaging/conf/osinfo-defaults.properties index d3d2b0d..f424867 100644 --- a/packaging/conf/osinfo-defaults.properties +++ b/packaging/conf/osinfo-defaults.properties @@ -127,7 +127,7 @@ os.windows_xp.id.value = 1 os.windows_xp.name.value = Windows XP os.windows_xp.derivedFrom.value = other -os.windows_xp.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.xp +os.windows_xp.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.xp os.windows_xp.productKey.value = os.windows_xp.isTimezoneTypeInteger.value = true os.windows_xp.devices.network.value = rtl8139_pv, rtl8139, e1000, pv @@ -141,7 +141,7 @@ os.windows_2003.id.value = 3 os.windows_2003.name.value = Windows 2003 os.windows_2003.derivedFrom.value = windows_xp -os.windows_2003.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.2k3 +os.windows_2003.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k3 os.windows_2003.productKey.value = os.windows_2003.isTimezoneTypeInteger.value = true os.windows_2003.devices.audio.value = ac97 @@ -152,7 +152,7 @@ os.windows_2008.id.value = 4 os.windows_2008.name.value = Windows 2008 os.windows_2008.derivedFrom.value = windows_2003 -os.windows_2008.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.2k8 +os.windows_2008.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k8 os.windows_2008.productKey.value = # Windows2003x64(10, OsType.Windows, true), @@ -161,7 +161,7 @@ os.windows_2003x64.derivedFrom.value = windows_2003 os.windows_2003x64.bus.value = 64 os.windows_2003x64.resources.minimum.ram.value = 1024 -os.windows_2003x64.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.2k3 +os.windows_2003x64.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k3 os.windows_2003x64.productKey.value = os.windows_2003x64.isTimezoneTypeInteger.value = true @@ -169,7 +169,7 @@ os.windows_7.id.value = 11 os.windows_7.name.value = Windows 7 os.windows_7.derivedFrom.value = windows_xp -os.windows_7.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.w7 +os.windows_7.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w7 os.windows_7.productKey.value = os.windows_7.devices.audio.value = ich6 os.windows_7.devices.diskInterfaces.value.3.3 = IDE, VirtIO_SCSI, VirtIO @@ -180,14 +180,14 @@ os.windows_7x64.bus.value = 64 os.windows_7x64.derivedFrom.value = windows_7 os.windows_7x64.resources.minimum.ram.value = 1024 -os.windows_7x64.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.w7x64 +os.windows_7x64.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w7x64 os.windows_7x64.productKey.value = # Windows2008x64(16, OsType.Windows, true), os.windows_2008x64.id.value = 16 os.windows_2008x64.name.value = Windows 2008 x64 os.windows_2008x64.derivedFrom.value = windows_2003x64 -os.windows_2008x64.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.2k8x64 +os.windows_2008x64.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k8x64 os.windows_2008x64.productKey.value = os.windows_2008x64.devices.audio.value = ich6 @@ -202,7 +202,7 @@ os.windows_8.id.value = 20 os.windows_8.name.value = Windows 8 os.windows_8.derivedFrom.value = windows_7 -os.windows_8.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.w8 +os.windows_8.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w8 os.windows_8.productKey.value = os.windows_8.displayProtocols.value = vnc/cirrus @@ -211,7 +211,7 @@ os.windows_8x64.name.value = Windows 8 x64 os.windows_8x64.bus.value = 64 os.windows_8x64.derivedFrom.value = windows_7x64 -os.windows_8x64.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.w8x64 +os.windows_8x64.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w8x64 os.windows_8x64.productKey.value = os.windows_8x64.displayProtocols.value = vnc/cirrus @@ -219,7 +219,7 @@ os.windows_2012x64.id.value = 23 os.windows_2012x64.name.value = Windows 2012 x64 os.windows_2012x64.derivedFrom.value = windows_2008x64 -os.windows_2012x64.sysprepPath.value = ${ENGINE_ETC}/sysprep/sysprep.2k12x64 +os.windows_2012x64.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k12x64 os.windows_2012x64.productKey.value = os.windows_2012x64.displayProtocols.value = vnc/cirrus diff --git a/packaging/etc/sysprep/sysprep.2k12x64 b/packaging/conf/sysprep/sysprep.2k12x64 similarity index 100% rename from packaging/etc/sysprep/sysprep.2k12x64 rename to packaging/conf/sysprep/sysprep.2k12x64 diff --git a/packaging/etc/sysprep/sysprep.2k3 b/packaging/conf/sysprep/sysprep.2k3 similarity index 100% rename from packaging/etc/sysprep/sysprep.2k3 rename to packaging/conf/sysprep/sysprep.2k3 diff --git a/packaging/etc/sysprep/sysprep.2k8 b/packaging/conf/sysprep/sysprep.2k8 similarity index 100% rename from packaging/etc/sysprep/sysprep.2k8 rename to packaging/conf/sysprep/sysprep.2k8 diff --git a/packaging/etc/sysprep/sysprep.2k8x64 b/packaging/conf/sysprep/sysprep.2k8x64 similarity index 100% rename from packaging/etc/sysprep/sysprep.2k8x64 rename to packaging/conf/sysprep/sysprep.2k8x64 diff --git a/packaging/etc/sysprep/sysprep.w7 b/packaging/conf/sysprep/sysprep.w7 similarity index 100% rename from packaging/etc/sysprep/sysprep.w7 rename to packaging/conf/sysprep/sysprep.w7 diff --git a/packaging/etc/sysprep/sysprep.w7x64 b/packaging/conf/sysprep/sysprep.w7x64 similarity index 100% rename from packaging/etc/sysprep/sysprep.w7x64 rename to packaging/conf/sysprep/sysprep.w7x64 diff --git a/packaging/etc/sysprep/sysprep.w8 b/packaging/conf/sysprep/sysprep.w8 similarity index 100% rename from packaging/etc/sysprep/sysprep.w8 rename to packaging/conf/sysprep/sysprep.w8 diff --git a/packaging/etc/sysprep/sysprep.w8x64 b/packaging/conf/sysprep/sysprep.w8x64 similarity index 100% rename from packaging/etc/sysprep/sysprep.w8x64 rename to packaging/conf/sysprep/sysprep.w8x64 diff --git a/packaging/etc/sysprep/sysprep.xp b/packaging/conf/sysprep/sysprep.xp similarity index 100% rename from packaging/etc/sysprep/sysprep.xp rename to packaging/conf/sysprep/sysprep.xp diff --git a/packaging/setup/ovirt_engine_setup/constants.py b/packaging/setup/ovirt_engine_setup/constants.py index c811e5f..77421b1 100644 --- a/packaging/setup/ovirt_engine_setup/constants.py +++ b/packaging/setup/ovirt_engine_setup/constants.py @@ -450,6 +450,11 @@ '10-productkeys.properties', ) + OSINFO_LEGACY_SYSPREP = os.path.join( + OVIRT_ENGINE_OSINFO_REPOSITORY_DIR, + '10-sysprep.properties', + ) + @util.export class Defaults(object): diff --git a/packaging/setup/plugins/ovirt-engine-setup/config/options.py b/packaging/setup/plugins/ovirt-engine-setup/config/options.py index f14b855..b833c16 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/config/options.py +++ b/packaging/setup/plugins/ovirt-engine-setup/config/options.py @@ -19,7 +19,6 @@ """options plugin.""" -import os import gettext _ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') @@ -185,76 +184,6 @@ { 'name': 'DataDir', 'value': osetupcons.FileLocations.DATADIR, - }, - { - 'name': 'SysPrepXPPath', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.xp', - ), - }, - { - 'name': 'SysPrep2K3Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.2k3', - ), - }, - { - 'name': 'SysPrep2K8Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.2k8x86', - ), - }, - { - 'name': 'SysPrep2K8x64Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.2k8', - ), - }, - { - 'name': 'SysPrep2K8R2Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.2k8', - ), - }, - { - 'name': 'SysPrepWindows7Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.w7', - ), - }, - { - 'name': 'SysPrepWindows7x64Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.w7x64', - ), - }, - { - 'name': 'SysPrepWindows8Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.w8', - ), - }, - { - 'name': 'SysPrepWindows8x64Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.w8x64', - ), - }, - { - 'name': 'SysPrepWindows2012x64Path', - 'value': os.path.join( - osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, - 'gsysprep/sysprep.2k12x64', - ), }, ), ) diff --git a/packaging/setup/plugins/ovirt-engine-setup/legacy/__init__.py b/packaging/setup/plugins/ovirt-engine-setup/legacy/__init__.py index e1fe475..1d23b1a 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/legacy/__init__.py +++ b/packaging/setup/plugins/ovirt-engine-setup/legacy/__init__.py @@ -30,6 +30,7 @@ from . import isodomain from . import database from . import ca +from . import osinfo @util.export @@ -42,6 +43,7 @@ isodomain.Plugin(context=context) database.Plugin(context=context) ca.Plugin(context=context) + osinfo.Plugin(context=context) # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/setup/plugins/ovirt-engine-setup/legacy/osinfo.py b/packaging/setup/plugins/ovirt-engine-setup/legacy/osinfo.py new file mode 100644 index 0000000..c84c212 --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/legacy/osinfo.py @@ -0,0 +1,164 @@ +# +# 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. +# + + +"""Upgrade osinfo from legacy plugin.""" + + +import filecmp +import os +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import plugin +from otopi import constants as otopicons +from otopi import filetransaction + + +from ovirt_engine_setup import constants as osetupcons + + +@util.export +class Plugin(plugin.PluginBase): + """Upgrade osinfo from legacy plugin.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._toremove = set() + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self.environment[ + osetupcons.CoreEnv.ACTION + ] == osetupcons.Const.ACTION_UPGRADE, + after=[ + osetupcons.Stages.DB_CONNECTION_AVAILABLE, + ], + ) + def _misc(self): + content = [] + used = set() + + for vdcoption, sysprep, osinfo in ( + ('SysPrep2K3Path', 'sysprep.2k3', ( + 'windows_2003', 'windows_2003x64' + )), + ('SysPrep2K8Path', 'sysprep.2k8', ('windows_2008',)), + ('SysPrep2K8R2Path', 'sysprep.2k8', ('windows_2008',)), + ('SysPrep2K8x64Path', 'sysprep.2k8x64', ('windows_2008x64',)), + ('SysPrepWindows2012x64Path', 'sysprep.2k12x64', ( + 'windows_2012x64', + )), + ('SysPrepWindows7Path', 'sysprep.w7', ('windows_7',)), + ('SysPrepWindows7x64Path', 'sysprep.w7x64', ('windows_7x64',)), + ('SysPrepWindows8Path', 'sysprep.w8', ('windows_8',)), + ('SysPrepWindows8x64Path', 'sysprep.w8x64', ('windows_2008x64',)), + ('SysPrepXPPath', 'sysprep.xp', ('windows_xp',)), + ): + val = self.environment[ + osetupcons.DBEnv.STATEMENT + ].getVdcOption(name=vdcoption) + + # + # fix emberrising typo in previous setup + # so we can find files. + # + val = val.replace('/gsysprep', '/sysprep') + + # + # reset so at next cycle we won't + # consider vdcoptions any more + # + self.environment[ + osetupcons.DBEnv.STATEMENT + ].updateVdcOptions( + options=( + { + 'name': vdcoption, + 'value': '', + }, + ), + ) + + if val and os.path.exists(val): + self.logger.debug( + "Found legacy sysprep %s '%s'", + vdcoption, + val, + ) + if filecmp.cmp( + val, + os.path.join( + osetupcons.FileLocations.OVIRT_ENGINE_DATADIR, + 'conf', + 'sysprep', + sysprep, + ) + ): + self._toremove.add(val) + else: + used.add(val) + self.logger.debug('legacy sysprep differ from %s', sysprep) + for name in osinfo: + content.append( + 'os.%s.sysprepPath.value = %s' % ( + name, + val, + ) + ) + + self._toremove -= used + + self.logger.debug('legacy sysprep fixup: %s', content) + self.logger.debug('legacy sysprep remove: %s', self._toremove) + + if content: + self.environment[ + otopicons.CoreEnv.MAIN_TRANSACTION + ].append( + filetransaction.FileTransaction( + name=osetupcons.FileLocations.OSINFO_LEGACY_SYSPREP, + content=content, + ) + ) + + @plugin.event( + stage=plugin.Stages.STAGE_CLOSEUP, + ) + def _closeup(self): + for candidate in self._toremove: + for f in ( + '%s' % candidate, + '%s.rpmnew' % candidate, + '%s.rpmsave' % candidate, + ): + if os.path.exists(f): + os.unlink(f) + try: + os.rmdir( + os.path.join( + osetupcons.FileLocations.OVIRT_ENGINE_SYSCONFDIR, + 'sysprep', + ) + ) + except OSError: + pass + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/22384 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I26a853c12ca091f340d6ebed2c10726462ec576a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches