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

Change subject: mgmt: initial add
......................................................................

mgmt: initial add

Change-Id: I2fdfad98664fca4351ae1914b7d51cf507d347bf
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M .gitignore
M ChangeLog
M README.environment
M configure.ac
M ovirt-host-deploy.spec.in
M po/POTFILES.in
M src/Makefile.am
M src/bin/Makefile.am
M src/interface-3/Makefile.am
M src/java/Makefile.am
A src/ovirt_host_mgmt/Makefile.am
A src/ovirt_host_mgmt/__init__.py
A src/ovirt_host_mgmt/config.py.in
A src/ovirt_host_mgmt/constants.py
M src/plugins/Makefile.am
A src/plugins/ovirt-host-mgmt/Makefile.am
A src/plugins/ovirt-host-mgmt/core/Makefile.am
A src/plugins/ovirt-host-mgmt/core/__init__.py
A src/plugins/ovirt-host-mgmt/core/misc.py
A src/plugins/ovirt-host-mgmt/core/offlinepackager.py
A src/plugins/ovirt-host-mgmt/packages/Makefile.am
A src/plugins/ovirt-host-mgmt/packages/__init__.py
A src/plugins/ovirt-host-mgmt/packages/update.py
23 files changed, 697 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy 
refs/changes/88/39988/4

diff --git a/.gitignore b/.gitignore
index 231f0d9..3d4beec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,4 +27,6 @@
 .bundeled
 target
 src/bin/ovirt-host-deploy
+src/bin/ovirt-host-mgmt
 src/ovirt_host_deploy/config.py
+src/ovirt_host_mgmt/config.py
diff --git a/ChangeLog b/ChangeLog
index fc1dc26..4e04e4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
  * tune: tuned: set the tuned profile based on environment variable,
    rhbz#1209418.
+ * mgmt: new component to enable host management.
 
 2015-01-15 - Version 1.3.1
 
diff --git a/README.environment b/README.environment
index fb06a86..69fb16f 100644
--- a/README.environment
+++ b/README.environment
@@ -90,3 +90,20 @@
 
 OPENSTACK_NEUTRON_OPENVSWITCH_CONFIG/section/key(str)
     Set Neutron Open vSwitch agent configuration option.
+
+MANAGEMENT ENVIRONMENT
+----------------------
+
+OMGMT_CORE/offlinePackager(str) [False]
+    Force offline packager.
+
+OMGMT_PACKAGES/packagesUpdateMode(str) [disabled]
+    disabled - do nothing
+    checkUpdate - only check for updates
+    update - perform update
+
+OMGMT_PACKAGES/packages(multi-str)
+    Packages to monitor
+
+OMGMT_PACKAGES/packagesInfo(multi-str)
+    Package information that is retrieved out of check.
diff --git a/configure.ac b/configure.ac
index 2182ef3..fd0c5eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 dnl
 dnl ovirt-host-deploy -- ovirt host deployer
-dnl Copyright (C) 2012-2013 Red Hat, Inc.
+dnl Copyright (C) 2012-2015 Red Hat, Inc.
 dnl
 dnl This library is free software; you can redistribute it and/or
 dnl modify it under the terms of the GNU Lesser General Public
@@ -147,11 +147,13 @@
 otopiplugindir="\$(datadir)/otopi/plugins"
 ovirthostdeployplugindir="\$(pkgdatadir)/plugins"
 ovirthostdeploylibdir="\$(pythondir)/ovirt_host_deploy"
+ovirthostmgmtlibdir="\$(pythondir)/ovirt_host_mgmt"
 ovirthostdeployinterfacedir="\$(pkgdatadir)/interface-${INTERFACE_VERSION}"
 AC_SUBST([otopiplugindir])
 AC_SUBST([ovirthostdeployplugindir])
 AC_SUBST([ovirthostdeploylibdir])
 AC_SUBST([ovirthostdeployinterfacedir])
+AC_SUBST([ovirthostmgmtlibdir])
 AC_SUBST([LOCAL_VERSION])
 AC_SUBST([OTOPI_SOURCES])
 AM_CONDITIONAL([PYTHON_SYNTAX_CHECK], [test "${enable_python_syntax_check}" = 
"yes"])
@@ -173,6 +175,8 @@
        src/java/pom.xml
        src/ovirt_host_deploy/Makefile
        src/ovirt_host_deploy/config.py
