[virt-who] Fixed unittest for python < 2.7
by Radek Novacek
commit 7bd98cea21e7d5b66e48af2aab1bf5ed0c100ae3
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Tue Aug 23 12:06:16 2011 +0200
Fixed unittest for python < 2.7
test.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/test.py b/test.py
index f86a068..b40ecda 100644
--- a/test.py
+++ b/test.py
@@ -33,7 +33,7 @@ class VirtTest(unittest.TestCase):
self.virt = Virt(logger)
def test_connection(self):
- self.assertGreater(self.virt.virt.getVersion(), 0)
+ self.assertTrue(self.virt.virt.getVersion() > 0)
def test_listDomains(self):
uuids = []
@@ -46,7 +46,7 @@ class VirtTest(unittest.TestCase):
continue
domId = line.split()[1]
uuid = subprocess.Popen(["virsh", "-r", "domuuid", domId], stdout=subprocess.PIPE).communicate()[0].strip()
- self.assertIn(uuid, uuids, "virsh returns more domains then virt-who (%s)" % uuid)
+ self.assertTrue(uuid in uuids, "virsh returns more domains then virt-who (%s)" % uuid)
uuids.remove(uuid)
self.assertEqual(len(uuids), 0, "virsh returns less domains then virt-who (%s)" % ",".join(uuids))
12 years, 8 months
[virt-who] Version 0.2
by Radek Novacek
commit b8df47b9591abe43365b791b5fad1601164e95a5
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Aug 22 10:41:58 2011 +0200
Version 0.2
Makefile | 2 +-
virt-who.spec | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/Makefile b/Makefile
index c59da3d..83ba8e1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
name = virt-who
-version = 0.1
+version = 0.2
.PHONY: pack check install srpm rpm rpmlint upload
diff --git a/virt-who.spec b/virt-who.spec
index 94c6bb7..548593e 100644
--- a/virt-who.spec
+++ b/virt-who.spec
@@ -1,6 +1,6 @@
Name: virt-who
-Version: 0.1
-Release: 2%{?dist}
+Version: 0.2
+Release: 1%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager
Group: System Environment/Base
@@ -12,6 +12,7 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: noarch
BuildRequires: python2-devel
Requires: libvirt-python
+Requires: libvirt
Requires: python-rhsm
%description
@@ -44,6 +45,10 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Mon Aug 22 2011 Radek Novacek <rnovacek(a)redhat.com> - 0.2-1
+- Update to upstream version 0.2
+- Add Requires: libvirt
+
* Fri Aug 19 2011 Radek Novacek <rnovacek(a)redhat.com> - 0.1-2
- Add BuildRoot tag (the package will be in RHEL5)
12 years, 8 months
[virt-who] Makefile: don't pack if tarball exists
by Radek Novacek
commit 70da860dde721539e12336cc36546db82c0bc8b2
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Aug 22 10:41:15 2011 +0200
Makefile: don't pack if tarball exists
Makefile | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/Makefile b/Makefile
index 7934f80..c59da3d 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,11 @@ version = 0.1
.PHONY: pack check install srpm rpm rpmlint upload
-pack:
+$(name)-$(version).tar.gz:
git archive --format=tar --prefix=$(name)-$(version)/ master | gzip > $(name)-$(version).tar.gz
+pack: $(name)-$(version).tar.gz
+
check:
pyflakes *.py
12 years, 8 months
[virt-who] Move handling libvirt errors before connection to libvirtd
by Radek Novacek
commit aaa51d389f072ff54abf4df5a8e78381efee4a1d
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Aug 22 10:29:47 2011 +0200
Move handling libvirt errors before connection to libvirtd
virt.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/virt.py b/virt.py
index 0163c00..2b8ef16 100644
--- a/virt.py
+++ b/virt.py
@@ -28,12 +28,13 @@ class Virt:
def __init__(self, logger):
self.changedCallback = None
self.logger = logger
+ self.virt = None
+ # Log libvirt errors
+ libvirt.registerErrorHandler(lambda ctx, error: self.logger.debug(error), None)
try:
self.virt = libvirt.openReadOnly("")
except libvirt.libvirtError, e:
raise VirtError(str(e))
- # Log libvirt errors
- libvirt.registerErrorHandler(lambda ctx, error: self.logger.debug(error), None)
def listDomains(self):
""" Get list of all domains. """
@@ -54,7 +55,8 @@ class Virt:
return domains
def __del__(self):
- self.virt.close()
+ if self.virt:
+ self.virt.close()
def changed(self, conn, dom, event, detail, opaque):
print "EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), eventToString(event), detailToString(event, detail))
12 years, 8 months
[virt-who] Handle error in creating libvirt object
by Radek Novacek
commit d16a5fb2ad16bb1b344747657fc58e4271c96850
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Aug 22 10:24:35 2011 +0200
Handle error in creating libvirt object
virt-who.py | 8 ++++++--
virt.py | 8 +++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/virt-who.py b/virt-who.py
index 29d2fbf..8c52701 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -22,7 +22,7 @@ import sys
import os
import time
-from virt import Virt
+from virt import Virt, VirtError
from event import virEventLoopPureStart
from subscriptionmanager import SubscriptionManager
@@ -60,7 +60,11 @@ if __name__ == '__main__':
logger.error("Error in reading configuration file (/etc/rhsm/rhsm.conf): %s" % e)
sys.exit(2)
- virt = Virt(logger)
+ try:
+ virt = Virt(logger)
+ except VirtError, e:
+ print e
+ sys.exit(3)
subscriptionManager.connect()
diff --git a/virt.py b/virt.py
index 206ff6f..0163c00 100644
--- a/virt.py
+++ b/virt.py
@@ -20,12 +20,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import libvirt
+class VirtError(Exception):
+ pass
+
class Virt:
""" Class for interacting with libvirt. """
def __init__(self, logger):
self.changedCallback = None
self.logger = logger
- self.virt = libvirt.openReadOnly("")
+ try:
+ self.virt = libvirt.openReadOnly("")
+ except libvirt.libvirtError, e:
+ raise VirtError(str(e))
# Log libvirt errors
libvirt.registerErrorHandler(lambda ctx, error: self.logger.debug(error), None)
12 years, 8 months
[virt-who] Increase release version in specfile
by Radek Novacek
commit 9ad1882cd23de403f46da08460ad93a167eb4d36
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Aug 19 10:32:19 2011 +0200
Increase release version in specfile
virt-who.spec | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/virt-who.spec b/virt-who.spec
index 537ca78..94c6bb7 100644
--- a/virt-who.spec
+++ b/virt-who.spec
@@ -1,6 +1,6 @@
Name: virt-who
Version: 0.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager
Group: System Environment/Base
@@ -44,5 +44,8 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Fri Aug 19 2011 Radek Novacek <rnovacek(a)redhat.com> - 0.1-2
+- Add BuildRoot tag (the package will be in RHEL5)
+
* Wed Aug 10 2011 Radek Novacek <rnovacek(a)redhat.com> - 0.1-1
- initial import
12 years, 8 months
[virt-who] Fix bug in logging to rhsm.log
by Radek Novacek
commit df5d0570b341c352fcf200dc405ced3f96f7dc78
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Aug 19 10:22:39 2011 +0200
Fix bug in logging to rhsm.log
log.py | 7 +++----
virt-who.py | 4 +++-
2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/log.py b/log.py
index b965482..eb99cd5 100644
--- a/log.py
+++ b/log.py
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import logging
+import logging.handlers
import os
def init_logger():
@@ -37,11 +38,9 @@ def _get_handler():
# Try to write to /var/log, fallback on console logging:
try:
handler = logging.handlers.RotatingFileHandler(path, maxBytes=0x100000, backupCount=5)
- except IOError:
- handler = logging.StreamHandler()
- except:
+ except Exception, e:
+ sys.stderr.write("Unable to log to %s: %s\n" % (path, e))
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(fmt))
-
return handler
diff --git a/virt-who.py b/virt-who.py
index caf3918..29d2fbf 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -46,8 +46,10 @@ if __name__ == '__main__':
(options, args) = parser.parse_args()
if options.debug:
- # Enable debugging
+ # Enable debugging output to be writen in /var/log
logger.setLevel(logging.DEBUG)
+ # Print debugging output to stderr too
+ logger.addHandler(logging.StreamHandler())
if options.background:
virEventLoopPureStart()
12 years, 8 months
[virt-who] Handle error in reading rhsm.conf
by Radek Novacek
commit 9fd5fd8a573c585f49f82b792f5193db284bc182
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Aug 19 10:20:45 2011 +0200
Handle error in reading rhsm.conf
subscriptionmanager.py | 1 +
virt-who.py | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/subscriptionmanager.py b/subscriptionmanager.py
index c6e8216..1ccc3aa 100644
--- a/subscriptionmanager.py
+++ b/subscriptionmanager.py
@@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
import os
+import sys
import rhsm.connection as rhsm_connection
import rhsm.certificate as rhsm_certificate
diff --git a/virt-who.py b/virt-who.py
index 4537400..caf3918 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -31,6 +31,8 @@ import log
from optparse import OptionParser
+from ConfigParser import NoOptionError
+
if __name__ == '__main__':
log.init_logger()
@@ -50,7 +52,12 @@ if __name__ == '__main__':
if options.background:
virEventLoopPureStart()
- subscriptionManager = SubscriptionManager(logger)
+ try:
+ subscriptionManager = SubscriptionManager(logger)
+ except NoOptionError, e:
+ logger.error("Error in reading configuration file (/etc/rhsm/rhsm.conf): %s" % e)
+ sys.exit(2)
+
virt = Virt(logger)
subscriptionManager.connect()
12 years, 8 months
[virt-who] Add missing targets to .PHONY in Makefile
by Radek Novacek
commit 568ccbdcb4e463d99d43b6a98064097345fdcdf7
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Aug 19 09:07:52 2011 +0200
Add missing targets to .PHONY in Makefile
Makefile | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/Makefile b/Makefile
index 8636c90..7934f80 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,8 @@
name = virt-who
version = 0.1
-.PHONY: pack check install srpm rpm
+.PHONY: pack check install srpm rpm rpmlint upload
+
pack:
git archive --format=tar --prefix=$(name)-$(version)/ master | gzip > $(name)-$(version).tar.gz
12 years, 8 months
[virt-who] Add BuildRoot tag to specfile (needed for RHEL5)
by Radek Novacek
commit 3523ade2115c21348160127259f40f06f9646078
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Thu Aug 18 11:13:30 2011 +0200
Add BuildRoot tag to specfile (needed for RHEL5)
virt-who.spec | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/virt-who.spec b/virt-who.spec
index 0919dde..537ca78 100644
--- a/virt-who.spec
+++ b/virt-who.spec
@@ -2,11 +2,12 @@ Name: virt-who
Version: 0.1
Release: 1%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager
-Group: System Environment/Base
+Group: System Environment/Base
License: GPLv2+
URL: https://fedorahosted.org/virt-who/
Source0: https://fedorahosted.org/releases/v/i/virt-who/%{name}-%{version}.tar.gz
+BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: noarch
BuildRequires: python2-devel
12 years, 8 months