Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging - fix otopi implementation version locking handling
......................................................................

packaging - fix otopi implementation version locking handling

moved system/environment plugin from ovirt-engine-setup to
ovirt-engine-common for reusing it in engine-cleanup-2

engine-setup-2 avoid to replace version locking list file

engine-cleanup-2 removes ovirt-engine lines from locking list file

Change-Id: Ib1b9142088cfa7def37f6d1ad3d2a4204aebe8ae
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M packaging/setup/plugins/ovirt-engine-common/system/__init__.py
R packaging/setup/plugins/ovirt-engine-common/system/environment.py
A packaging/setup/plugins/ovirt-engine-remove/distro-rpm/__init__.py
A packaging/setup/plugins/ovirt-engine-remove/distro-rpm/versionlock.py
M packaging/setup/plugins/ovirt-engine-setup/distro-rpm/versionlock.py
M packaging/setup/plugins/ovirt-engine-setup/system/__init__.py
6 files changed, 136 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/14700/1

diff --git a/packaging/setup/plugins/ovirt-engine-common/system/__init__.py 
b/packaging/setup/plugins/ovirt-engine-common/system/__init__.py
index 6986853..e5a052b 100644
--- a/packaging/setup/plugins/ovirt-engine-common/system/__init__.py
+++ b/packaging/setup/plugins/ovirt-engine-common/system/__init__.py
@@ -22,11 +22,13 @@
 from otopi import util
 
 
+from . import environment
 from . import hostile_services
 
 
 @util.export
 def createPlugins(context):
+    environment.Plugin(context=context)
     hostile_services.Plugin(context=context)
 
 
diff --git a/packaging/setup/plugins/ovirt-engine-setup/system/environment.py 
b/packaging/setup/plugins/ovirt-engine-common/system/environment.py
similarity index 100%
rename from packaging/setup/plugins/ovirt-engine-setup/system/environment.py
rename to packaging/setup/plugins/ovirt-engine-common/system/environment.py
diff --git a/packaging/setup/plugins/ovirt-engine-remove/distro-rpm/__init__.py 
b/packaging/setup/plugins/ovirt-engine-remove/distro-rpm/__init__.py
new file mode 100644
index 0000000..6b7acdf
--- /dev/null
+++ b/packaging/setup/plugins/ovirt-engine-remove/distro-rpm/__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.
+#
+
+
+""" ovirt-host-setup distro-rpm plugin.
+    Includes code relevant for rpm-based distributions
+"""
+
+
+from otopi import util
+from . import versionlock
+
+
[email protected]
+def createPlugins(context):
+    versionlock.Plugin(context=context)
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git 
a/packaging/setup/plugins/ovirt-engine-remove/distro-rpm/versionlock.py 
b/packaging/setup/plugins/ovirt-engine-remove/distro-rpm/versionlock.py
new file mode 100644
index 0000000..32b8145
--- /dev/null
+++ b/packaging/setup/plugins/ovirt-engine-remove/distro-rpm/versionlock.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.
+#
+
+
+"""
+Yum versionlock configuration plugin.
+"""
+
+import os
+import platform
+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):
+    """
+    Yum versionlock configuration plugin.
+    """
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+        self._enabled = False
+        self._distribution = platform.linux_distribution(
+            full_distribution_name=0
+        )[0]
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_SETUP,
+        condition=lambda self: not self.environment[
+            osetupcons.CoreEnv.DEVELOPER_MODE
+        ],
+    )
+    def _setup(self):
+        if self._distribution in ('redhat', 'fedora', 'centos'):
+            self._enabled = True
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_MISC,
+        condition=lambda self: self._enabled,
+    )
+    def _configversionunlock(self):
+        #Can't assume we're the owner of the locking list.
+        oldcontent = ''
+        if os.path.exists(
+            osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK
+        ):
+            with open(
+                osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK
+            ) as locking_list_file:
+                oldcontent = locking_list_file.read()
+        new_content = []
+        for line in oldcontent.splitlines():
+            if line.find(osetupcons.Const.ENGINE_PACKAGE_NAME) == -1:
+                new_content.append(line)
+
+        self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
+            filetransaction.FileTransaction(
+                name=osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK,
+                owner=self.environment[osetupcons.SystemEnv.USER_ROOT],
+                mode=0o644,
+                enforcePermissions=True,
+                content=new_content,
+            )
+        )
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/distro-rpm/versionlock.py 
b/packaging/setup/plugins/ovirt-engine-setup/distro-rpm/versionlock.py
index f2fb216..689956d 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/distro-rpm/versionlock.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/distro-rpm/versionlock.py
@@ -20,6 +20,7 @@
 Yum versionlock configuration plugin.
 """
 
+import os
 import platform
 import gettext
 _ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup')
@@ -61,13 +62,22 @@
         condition=lambda self: self._enabled,
     )
     def _configversionlock(self):
+        #Can't assume we're the owner of the locking list.
+        content = ''
+        if os.path.exists(
+            osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK
+        ):
+            with open(
+                osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK
+            ) as locking_list_file:
+                content = locking_list_file.read()
         self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
             filetransaction.FileTransaction(
                 name=osetupcons.FileLocations.OVIRT_ENGINE_YUM_VERSIONLOCK,
                 owner=self.environment[osetupcons.SystemEnv.USER_ROOT],
                 mode=0o644,
                 enforcePermissions=True,
-                content=(
+                content=content + (
                     '\n'.join(
                         osetupcons.Const.RPM_LOCK_LIST
                     ).format(
diff --git a/packaging/setup/plugins/ovirt-engine-setup/system/__init__.py 
b/packaging/setup/plugins/ovirt-engine-setup/system/__init__.py
index e073b0d..0337708 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/system/__init__.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/system/__init__.py
@@ -22,7 +22,6 @@
 from otopi import util
 
 
-from . import environment
 from . import sysctl
 from . import memcheck
 from . import nfs
@@ -32,7 +31,6 @@
 
 @util.export
 def createPlugins(context):
-    environment.Plugin(context=context)
     sysctl.Plugin(context=context)
     memcheck.Plugin(context=context)
     nfs.Plugin(context=context)


--
To view, visit http://gerrit.ovirt.org/14700
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1b9142088cfa7def37f6d1ad3d2a4204aebe8ae
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to