+       src/ovirt_host_mgmt/Makefile
+       src/ovirt_host_mgmt/config.py
        src/plugins/Makefile
        src/plugins/ovirt-host-deploy/Makefile
        src/plugins/ovirt-host-deploy/core/Makefile
@@ -183,10 +187,17 @@
        src/plugins/ovirt-host-deploy/tune/Makefile
        src/plugins/ovirt-host-deploy/vdsm/Makefile
        src/plugins/ovirt-host-deploy/vdsmhooks/Makefile
+       src/plugins/ovirt-host-mgmt/Makefile
+       src/plugins/ovirt-host-mgmt/core/Makefile
+       src/plugins/ovirt-host-mgmt/packages/Makefile
        tests/Makefile
 ])
 AC_CONFIG_FILES(
        [src/bin/ovirt-host-deploy:src/bin/executor.in],
        [chmod a+x src/bin/ovirt-host-deploy]
 )
+AC_CONFIG_FILES(
+       [src/bin/ovirt-host-mgmt:src/bin/executor.in],
+       [chmod a+x src/bin/ovirt-host-mgmt]
+)
 AC_OUTPUT
diff --git a/ovirt-host-deploy.spec.in b/ovirt-host-deploy.spec.in
index 25fff20..e034402 100644
--- a/ovirt-host-deploy.spec.in
+++ b/ovirt-host-deploy.spec.in
@@ -145,17 +145,23 @@
 %doc COPYING
 %doc README
 %doc README.environment
-%{_datadir}/%{name}/plugins/%{name}/
-%{_datadir}/otopi/plugins/%{name}
-%{_sbindir}/%{name}
+%{_datadir}/%{name}/plugins/ovirt-host-deploy/
+%{_datadir}/%{name}/plugins/ovirt-host-mgmt/
+%{_datadir}/otopi/plugins/ovirt-host-deploy
+%{_datadir}/otopi/plugins/ovirt-host-mgmt
+%{_sbindir}/ovirt-host-deploy
+%{_sbindir}/ovirt-host-mgmt
 %{ovirt_host_deploy_root}/.bundled
 %{ovirt_host_deploy_root}/otopi
 %{ovirt_host_deploy_root}/otopi-plugins
 %{ovirt_host_deploy_root}/ovirt-host-deploy
+%{ovirt_host_deploy_root}/ovirt-host-mgmt
 %{ovirt_host_deploy_root}/pythonlib/otopi
 %{ovirt_host_deploy_root}/pythonlib/ovirt_host_deploy
+%{ovirt_host_deploy_root}/pythonlib/ovirt_host_mgmt
 %{ovirt_host_deploy_root}/setup
 %{python_sitelib}/ovirt_host_deploy/
+%{python_sitelib}/ovirt_host_mgmt/
 
 %files java -f src/java/.mfiles
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index aa8f0bc..91bfff4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,8 @@
 ./src/ovirt_host_deploy/constants.py
 ./src/ovirt_host_deploy/hardware.py
 ./src/ovirt_host_deploy/__init__.py
+./src/ovirt_host_mgmt/constants.py
+./src/ovirt_host_mgmt/__init__.py
 ./src/plugins/ovirt-host-deploy/core/__init__.py
 ./src/plugins/ovirt-host-deploy/core/misc.py
 ./src/plugins/ovirt-host-deploy/core/offlinepackager.py
@@ -30,3 +32,8 @@
 ./src/plugins/ovirt-host-deploy/vdsm/pki.py
 ./src/plugins/ovirt-host-deploy/vdsm/software.py
 ./src/plugins/ovirt-host-deploy/vdsm/vdsmid.py
+./src/plugins/ovirt-host-mgmt/core/__init__.py
+./src/plugins/ovirt-host-mgmt/core/misc.py
+./src/plugins/ovirt-host-mgmt/core/offlinepackager.py
+./src/plugins/ovirt-host-mgmt/packages/__init__.py
+./src/plugins/ovirt-host-mgmt/packages/update.py
diff --git a/src/Makefile.am b/src/Makefile.am
index 56ad8af..c039713 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,5 +26,6 @@
        interface-3 \
        java \
        ovirt_host_deploy \
