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=1043206
Change-Id: I26a853c12ca091f340d6ebed2c10726462ec576a
Signed-off-by: Alon Bar-Lev <[email protected]>
---
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/ovirt-engine/config/options.py
A packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/legacy/__init__.py
A packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/legacy/osinfo.py
15 files changed, 223 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/23339/1

diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in
index 909841d..d42d4f4 100644
--- a/ovirt-engine.spec.in
+++ b/ovirt-engine.spec.in
@@ -715,6 +715,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"
 
@@ -802,12 +806,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
@@ -912,6 +916,8 @@
 %{engine_data}/setup/plugins/ovirt-engine-rename/
 
 # backward compatibility
+# backward compatibility (pre-3.4)
+%ghost %config(noreplace) %{engine_etc}/sysprep/
 %ghost %config(noreplace) %{_sysconfdir}/firewalld/services/ovirt.xml
 
 %files setup-plugin-ovirt-engine-common
diff --git a/packaging/conf/osinfo-defaults.properties 
b/packaging/conf/osinfo-defaults.properties
index b5b5c09..3d666f6 100644
--- a/packaging/conf/osinfo-defaults.properties
+++ b/packaging/conf/osinfo-defaults.properties
@@ -131,7 +131,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
@@ -145,7 +145,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
@@ -156,7 +156,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),
@@ -165,7 +165,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
 
@@ -173,7 +173,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
@@ -184,14 +184,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
 
@@ -206,7 +206,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.devices.display.protocols.value = vnc/cirrus
 
@@ -215,7 +215,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.devices.display.protocols.value = vnc/cirrus
 
@@ -223,7 +223,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.devices.display.protocols.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 1a15643..9b45c65 100644
--- a/packaging/setup/ovirt_engine_setup/constants.py
+++ b/packaging/setup/ovirt_engine_setup/constants.py
@@ -80,6 +80,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,
@@ -420,6 +424,11 @@
         '20-setup-aio.conf'
     )
 
+    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/ovirt-engine/config/options.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/options.py
index f14b855..b833c16 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/options.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/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/ovirt-engine/legacy/__init__.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/legacy/__init__.py
new file mode 100644
index 0000000..5bfc9ad
--- /dev/null
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/legacy/__init__.py
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+
+"""legacy plugin."""
+
+
+from otopi import util
+
+
+from . import osinfo
+
+
[email protected]
+def createPlugins(context):
+    osinfo.Plugin(context=context)
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/legacy/osinfo.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/legacy/osinfo.py
new file mode 100644
index 0000000..8f54330
--- /dev/null
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/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
+
+
[email protected]
+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: not self.environment[
+            osetupcons.DBEnv.NEW_DATABASE
+        ],
+        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 embarrassing 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/23339
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26a853c12ca091f340d6ebed2c10726462ec576a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to