Change in vdsm[master]: [wip] Adding cron job check for available updates of vdsm pa...

2015-03-15 Thread automation
automat...@ovirt.org has posted comments on this change.

Change subject: [wip] Adding cron job check for available updates of vdsm 
packages
..


Patch Set 1:

* Update tracker::IGNORE, no Bug-Url found
* Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' 
and is a valid url.
* Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 
'ovirt-3.4', 'ovirt-3.3'])

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I1f6b83e1c18c05142da095b0b537fa6d9aecb59e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim ybron...@redhat.com
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: [wip] Adding cron job check for available updates of vdsm pa...

2015-03-05 Thread oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.

Change subject: [wip] Adding cron job check for available updates of vdsm 
packages
..


Patch Set 1:

Build Failed 

http://jenkins.ovirt.org/job/vdsm_master_install-rpm-sanity-el7_created/534/ : 
FAILURE

http://jenkins.ovirt.org/job/vdsm_master_install-rpm-sanity-fc21_created/526/ : 
SUCCESS

http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/16261/ : SUCCESS

http://jenkins.ovirt.org/job/vdsm_master_install-rpm-sanity-el6_created/1092/ : 
FAILURE

http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/15461/ : FAILURE

http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/16431/ : SUCCESS

http://jenkins.ovirt.org/job/vdsm_master_install-rpm-sanity-fc20_created/1075/ 
: SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I1f6b83e1c18c05142da095b0b537fa6d9aecb59e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim ybron...@redhat.com
Gerrit-Reviewer: Dan Kenigsberg dan...@redhat.com
Gerrit-Reviewer: Oved Ourfali oourf...@redhat.com
Gerrit-Reviewer: Yeela Kaplan ykap...@redhat.com
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: [wip] Adding cron job check for available updates of vdsm pa...

2015-03-05 Thread ybronhei
Yaniv Bronhaim has uploaded a new change for review.

Change subject: [wip] Adding cron job check for available updates of vdsm 
packages
..

[wip] Adding cron job check for available updates of vdsm packages

This patch adds python tool for packages management which checks for
available updates and run as cron job. The tool is generic and currently
implemented for yum and dnf.
The packages list is written to a file readable for vdsm. In following
patch vdsm will expose the list via api.

Change-Id: I1f6b83e1c18c05142da095b0b537fa6d9aecb59e
Signed-off-by: Yaniv Bronhaim bronh...@gmail.com
---
M debian/vdsm.install
M vdsm.spec.in
A vdsm/AvailableUpdates
M vdsm/Makefile.am
A vdsm/vdsm-packages-update
5 files changed, 133 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/38401/1

diff --git a/debian/vdsm.install b/debian/vdsm.install
index cd71517..761e26b 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -1,4 +1,5 @@
 ./etc/cron.d/vdsm-libvirt-logrotate
+./etc/cron.d/vdsm-packages-update
 ./etc/cron.hourly/vdsm-logrotate
 ./etc/dhcp/dhclient.d/sourceRoute.sh
 ./etc/init/supervdsmd.conf
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 0740530..9652889 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1095,6 +1095,7 @@
 %{_sysconfdir}/sudoers.d/50_vdsm
 %{_sysconfdir}/cron.hourly/vdsm-logrotate
 %{_sysconfdir}/cron.d/vdsm-libvirt-logrotate
+%{_sysconfdir}/cron.d/vdsm-packages-update
 %if 0%{?fedora} || 0%{?rhel} = 7
 %{_sysconfdir}/libvirt/hooks/qemu
 %endif
@@ -1231,6 +1232,7 @@
 %dir %{_libexecdir}/%{vdsm_name}/hooks/before_get_caps
 %dir %{_libexecdir}/%{vdsm_name}/hooks/after_get_caps
 %{_datadir}/%{vdsm_name}/addNetwork
+%{_datadir}/%{vdsm_name}/AvailableUpdates
 %{_datadir}/%{vdsm_name}/delNetwork
 %{_datadir}/%{vdsm_name}/dumpStorageTable.py*
 %{_datadir}/%{vdsm_name}/get-conf-item
diff --git a/vdsm/AvailableUpdates b/vdsm/AvailableUpdates
new file mode 100755
index 000..89a2a2d
--- /dev/null
+++ b/vdsm/AvailableUpdates
@@ -0,0 +1,124 @@
+#!/bin/python
+try:
+import yum
+yumSupport = True
+except ImportError:
+yumSupport = False
+print 'not available yum support'
+
+try:
+import dnf
+dnfSupport = True
+except ImportError:
+dnfSupport = False
+print 'not available dnf support'
+
+import datetime
+import sys
+import syslog
+import stat
+import os
+
+def time():
+return datetime.datetime.now().time().isoformat()
+
+def outputPrint(out):
+syslog.syslog(%s: %s\n % (time(), out))
+
+
+# pkgUpdater refresh installed packages cache and return list of available
+# updates. pkgProvider can be yum, apt-get, dnf
+class AvailableUpdates():
+def __init__(self, pkgProvider):
+self.provider = pkgProvider()
+self.ups = None
+
+def refreshUpdates(self):
+self._cleanCache()
+self.ups = self.provider.getUpdates()
+return self.ups
+
+def getCacheUpdates(self):
+self.ups = self.provider.getUpdates()
+return self.ups
+
+def writeUpdates(self, pkgs, output):
+pkgInfo = []
+if self.ups:
+for trns in self.ups:
+if pkgs is None or trns.name in pkgs:
+pkg = %s.%s %s-%s % (trns.name, trns.arch,
+   trns.version, trns.release)
+pkgInfo.append(pkg)
+output.write(pkg + '\n')
+
+return pkgInfo
+
+def _cleanCache(self):
+if not self.provider.cleanCache():
+print 'failed to clean cache'
+
+if yumSupport:
+class YumProvider(yum.YumBase):
+def __init__(self):
+yum.YumBase.__init__(self)
+
+def getUpdates(self):
+return self.update()
+
+def cleanCache(self):
+return self.provider.cleanExpireCache() and \
+   self.provider.cleanRpmDB()
+
+if dnfSupport:
+class DnfProvider(dnf.Base):
+def __init__(self):
+dnf.Base.__init__(self)
+
+def getUpdates(self):
+# WIP
+pass
+
+def cleanCache(self):
+# WIP
+pass
+
+
+if __name__ == '__main__':
+if len(sys.argv)  2:
+sys.stdout.write(please provide output file (see --help)\n)
+exit(1)
+
+if sys.argv[1] == '--help':
+sys.stdout.write(
+Usage: AvailableUpdates [output-file] [list-of-packages]\n)
+sys.stdout.write(
+e.g. AvailableUpdates /tmp/out ['vdsm', 'libvirt', 'mom']\n)
+exit(1)
+
+pkgList = None
+if len(sys.argv)  3 or not isinstance(sys.argv[2], list):
+outputPrint(err in list-of-packages argument - checking all packages)
+else:
+pkgList = sys.argv[2]
+outputPrint(checking updates for: %s % (pkgList))
+
+outputPrint('creating provider')
+if yumSupport:
+au = AvailableUpdates(YumProvider)
+elif