+       ovirt_host_mgmt \
        plugins \
        $(NULL)
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 299ecaa..74020bb 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -27,4 +27,5 @@
 
 sbin_SCRIPTS = \
        ovirt-host-deploy \
+       ovirt-host-mgmt \
        $(NULL)
diff --git a/src/interface-3/Makefile.am b/src/interface-3/Makefile.am
index 9d7a69b..394f297 100644
--- a/src/interface-3/Makefile.am
+++ b/src/interface-3/Makefile.am
@@ -33,10 +33,16 @@
                --otopi-sources="$(OTOPI_SOURCES)"
        rm -f "$(DESTDIR)$(ovirthostdeployinterfacedir)/ovirt-host-deploy"
        $(LN_SR) "$(DESTDIR)$(sbindir)/ovirt-host-deploy" 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/ovirt-host-deploy"
+       rm -f "$(DESTDIR)$(ovirthostdeployinterfacedir)/ovirt-host-mgmt"
+       $(LN_SR) "$(DESTDIR)$(sbindir)/ovirt-host-mgmt" 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/ovirt-host-mgmt"
        rm -f 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/pythonlib/ovirt_host_deploy"
        $(LN_SR) "$(DESTDIR)$(ovirthostdeploylibdir)" 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/pythonlib/ovirt_host_deploy"
+       rm -f 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/pythonlib/ovirt_host_mgmt"
+       $(LN_SR) "$(DESTDIR)$(ovirthostmgmtlibdir)" 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/pythonlib/ovirt_host_mgmt"
        rm -f 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/otopi-plugins/ovirt-host-deploy"
        $(LN_SR) "$(DESTDIR)$(ovirthostdeployplugindir)/ovirt-host-deploy" 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/otopi-plugins/ovirt-host-deploy"
+       rm -f 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/otopi-plugins/ovirt-host-mgmt"
+       $(LN_SR) "$(DESTDIR)$(ovirthostdeployplugindir)/ovirt-host-mgmt" 
"$(DESTDIR)$(ovirthostdeployinterfacedir)/otopi-plugins/ovirt-host-mgmt"
 
 uninstall-hook:
        rm -f "$(DESTDIR)$(ovirthostdeployinterfacedir)/.bundled"
diff --git a/src/java/Makefile.am b/src/java/Makefile.am
index 6a04fff..f1b727b 100644
--- a/src/java/Makefile.am
+++ b/src/java/Makefile.am
@@ -21,6 +21,7 @@
 
 generate = \
        ovirt_host_deploy.constants \
+       ovirt_host_mgmt.constants \
        $(NULL)
 
 targetdir = $(abs_top_builddir)/target
