Alon Bar-Lev has uploaded a new change for review.

Change subject: core: use before/after feature
......................................................................

core: use before/after feature

Change-Id: I8f377d454b2d1f3fed1bd4df6d98955258a8c64d
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M src/otopi/constants.py
M src/plugins/otopi/core/config.py
M src/plugins/otopi/core/log.py
M src/plugins/otopi/dialog/cli.py
M src/plugins/otopi/packagers/yumpackager.py
M src/plugins/otopi/services/openrc.py
M src/plugins/otopi/services/rhel.py
M src/plugins/otopi/services/systemd.py
M src/plugins/otopi/system/command.py
9 files changed, 36 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/otopi refs/changes/79/11779/1

diff --git a/src/otopi/constants.py b/src/otopi/constants.py
index 00ba7c2..13a06c4 100644
--- a/src/otopi/constants.py
+++ b/src/otopi/constants.py
@@ -42,6 +42,17 @@
 
 
 @util.export
+class Stages(object):
+    CORE_LOG_INIT = 'otopi.core.log.init'
+    CORE_CONFIG_INIT = 'otopi.core.config.init'
+    DIALOG_CLI_CUSTOMIZATION = 'otopi.dialog.cli.customization'
+    DIALOG_CLI_TERMINATION = 'otopi.dialog.cli.termination'
+    SYSTEM_COMMAND_DETECTION = 'otopi.system.command.detection'
+    SYSTEM_COMMAND_REDETECTION = 'otopi.system.command.redetection'
+    PACKAGERS_DETECTION = 'otopi.packagers.detection'
+
+
+@util.export
 class Log(object):
     LOGGER_BASE = 'otopi'
 
diff --git a/src/plugins/otopi/core/config.py b/src/plugins/otopi/core/config.py
index b33fc5c..45827db 100644
--- a/src/plugins/otopi/core/config.py
+++ b/src/plugins/otopi/core/config.py
@@ -82,6 +82,7 @@
         self._config.optionxform = str
 
     @plugin.event(
+        name=constants.Stages.CORE_CONFIG_INIT,
         stage=plugin.Stages.STAGE_INIT,
         priority=plugin.Stages.PRIORITY_HIGH - 10,
     )
diff --git a/src/plugins/otopi/core/log.py b/src/plugins/otopi/core/log.py
index 2e1ca96..eea8a04 100644
--- a/src/plugins/otopi/core/log.py
+++ b/src/plugins/otopi/core/log.py
@@ -190,6 +190,7 @@
             self._closeLogging()
 
     @plugin.event(
+        name=constants.Stages.CORE_LOG_INIT,
         stage=plugin.Stages.STAGE_BOOT,
         priority=plugin.Stages.PRIORITY_HIGH,
     )
