Martin Peřina has uploaded a new change for review. Change subject: node: Determine node version ......................................................................
node: Determine node version Adds plugin to determine node version. Change-Id: Icfa4fb729cb2db3fba9076a1184d2906cee06868 Bug-Url: https://bugzilla.redhat.com/1079821 Signed-off-by: Martin Perina <[email protected]> --- M src/ovirt_host_deploy/constants.py A src/plugins/ovirt-host-deploy/node/version.py 2 files changed, 77 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy refs/changes/03/29503/1 diff --git a/src/ovirt_host_deploy/constants.py b/src/ovirt_host_deploy/constants.py index d9a1793..3f9dec1 100644 --- a/src/ovirt_host_deploy/constants.py +++ b/src/ovirt_host_deploy/constants.py @@ -115,6 +115,7 @@ CHECK_VIRT_HARDWARE = 'VDSM/checkVirtHardware' OVIRT_NODE = 'VDSM/node' OVIRT_NODE_HAS_OWN_BRIDGES = 'VDSM/nodeHasOwnBridges' + OVIRT_NODE_VERSION = 'VDSM/nodeVersion' CONFIG_OVERRIDE = 'VDSM/configOverride' DISABLE_NETWORKMANAGER = 'VDSM/disableNetworkManager' CONFIG_PREFIX = 'VDSM_CONFIG/' diff --git a/src/plugins/ovirt-host-deploy/node/version.py b/src/plugins/ovirt-host-deploy/node/version.py new file mode 100644 index 0000000..52c1b88 --- /dev/null +++ b/src/plugins/ovirt-host-deploy/node/version.py @@ -0,0 +1,76 @@ +# ovirt-host-deploy -- ovirt host deployer +# Copyright (C) 2012-2014 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 +# + + +"""determine node version.""" + +from ovirt_host_deploy import constants as odeploycons + + [email protected] +class Plugin(plugin.PluginBase): + """Determines node version + + Environment: + VdsmEnv.OVIRT_NODE_VERSION + + """ + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + def _get_node_version(self, file): + version = None + try: + with open(file) as f: + version = f.read().strip('\n') + except (IOError, OSError, ValueError): + self.logger.debug( + 'Error getting node version', + exc_info=True, + ) + + return version + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + condition=lambda self: self.environment[ + odeploycons.VdsmEnv.OVIRT_NODE + ], + ) + def _init(self): + nodeVersion = None + if os.path.exists('/etc/rhev-hypervisor-release'): + nodeVersion = self._get_node_version('/etc/rhev-hypervisor-release') + else: + version_files = glob.glob('/etc/ovirt-node-*-release') + from distutils.version import LooseVersion + for file in version_files: + version = self._get_node_version(file) + if ( + version is not None and + ( + nodeVersion is None or + LooseVersion(version) > LooseVersion(nodeVersion) + ) + ): + nodeVersion = version + + self.environment.setdefault( + odeploycons.VdsmEnv.OVIRT_NODE_VERSION, + nodeVersion + ) -- To view, visit http://gerrit.ovirt.org/29503 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icfa4fb729cb2db3fba9076a1184d2906cee06868 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-host-deploy Gerrit-Branch: master Gerrit-Owner: Martin Peřina <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