diff --git a/src/ovirt_host_mgmt/Makefile.am b/src/ovirt_host_mgmt/Makefile.am
new file mode 100644
index 0000000..ab166d7
--- /dev/null
+++ b/src/ovirt_host_mgmt/Makefile.am
@@ -0,0 +1,49 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+include $(top_srcdir)/build/python.inc
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in \
+       $(NULL)
+
+CLEANFILES = \
+       config.py \
+       $(NULL)
+
+dist_ovirthostmgmtlib_PYTHON = \
+       __init__.py \
+       constants.py \
+       $(NULL)
+
+ovirthostmgmtlib_PYTHON = \
+       config.py \
+       $(NULL)
+
+config.py:     \
+       $(top_srcdir)/configure.ac \
+       $(NULL)
+
+clean-local: \
+       python-clean \
+       $(NULL)
+
+all-local: \
+       python-syntax-check \
+       $(NULL)
diff --git a/src/ovirt_host_mgmt/__init__.py b/src/ovirt_host_mgmt/__init__.py
new file mode 100644
index 0000000..00d5b93
--- /dev/null
+++ b/src/ovirt_host_mgmt/__init__.py
@@ -0,0 +1,27 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""ovirt-host-deploy module."""
+
+
+__all__ = []
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/ovirt_host_mgmt/config.py.in b/src/ovirt_host_mgmt/config.py.in
new file mode 100644
index 0000000..7c63b3a
--- /dev/null
+++ b/src/ovirt_host_mgmt/config.py.in
@@ -0,0 +1,29 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""Constants."""
+
+
+PACKAGE_NAME = '@PACKAGE_NAME@'
+PACKAGE_VERSION = '@PACKAGE_VERSION@'
+LOCAL_VERSION = '@LOCAL_VERSION@'
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/ovirt_host_mgmt/constants.py b/src/ovirt_host_mgmt/constants.py
new file mode 100644
index 0000000..27f60c6
--- /dev/null
+++ b/src/ovirt_host_mgmt/constants.py
@@ -0,0 +1,56 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""Constants."""
+
+
+from otopi import util
+
+
+@util.export
+class FileLocations(object):
+    OVIRT_HOST_MGMT_CONFIG_FILE = '/etc/ovirt-host-mgmt.conf'
+
+    OVIRT_HOST_MGMT_LOG_PREFIX = 'ovirt-host-mgmt'
+
+
+@util.export
+@util.codegen
+class Const(object):
+    PACKAGES_UPDATE_MODE_DISABLED = "disabled"
+    PACKAGES_UPDATE_MODE_CHECK_UPDATE = "checkUpdate"
+    PACKAGES_UPDATE_MODE_UPDATE = "update"
+
+
+@util.export
+@util.codegen
+class CoreEnv(object):
+    OFFLINE_PACKAGER = 'OMGMT_CORE/offlinePackager'
+
+
+@util.export
+@util.codegen
+class PackagesEnv(object):
+    UPDATE_MODE = 'OMGMT_PACKAGES/packagesUpdateMode'
+    PACKAGES = 'OMGMT_PACKAGES/packages'
+    PACKAGES_INFO = 'OMGMT_PACKAGES/packagesInfo'
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 8bde47d..8cb3a8f 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -23,4 +23,5 @@
 
 SUBDIRS = \
        ovirt-host-deploy \
+       ovirt-host-mgmt \
        $(NULL)
diff --git a/src/plugins/ovirt-host-mgmt/Makefile.am 
b/src/plugins/ovirt-host-mgmt/Makefile.am
new file mode 100644
index 0000000..419a11a
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/Makefile.am
@@ -0,0 +1,32 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in \
+       $(NULL)
+
+SUBDIRS = \
+       core \
+       packages \
+       $(NULL)
+
+install-data-local:
+       $(MKDIR_P) "$(DESTDIR)$(otopiplugindir)"
+       rm -f "$(DESTDIR)$(otopiplugindir)/ovirt-host-mgmt"
+       ln -s "$(ovirthostdeployplugindir)/ovirt-host-mgmt" 
"$(DESTDIR)$(otopiplugindir)/ovirt-host-mgmt"
diff --git a/src/plugins/ovirt-host-mgmt/core/Makefile.am 
b/src/plugins/ovirt-host-mgmt/core/Makefile.am
new file mode 100644
index 0000000..600676b
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/core/Makefile.am
@@ -0,0 +1,39 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+include $(top_srcdir)/build/python.inc
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in \
+       $(NULL)
+
+mydir=$(ovirthostdeployplugindir)/ovirt-host-mgmt/core
+dist_my_PYTHON = \
+       __init__.py \
+       misc.py \
+       offlinepackager.py \
+       $(NULL)
+
+clean-local: \
+       python-clean \
+       $(NULL)
+
+all-local: \
+       python-syntax-check \
+       $(NULL)
diff --git a/src/plugins/ovirt-host-mgmt/core/__init__.py 
b/src/plugins/ovirt-host-mgmt/core/__init__.py
new file mode 100644
index 0000000..0c07c0d
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/core/__init__.py
@@ -0,0 +1,37 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""vdsm core plugin."""
+
+
+from otopi import util
+
+
+from . import misc
+from . import offlinepackager
+
+
+@util.export
+def createPlugins(context):
+    misc.Plugin(context=context)
+    offlinepackager.Plugin(context=context)
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-host-mgmt/core/misc.py 
b/src/plugins/ovirt-host-mgmt/core/misc.py
new file mode 100644
index 0000000..3856e67
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/core/misc.py
@@ -0,0 +1,86 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""Misc plugin."""
+
+
+import gettext
+import os
+
+
+from otopi import constants as otopicons
+from otopi import plugin
+from otopi import util
+
+
+from ovirt_host_mgmt import config
+from ovirt_host_mgmt import constants as omgmt
+
+
+def _(m):
+    return gettext.dgettext(message=m, domain='ovirt-host-deploy')
+
+
+@util.export
+class Plugin(plugin.PluginBase):
+    """Misc plugin."""
+
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_BOOT,
+        before=(
+            otopicons.Stages.CORE_LOG_INIT,
+            otopicons.Stages.CORE_CONFIG_INIT,
+        ),
+    )
+    def _preinit(self):
+        self.environment.setdefault(
+            otopicons.CoreEnv.LOG_FILE_NAME_PREFIX,
+            omgmt.FileLocations.OVIRT_HOST_MGMT_LOG_PREFIX
+        )
+        self.environment.setdefault(
+            otopicons.CoreEnv.CONFIG_FILE_NAME,
+            self.resolveFile(
+                os.environ.get(
+                    otopicons.SystemEnvironment.CONFIG,
+                    self.resolveFile(
+                        omgmt.FileLocations.OVIRT_HOST_MGMT_CONFIG_FILE
+                    )
+                )
+            )
+        )
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_SETUP,
+        priority=plugin.Stages.PRIORITY_HIGH,
+    )
+    def _setup(self):
+        self.dialog.note(
+            text=_('Version: {package}-{version} ({local_version})').format(
+                package=config.PACKAGE_NAME,
+                version=config.PACKAGE_VERSION,
+                local_version=config.LOCAL_VERSION,
+            )
+        )
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-host-mgmt/core/offlinepackager.py 
b/src/plugins/ovirt-host-mgmt/core/offlinepackager.py
new file mode 100644
index 0000000..56fda45
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/core/offlinepackager.py
@@ -0,0 +1,70 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""Fake packager for offline mode"""
+
+
+import gettext
+
+
+from otopi import constants as otopicons
+from otopi import packager
+from otopi import plugin
+from otopi import util
+
+
+from ovirt_host_mgmt import constants as omgmtcons
+
+
+def _(m):
+    return gettext.dgettext(message=m, domain='ovirt-host-deploy')
+
+
+@util.export
+class Plugin(plugin.PluginBase, packager.PackagerBase):
+    """Offline packager."""
+    def install(self, packages, ignoreErrors=False):
+        pass
+
+    def update(self, packages, ignoreErrors=False):
+        pass
+
+    def queryPackages(self, patterns=None):
+        return []
+
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_INIT,
+        after=(
+            otopicons.Stages.PACKAGERS_DETECTION,
+        ),
+    )
+    def _init(self):
+        if self.environment.setdefault(
+            omgmtcons.CoreEnv.OFFLINE_PACKAGER,
+            False
+        ):
+            self.logger.debug('Registering offline packager')
+            self.context.registerPackager(packager=self)
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-host-mgmt/packages/Makefile.am 
b/src/plugins/ovirt-host-mgmt/packages/Makefile.am
new file mode 100644
index 0000000..8ead29f
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/packages/Makefile.am
@@ -0,0 +1,38 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+include $(top_srcdir)/build/python.inc
+
+MAINTAINERCLEANFILES = \
+       $(srcdir)/Makefile.in \
+       $(NULL)
+
+mydir=$(ovirthostdeployplugindir)/ovirt-host-mgmt/packages
+dist_my_PYTHON = \
+       __init__.py \
+       update.py \
+       $(NULL)
+
+clean-local: \
+       python-clean \
+       $(NULL)
+
+all-local: \
+       python-syntax-check \
+       $(NULL)
diff --git a/src/plugins/ovirt-host-mgmt/packages/__init__.py 
b/src/plugins/ovirt-host-mgmt/packages/__init__.py
new file mode 100644
index 0000000..373451e
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/packages/__init__.py
@@ -0,0 +1,35 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""vdsm core plugin."""
+
+
+from otopi import util
+
+
+from . import update
+
+
+@util.export
+def createPlugins(context):
+    update.Plugin(context=context)
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-host-mgmt/packages/update.py 
b/src/plugins/ovirt-host-mgmt/packages/update.py
new file mode 100644
index 0000000..86e5d79
--- /dev/null
+++ b/src/plugins/ovirt-host-mgmt/packages/update.py
@@ -0,0 +1,141 @@
+#
+# ovirt-host-deploy -- ovirt host deployer
+# Copyright (C) 2012-2015 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+
+"""Misc plugin."""
+
+
+import gettext
+import platform
+
+
+from otopi import plugin
+from otopi import util
+
+
+from ovirt_host_mgmt import constants as omgmt
+
+
+def _(m):
+    return gettext.dgettext(message=m, domain='ovirt-host-deploy')
+
+
+@util.export
+class Plugin(plugin.PluginBase):
+    """Packages plugin."""
+
+    def __init__(self, context):
+        super(Plugin, self).__init__(context=context)
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_INIT,
+    )
+    def _init(self):
+        self.environment.setdefault(
+            omgmt.PackagesEnv.UPDATE_MODE,
+            omgmt.Const.PACKAGES_UPDATE_MODE_DISABLED
+        )
+        self.environment.setdefault(
+            omgmt.PackagesEnv.PACKAGES,
+            []
+        )
+        self.environment[omgmt.PackagesEnv.PACKAGES_INFO] = []
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_PACKAGES,
+        condition=lambda self: (
+            self.environment[
+                omgmt.PackagesEnv.UPDATE_MODE
+            ] == omgmt.Const.PACKAGES_UPDATE_MODE_CHECK_UPDATE
+        ),
+    )
+    def _packagesCheck(self):
+        info = []
+        if platform.linux_distribution(
+            full_distribution_name=0
+        )[0] not in ('redhat', 'fedora', 'centos', 'ibm_powerkvm'):
+            for entry in self.packager.queryPackages(
+                patterns=self.environment[omgmt.PackagesEnv.PACKAGES],
+            ):
+                if entry['operation'] in ('available', 'updates'):
+                    info.append(
+                        '%s-%s-%s' % (
+                            entry['name'],
+                            entry['version'],
+                            entry['release'],
+                        )
+                    )
+        else:
+            from otopi import miniyum
+
+            class MyMiniYumSink(miniyum.MiniYumSinkBase):
+                def __init__(self, log):
+                    super(MyMiniYumSink, self).__init__()
+                    self._log = log
+
+                def verbose(self, msg):
+                    super(MyMiniYumSink, self).verbose(msg)
+                    self._log.debug('Yum: %s', msg)
+
+                def info(self, msg):
+                    super(MyMiniYumSink, self).info(msg)
+                    self._log.info('Yum: %s', msg)
+
+                def error(self, msg):
+                    super(MyMiniYumSink, self).error(msg)
+                    self._log.error('Yum: %s', msg)
+
+            myum = miniyum.MiniYum(
+                sink=MyMiniYumSink(self.logger),
+                disabledPlugins=('versionlock',),
+            )
+            with myum.transaction():
+                myum.install(
+                    packages=self.environment[omgmt.PackagesEnv.PACKAGES],
+                )
+                myum.update(
+                    packages=self.environment[omgmt.PackagesEnv.PACKAGES],
+                )
+                if myum.buildTransaction():
+                    for entry in myum.queryTransaction():
+                        if entry['operation'] in ('update', 'install'):
+                            info.append(
+                                '%s-%s-%s' % (
+                                    entry['name'],
+                                    entry['version'],
+                                    entry['release'],
+                                )
+                            )
+        self.environment[omgmt.PackagesEnv.PACKAGES_INFO] = info
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_PACKAGES,
+        condition=lambda self: (
+            self.environment[
+                omgmt.PackagesEnv.UPDATE_MODE
+            ] == omgmt.Const.PACKAGES_UPDATE_MODE_UPDATE
+        ),
+    )
+    def _packagesUpdate(self):
+        self.packager.installUpdate(
+            packages=self.environment[omgmt.PackagesEnv.PACKAGES],
+        )
+
+
+# vim: expandtab tabstop=4 shiftwidth=4


-- 
To view, visit https://gerrit.ovirt.org/39988
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2fdfad98664fca4351ae1914b7d51cf507d347bf
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-host-deploy
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: automat...@ovirt.org
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to