Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: setup: total mem env in common
......................................................................

packaging: setup: total mem env in common

Move the check for amount of memory to common.

Change-Id: I9d07718b1852f545813ce3893cca790a3294e2ad
Bug-Url: https://bugzilla.redhat.com/1185411
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M packaging/setup/plugins/ovirt-engine-common/base/system/__init__.py
A packaging/setup/plugins/ovirt-engine-common/base/system/mem.py
M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/memcheck.py
3 files changed, 73 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/37501/1

diff --git 
a/packaging/setup/plugins/ovirt-engine-common/base/system/__init__.py 
b/packaging/setup/plugins/ovirt-engine-common/base/system/__init__.py
index 6986853..fbf4b53 100644
--- a/packaging/setup/plugins/ovirt-engine-common/base/system/__init__.py
+++ b/packaging/setup/plugins/ovirt-engine-common/base/system/__init__.py
@@ -1,6 +1,6 @@
 #
 # ovirt-engine-setup -- ovirt engine setup
-# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013-2015 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.
@@ -23,11 +23,13 @@
 
 
 from . import hostile_services
+from . import mem
 
 
 @util.export
 def createPlugins(context):
     hostile_services.Plugin(context=context)
+    mem.Plugin(context=context)
 
 
 # vim: expandtab tabstop=4 shiftwidth=4
diff --git a/packaging/setup/plugins/ovirt-engine-common/base/system/mem.py 
b/packaging/setup/plugins/ovirt-engine-common/base/system/mem.py
new file mode 100644
index 0000000..b1239dd
--- /dev/null
+++ b/packaging/setup/plugins/ovirt-engine-common/base/system/mem.py
@@ -0,0 +1,70 @@
+#
+# ovirt-engine-setup -- ovirt engine setup
+# Copyright (C) 2015 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.
+#
+
+
+import re
+
+
+from otopi import util
+from otopi import plugin
+
+from ovirt_engine_setup import constants as osetupcons
+
+
+@util.export
+class Plugin(plugin.PluginBase):
+
+    _RE_MEMINFO_MEMTOTAL = re.compile(
+        flags=re.VERBOSE,
+        pattern=r"""
+            ^
+            MemTotal:
+            \s+
+            (?P<value>\d+)
+            \s+
+            (?P<unit>\w+)
+        """
+    )
+
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+        self.environment.setdefault(
+            osetupcons.ConfigEnv.TOTAL_MEMORY_MB,
+            None
+        )
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_SETUP,
+    )
+    def _setup(self):
+        self.logger.debug('Checking total memory')
+        with open('/proc/meminfo', 'r') as f:
+            content = f.read()
+
+        match = self._RE_MEMINFO_MEMTOTAL.match(content)
+        if match is None:
+            raise RuntimeError(_("Unable to parse /proc/meminfo"))
+
+        if self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] is None:
+            self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] = int(
+                match.group('value')
+            )
+            if match.group('unit') == "kB":
+                self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] //= 1024
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/memcheck.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/memcheck.py
index 78c67a7..b7e35f3 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/memcheck.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/system/memcheck.py
@@ -39,24 +39,9 @@
     """
     Available memory checking plugin.
     """
-    _RE_MEMINFO_MEMTOTAL = re.compile(
-        flags=re.VERBOSE,
-        pattern=r"""
-            ^
-            MemTotal:
-            \s+
-            (?P<value>\d+)
-            \s+
-            (?P<unit>\w+)
-        """
-    )
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
-        self.environment.setdefault(
-            osetupcons.ConfigEnv.TOTAL_MEMORY_MB,
-            None
-        )
 
     def _check_requirements(self):
         satisfied = False
@@ -121,25 +106,6 @@
             oenginecons.SystemEnv.MEMCHECK_THRESHOLD,
             oenginecons.Defaults.DEFAULT_SYSTEM_MEMCHECK_THRESHOLD
         )
-
-    @plugin.event(
-        stage=plugin.Stages.STAGE_SETUP,
-    )
-    def _setup(self):
-        self.logger.debug('Checking total memory')
-        with open('/proc/meminfo', 'r') as f:
-            content = f.read()
-
-        match = self._RE_MEMINFO_MEMTOTAL.match(content)
-        if match is None:
-            raise RuntimeError(_("Unable to parse /proc/meminfo"))
-
-        if self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] is None:
-            self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] = int(
-                match.group('value')
-            )
-            if match.group('unit') == "kB":
-                self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] //= 1024
 
     @plugin.event(
         stage=plugin.Stages.STAGE_VALIDATION,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d07718b1852f545813ce3893cca790a3294e2ad
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to