[virt-who] Add gitignore
by Radek Novacek
commit ebd42446f92495c57666107e1570597f9d8c87cc
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Aug 17 11:27:01 2011 +0200
Add gitignore
.gitignore | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b10388a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+*.pyc
+*~
+*.rpm
+*.tar.gz
+noarch/
+.*
+
12 years, 8 months
[virt-who] Add specfile
by Radek Novacek
commit 167cc0026f442cbd92bb8d8c2c413304da7245de
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Aug 17 11:25:05 2011 +0200
Add specfile
virt-who.spec | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/virt-who.spec b/virt-who.spec
new file mode 100644
index 0000000..cc743b4
--- /dev/null
+++ b/virt-who.spec
@@ -0,0 +1,47 @@
+Name: virt-who
+Version: 0.1
+Release: 1%{?dist}
+Summary: Agent for reporting virtual guest IDs to subscription-manager
+Group: System Environment/Base
+
+License: GPLv2+
+URL: https://fedorahosted.org/virt-who/
+Source0: https://fedorahosted.org/virt-who/%{name}-%{version}.tar.gz
+
+BuildArch: noarch
+BuildRequires: python2-devel
+Requires: libvirt-python
+Requires: python-rhsm
+
+%description
+Agent that collects information about virtual guests present in the system and
+report them to the subscription manager.
+
+%prep
+%setup -q
+
+
+%build
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+make DESTDIR=$RPM_BUILD_ROOT install
+
+# Don't run test suite in check section, because it need the system to be
+# registered to subscription-manager server
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%doc README LICENSE
+%{_bindir}/virt-who
+%{_datadir}/virt-who/
+
+
+%changelog
+* Wed Aug 10 2011 Radek Novacek <rnovacek(a)redhat.com> - 0.1-1
+- initial import
12 years, 8 months
[virt-who] Use PWD variable instead of calling pwd command in makefile
by Radek Novacek
commit 8c9a3dd65a48d0be74c4223ed62e554587a21812
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Aug 17 11:22:13 2011 +0200
Use PWD variable instead of calling pwd command in makefile
Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/Makefile b/Makefile
index 35bf52c..20de009 100644
--- a/Makefile
+++ b/Makefile
@@ -15,10 +15,10 @@ install:
install virt-who $(DESTDIR)/usr/bin/
srpm: pack
- rpmbuild --define "_sourcedir `pwd`" --define "_specdir `pwd`" --define "_srcrpmdir `pwd`" -bs $(name).spec
+ rpmbuild --define "_sourcedir $(PWD)" --define "_specdir $(PWD)" --define "_srcrpmdir $(PWD)" -bs $(name).spec
rpm: pack
- rpmbuild --define "_sourcedir `pwd`" --define "_specdir `pwd`" --define "_srcrpmdir `pwd`" --define "_rpmdir `pwd`" -bb $(name).spec
+ rpmbuild --define "_sourcedir $(PWD)" --define "_specdir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)" -bb $(name).spec
rpmlint: srpm rpm
rpmlint $(name).spec $(shell rpmspec -q $(name).spec | sed 's/.noarch//').src.rpm noarch/$(shell rpmspec -q $(name).spec).rpm
12 years, 8 months
[virt-who] Add 'make rpmlint' option
by Radek Novacek
commit 2e2aef49bed8422330a27ea726332d5257d05779
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Aug 17 11:19:01 2011 +0200
Add 'make rpmlint' option
Makefile | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/Makefile b/Makefile
index 8fc3f36..35bf52c 100644
--- a/Makefile
+++ b/Makefile
@@ -20,3 +20,5 @@ srpm: pack
rpm: pack
rpmbuild --define "_sourcedir `pwd`" --define "_specdir `pwd`" --define "_srcrpmdir `pwd`" --define "_rpmdir `pwd`" -bb $(name).spec
+rpmlint: srpm rpm
+ rpmlint $(name).spec $(shell rpmspec -q $(name).spec | sed 's/.noarch//').src.rpm noarch/$(shell rpmspec -q $(name).spec).rpm
12 years, 8 months
[virt-who] Readme
by Radek Novacek
commit ac6fa2eccec0dd3633611e333e30ffbc4877b395
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Aug 17 10:48:02 2011 +0200
Readme
README | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/README b/README
index e69de29..0c793d8 100644
--- a/README
+++ b/README
@@ -0,0 +1,34 @@
+virt-who is agent for reporting virtual guest IDs to subscription-manager.
+
+It uses libvirt-python to obtain UUIDs of all virtual guests present
+in the system (both running and stopped). It then connects to
+subscription-manager server (candlepin) and set the list of UUIDs to facts
+about host system.
+
+
+Installation
+------------
+To just install it use:
+
+# make DESTDIR=/usr install
+
+You can also create rpm package with:
+
+$ make rpm
+
+and then install the package
+
+
+Configuration
+-------------
+
+It uses rhsm configuration (usually in /etc/rhsm/rhsm.conf). The system needs
+to be registered in subscription-manager server before running the agent.
+
+Usage
+-----
+
+This agent has two modes of running. First [default] is to obtain UUIDs, send
+them to the server and exit. Second mode is running in infinite loop and
+monitor guests UUIDs changes. When some change happens it will be immediately
+send.
12 years, 8 months
[virt-who] Add some unit tests
by Radek Novacek
commit bc0ecf0d964fb9ac16bfe7733193b4fc40102df3
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Tue Aug 16 11:51:37 2011 +0200
Add some unit tests
test.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..f86a068
--- /dev/null
+++ b/test.py
@@ -0,0 +1,83 @@
+"""
+Testing module, part of virt-who
+
+Copyright (C) 2011 Radek Novacek <rnovacek(a)redhat.com>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+"""
+
+import unittest
+import logging
+import subprocess
+import os
+
+from virt import Virt
+from subscriptionmanager import SubscriptionManager
+
+logger = logging.Logger("virt-who")
+
+class VirtTest(unittest.TestCase):
+ def setUp(self):
+ self.virt = Virt(logger)
+
+ def test_connection(self):
+ self.assertGreater(self.virt.virt.getVersion(), 0)
+
+ def test_listDomains(self):
+ uuids = []
+ for domain in self.virt.listDomains():
+ uuids.append(domain.UUIDString())
+ virsh_list = subprocess.Popen(["virsh", "-r", "list", "--all"], stdout=subprocess.PIPE).communicate()[0]
+ lines = virsh_list.split("\n")[2:]
+ for line in lines:
+ if len(line) == 0:
+ 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)
+ uuids.remove(uuid)
+ self.assertEqual(len(uuids), 0, "virsh returns less domains then virt-who (%s)" % ",".join(uuids))
+
+class SubscriptionManagerTest(unittest.TestCase):
+ def setUp(self):
+ self.sm = SubscriptionManager(logger)
+
+ def test_connect(self):
+ self.sm.connect()
+ self.assertNotEqual(self.sm.connection.ping()['result'], "")
+
+ def test_config(self):
+ self.sm.readConfig()
+ consumerCertDir = None
+
+ f = open("/etc/rhsm/rhsm.conf", "r")
+ cfg = f.read()
+ for line in cfg.split("\n"):
+ line = line.strip()
+ if line.startswith("consumerCertDir"):
+ consumerCertDir = line.partition("=")[2].strip()
+ self.assertTrue(consumerCertDir is not None)
+ self.assertEqual(self.sm.cert_file, os.path.join(consumerCertDir, "cert.pem"))
+ self.assertEqual(self.sm.key_file, os.path.join(consumerCertDir, "key.pem"))
+
+ def test_uuid(self):
+ uuid = None
+ for line in subprocess.Popen(["subscription-manager", "identity"], stdout=subprocess.PIPE).communicate()[0].split("\n"):
+ if line.startswith("Current identity is:"):
+ uuid = line.partition(":")[2].strip()
+ self.assertEqual(uuid, self.sm.uuid())
+
+if __name__ == '__main__':
+ unittest.main()
12 years, 8 months
[virt-who] Add missing header to log.py
by Radek Novacek
commit 3e2bc9672154e9899ef80c90989d153773f4b19a
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Tue Aug 16 09:40:36 2011 +0200
Add missing header to log.py
log.py | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/log.py b/log.py
index 24a97c8..b965482 100644
--- a/log.py
+++ b/log.py
@@ -1,3 +1,23 @@
+"""
+Module for logging, part of virt-who
+
+Copyright (C) 2011 Radek Novacek <rnovacek(a)redhat.com>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+"""
+
import logging
import os
12 years, 8 months