diff --git a/src/plugins/otopi/dialog/cli.py b/src/plugins/otopi/dialog/cli.py
index 5bd6ad7..20162ed 100644
--- a/src/plugins/otopi/dialog/cli.py
+++ b/src/plugins/otopi/dialog/cli.py
@@ -133,8 +133,8 @@
         )
 
     @plugin.event(
+        name=constants.Stages.DIALOG_CLI_CUSTOMIZATION,
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
-        priority=plugin.Stages.PRIORITY_LOW,
         condition=(
             lambda self: self.environment[constants.DialogEnv.CUSTOMIZATION]
         ),
@@ -149,8 +149,8 @@
         )
 
     @plugin.event(
+        name=constants.Stages.DIALOG_CLI_TERMINATION,
         stage=plugin.Stages.STAGE_PRE_TERMINATE,
-        priority=plugin.Stages.PRIORITY_LOW,
         condition=(
             lambda self: self.environment[constants.DialogEnv.CUSTOMIZATION]
         ),
diff --git a/src/plugins/otopi/packagers/yumpackager.py 
b/src/plugins/otopi/packagers/yumpackager.py
index 25c4598..eb55296 100644
--- a/src/plugins/otopi/packagers/yumpackager.py
+++ b/src/plugins/otopi/packagers/yumpackager.py
@@ -87,6 +87,7 @@
             self.logger.debug('Cannot import miniyumlocal', exc_info=True)
 
     @plugin.event(
+        name=constants.Stages.PACKAGERS_DETECTION,
         stage=plugin.Stages.STAGE_INIT,
         priority=plugin.Stages.PRIORITY_HIGH,
         condition=lambda self: self._enabled,
diff --git a/src/plugins/otopi/services/openrc.py 
b/src/plugins/otopi/services/openrc.py
index 9d8ec6f..e110809 100644
--- a/src/plugins/otopi/services/openrc.py
+++ b/src/plugins/otopi/services/openrc.py
@@ -26,6 +26,7 @@
 _ = lambda m: gettext.dgettext(message=m, domain='otopi')
 
 
+from otopi import constants
 from otopi import util
 from otopi import plugin
 from otopi import services
@@ -47,9 +48,11 @@
 
     @plugin.event(
         stage=plugin.Stages.STAGE_VALIDATION,
-        priority=plugin.Stages.PRIORITY_HIGH,
+        after=[
+            constants.Stages.SYSTEM_COMMAND_DETECTION,
+        ],
     )
-    def _validation(self):
+    def _programs(self):
         rc = self.command.get('rc', optional=True)
         if rc is not None:
             (ret, stdout, stderr) = self.execute(
diff --git a/src/plugins/otopi/services/rhel.py 
b/src/plugins/otopi/services/rhel.py
index f58accb..fa67035 100644
--- a/src/plugins/otopi/services/rhel.py
+++ b/src/plugins/otopi/services/rhel.py
@@ -26,6 +26,7 @@
 _ = lambda m: gettext.dgettext(message=m, domain='otopi')
 
 
+from otopi import constants
 from otopi import util
 from otopi import plugin
 from otopi import services
@@ -48,10 +49,12 @@
         self.command.detect('initctl')
 
     @plugin.event(
-        stage=plugin.Stages.STAGE_VALIDATION,
-        priority=plugin.Stages.PRIORITY_HIGH,
+        stage=plugin.Stages.STAGE_PROGRAMS,
+        after=[
+            constants.Stages.SYSTEM_COMMAND_DETECTION,
+        ],
     )
-    def _validation(self):
+    def _programs(self):
         haveSystemd = False
         systemctl = self.command.get('systemctl', optional=True)
         if systemctl is not None:
diff --git a/src/plugins/otopi/services/systemd.py 
b/src/plugins/otopi/services/systemd.py
index ba70008..9e567f4 100644
--- a/src/plugins/otopi/services/systemd.py
+++ b/src/plugins/otopi/services/systemd.py
@@ -25,6 +25,7 @@
 _ = lambda m: gettext.dgettext(message=m, domain='otopi')
 
 
+from otopi import constants
 from otopi import util
 from otopi import plugin
 from otopi import services
@@ -44,10 +45,12 @@
         self.command.detect('systemctl')
 
     @plugin.event(
-        stage=plugin.Stages.STAGE_VALIDATION,
-        priority=plugin.Stages.PRIORITY_HIGH,
+        stage=plugin.Stages.STAGE_PROGRAMS,
+        after=[
+            constants.Stages.SYSTEM_COMMAND_DETECTION,
+        ],
     )
-    def _validation(self):
+    def _programs(self):
         systemctl = self.command.get('systemctl', optional=True)
         if systemctl is not None:
             (ret, stdout, stderr) = self.execute(
diff --git a/src/plugins/otopi/system/command.py 
b/src/plugins/otopi/system/command.py
index b3a1a63..5e2c23a 100644
--- a/src/plugins/otopi/system/command.py
+++ b/src/plugins/otopi/system/command.py
@@ -64,12 +64,14 @@
         self.context.registerCommand(command=self)
 
     @plugin.event(
+        name=constants.Stages.SYSTEM_COMMAND_DETECTION,
         stage=plugin.Stages.STAGE_PROGRAMS,
     )
-    def _customization(self):
+    def _programs(self):
         self._search()
 
     @plugin.event(
+        name=constants.Stages.SYSTEM_COMMAND_REDETECTION,
         stage=plugin.Stages.STAGE_MISC,
         priority=plugin.Stages.PRIORITY_HIGH,
     )


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f377d454b2d1f3fed1bd4df6d98955258a8c64d
Gerrit-PatchSet: 1
Gerrit-Project: otopi
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

Reply via email to