[virt-who] Don't report Domain-0 as guest
by Radek Novacek
commit 49364d4fc97496cb9fa6cb7d55bd90d734a039b9
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Dec 21 14:56:53 2011 +0100
Don't report Domain-0 as guest
virt.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/virt.py b/virt.py
index 349dcf2..b0684d6 100644
--- a/virt.py
+++ b/virt.py
@@ -44,6 +44,9 @@ class Virt:
# Active domains
for domainID in self.virt.listDomainsID():
domain = self.virt.lookupByID(domainID)
+ if domain.UUIDString() == "00000000-0000-0000-0000-000000000000":
+ # Don't send Domain-0 on xen (zeroed uuid)
+ continue
domains.append(domain)
self.logger.debug("Virtual machine found: %s: %s" % (domain.name(), domain.UUIDString()))
12 years, 4 months
[virt-who] Fix using undefined variable
by Radek Novacek
commit 263ae835aa2ff551d5b68a417d8729d2653cdee3
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Dec 21 14:21:52 2011 +0100
Fix using undefined variable
virt.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/virt.py b/virt.py
index f3552d3..349dcf2 100644
--- a/virt.py
+++ b/virt.py
@@ -78,7 +78,7 @@ class Virt:
hasDomain = True
break
if not hasDomain:
- l.append(d)
+ l.append(dom)
self.changedCallback(l)
def domainListChangedCallback(self, callback):
12 years, 4 months
[virt-who] Fix logging exceptions
by Radek Novacek
commit e9fc0b755ac8445bd2060b652fe4b871bf4a6dcf
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Dec 21 14:21:36 2011 +0100
Fix logging exceptions
subscriptionmanager.py | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
---
diff --git a/subscriptionmanager.py b/subscriptionmanager.py
index 63492ee..236cbd0 100644
--- a/subscriptionmanager.py
+++ b/subscriptionmanager.py
@@ -60,8 +60,7 @@ class SubscriptionManager:
if not self.connection.ping()['result']:
self.logger.error("Unable to obtain status from server, UEPConnection is likely not usable.")
except Exception, e:
- self.logger.warn("Unable to obtain status from server, UEPConnection is likely not usable:")
- self.logger.exception(e)
+ self.logger.exception("Unable to obtain status from server, UEPConnection is likely not usable:")
def sendVirtGuests(self, domains):
""" Update consumer facts with UUIDs of virtual guests. """
12 years, 4 months
[virt-who] Fix reference before assignment error
by Radek Novacek
commit d97f5802aa0f7601a2c6d3a7159eedc45588bbed
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Dec 14 08:26:35 2011 +0100
Fix reference before assignment error
virt.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/virt.py b/virt.py
index ba2d947..f3552d3 100644
--- a/virt.py
+++ b/virt.py
@@ -64,10 +64,10 @@ class Virt:
print "EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), eventToString(event), detailToString(event, detail))
if self.changedCallback:
l = self.listDomains()
- # Workaround: xen sometimes doesn't update domain list when the event happens, add/remove the
+ uuid = dom.UUIDString()
+ # Workaround: xen sometimes doesn't update domain list when the event happens, add/remove the
# affected domain manually
if event == libvirt.VIR_DOMAIN_EVENT_UNDEFINED:
- uuid = dom.UUIDString()
# Copy the list of domains without deleted domain
l = [d for d in l if d.UUIDString() != uuid]
elif event == libvirt.VIR_DOMAIN_EVENT_DEFINED:
12 years, 5 months
[virt-who] Don't obtain unused information from vSphere
by Radek Novacek
commit 20a7d63215a9d12f096a1d422c52f1aec1276c19
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Dec 12 15:52:56 2011 +0100
Don't obtain unused information from vSphere
vsphere.py | 73 +++++++++++++----------------------------------------------
1 files changed, 16 insertions(+), 57 deletions(-)
---
diff --git a/vsphere.py b/vsphere.py
index 80b5c7f..569f818 100644
--- a/vsphere.py
+++ b/vsphere.py
@@ -129,60 +129,44 @@ class VSphere:
specSet=[get_search_filter_spec(self.client, self.sc.rootFolder, [ts])])
# Get properties of each cluster
- clusterObjs = []
+ clusterObjs = [] # List of objs for 'ComputeResource' query
for cluster in object_content:
for propSet in cluster.propSet:
if propSet.name == "name":
- self.clusters[cluster.obj.value] = Cluster(cluster.obj, propSet.val)
+ self.clusters[cluster.obj.value] = Cluster(propSet.val)
clusterObjs.append(cluster.obj)
# Get list of hosts from cluster
- object_contents = self.RetrieveProperties('ComputeResource', 'host', clusterObjs)
- hostObjs = []
+ object_contents = self.RetrieveProperties('ComputeResource', ['host'], clusterObjs)
+ hostObjs = [] # List of objs for 'HostSystem' query
for cluster in object_contents:
for propSet in cluster.propSet:
if propSet.name == 'host':
for host in propSet.val.ManagedObjectReference:
- h = Host(host)
+ h = Host()
self.hosts[host.value] = h
self.clusters[cluster.obj.value].hosts.append(h)
hostObjs.append(host)
# Get list of host uuids, names and virtual machines
- object_contents = self.RetrieveProperties('HostSystem', ['name', 'vm', 'hardware', 'config'], hostObjs)
- vmObjs = []
+ object_contents = self.RetrieveProperties('HostSystem', ['vm', 'hardware'], hostObjs)
+ vmObjs = [] # List of objs for 'VirtualMachine' query
for host in object_contents:
for propSet in host.propSet:
- if propSet.name == "name":
- self.hosts[host.obj.value].name = propSet.val
- elif propSet.name == "hardware":
+ if propSet.name == "hardware":
self.hosts[host.obj.value].uuid = propSet.val.systemInfo.uuid
elif propSet.name == "vm":
for vm in propSet.val.ManagedObjectReference:
vmObjs.append(vm)
- v = VM(vm)
+ v = VM()
self.vms[vm.value] = v
self.hosts[host.obj.value].vms.append(v)
- elif propSet.name == 'config':
- self.hosts[host.obj.value].osType = propSet.val.product.osType
- self.hosts[host.obj.value].product = propSet.val.product.fullName
- if hasattr(propSet.val.network, 'pnic'):
- for nic in propSet.val.network.pnic:
- self.hosts[host.obj.value].nics[nic.mac] = Nic(nic.device, nic.mac, nic.spec.ip.ipAddress)
- if hasattr(propSet.val.network, 'consoleVnic'):
- for nic in propSet.val.network.consoleVnic:
- self.hosts[host.obj.value].nics[nic.spec.mac].ip = nic.spec.ip.ipAddress
- if hasattr(propSet.val.network, 'vnic'):
- for nic in propSet.val.network.vnic:
- self.hosts[host.obj.value].nics[nic.spec.mac].ip = nic.spec.ip.ipAddress
# Get list of virtual machine uuids
- object_contents = self.RetrieveProperties('VirtualMachine', ['name', 'config'], vmObjs)
+ object_contents = self.RetrieveProperties('VirtualMachine', ['config'], vmObjs)
for obj in object_contents:
for propSet in obj.propSet:
- if propSet.name == 'name':
- self.vms[obj.obj.value].name = propSet.val
- elif propSet.name == 'config':
+ if propSet.name == 'config':
self.vms[obj.obj.value].uuid = propSet.val.uuid
def ping(self):
@@ -243,49 +227,24 @@ class VSphere:
for cluster in self.clusters.values():
print "ComputeResource: %s" % cluster.name
for host in cluster.hosts:
- print "\tHostSystem: %s (%s) <%s, %s>" % (host.name, host.uuid, host.osType, host.product)
- for mac, nic in host.nics.items():
- print "\t\tNIC: %s (MAC: %s, IP: %s)" % (nic.device, mac, nic.ip)
+ print "\tHostSystem: %s" % host.uuid
for vm in host.vms:
- print "\t\tVirtualMachine: %s (%s)" % (vm.name, vm.uuid)
+ print "\t\tVirtualMachine: %s" % vm.uuid
class Cluster:
- def __init__(self, obj, name=None):
- self.obj = obj
- self._type = obj._type
- self.value = obj.value
+ def __init__(self, name):
self.name = name
- self.uuid = None
-
self.hosts = []
class Host:
- def __init__(self, obj, name=None):
- self.obj = obj
- self._type = obj._type
- self.value = obj.value
- self.name = name
+ def __init__(self):
self.uuid = None
- self.osType = None
- self.product = None
-
- self.nics = {}
self.vms = []
class VM:
- def __init__(self, obj, name=None):
- self.obj = obj
- self.value = obj.value
- self._type = obj._type
- self.name = name
+ def __init__(self):
self.uuid = None
-class Nic:
- def __init__(self, device, mac, ip):
- self.device = device
- self.mac = mac
- self.ip = ip
-
if __name__ == '__main__':
# TODO: read from config
if len(sys.argv) < 4:
12 years, 5 months
[virt-who] Fix exporting variables from /etc/sysconfig in initscript
by Radek Novacek
commit 80f26ddd15455d36f06e401b83e78a6afd4b85d9
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Dec 12 12:44:42 2011 +0100
Fix exporting variables from /etc/sysconfig in initscript
virt-who-initscript | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/virt-who-initscript b/virt-who-initscript
index ada955d..105dba3 100644
--- a/virt-who-initscript
+++ b/virt-who-initscript
@@ -25,10 +25,10 @@ prog="virt-who"
config="/etc/sysconfig/virt-who"
pidfile="/var/run/$prog.pid"
+# Export all variables in /etc/sysconfig/virt-who
+set -a
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
-
-export VIRTWHO_BACKGROUND
-export VIRTWHO_DEBUG
+set +a
lockfile=/var/lock/subsys/virt-who
12 years, 5 months
[virt-who] Bump to version 0.5, add reqs for vsphere to spec
by Radek Novacek
commit b1d89848bebc136eec07ea98d5e646720148c76f
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Dec 12 12:01:51 2011 +0100
Bump to version 0.5, add reqs for vsphere to spec
Makefile | 2 +-
virt-who.spec | 11 +++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/Makefile b/Makefile
index f009b54..9a29099 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
name = virt-who
-version = 0.4
+version = 0.5
.PHONY: pack check install srpm rpm rpmlint upload
diff --git a/virt-who.spec b/virt-who.spec
index bb561fd..f57b8b6 100644
--- a/virt-who.spec
+++ b/virt-who.spec
@@ -1,5 +1,5 @@
Name: virt-who
-Version: 0.4
+Version: 0.5
Release: 1%{?dist}
Summary: Agent for reporting virtual guest IDs to subscription-manager
@@ -13,7 +13,10 @@ BuildArch: noarch
BuildRequires: python2-devel
Requires: libvirt-python
Requires: libvirt
-Requires: python-rhsm >= 0.96.13
+# python-rhsm 0.98.6 has required call for vSphere support
+Requires: python-rhsm >= 0.98.6
+# python-suds is required for vSphere support
+Requires: python-suds
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
@@ -66,6 +69,10 @@ fi
%changelog
+* Fri Dec 09 2011 Radek Novacek <rnovacek(a)redhat.com> 0.5-1
+- VSphere support
+- Req: python-suds
+
* Wed Nov 30 2011 Radek Novacek <rnovacek(a)redhat.com> 0.4-1
- Version 0.4
12 years, 5 months
[virt-who] Integrate vSphere support into virt-who
by Radek Novacek
commit a9de5fc75ddfa4975aa4ba5d352d2f1b2b239682
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Dec 12 11:58:24 2011 +0100
Integrate vSphere support into virt-who
Add options and enviroment variable for setting up and using vSphere in
virt-who. Call hypervisorCheckIn from python-rhsm for check-in with list
of guests from vCenter server.
Signed-off-by: Radek Novacek <rnovacek(a)redhat.com>
subscriptionmanager.py | 11 +++++++
virt-who.py | 76 +++++++++++++++++++++++++++++++++++++++--------
vsphere.py | 36 +++++++++++++++++++----
3 files changed, 104 insertions(+), 19 deletions(-)
---
diff --git a/subscriptionmanager.py b/subscriptionmanager.py
index 1374a0d..63492ee 100644
--- a/subscriptionmanager.py
+++ b/subscriptionmanager.py
@@ -80,6 +80,17 @@ class SubscriptionManager:
except Exception, e:
raise SubscriptionManagerError(str(e))
+ def hypervisorCheckIn(self, owner, env, mapping):
+ """ Send hosts to guests mapping to subscription manager. """
+
+ self.logger.debug("Sending updates in hosts-to-guests mapping: %s" % mapping)
+
+ # Send the mapping
+ try:
+ return self.connection.hypervisorCheckIn(owner, env, mapping)
+ except Exception, e:
+ raise SubscriptionManagerError(str(e))
+
def uuid(self):
""" Read consumer certificate and get consumer UUID from it. """
if not self.cert_uuid:
diff --git a/virt-who.py b/virt-who.py
index 9fc545d..21ad083 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -24,13 +24,14 @@ import time
from virt import Virt, VirtError
from vdsm import VDSM
+from vsphere import VSphere
from event import virEventLoopPureStart
from subscriptionmanager import SubscriptionManager, SubscriptionManagerError
import logging
import log
-from optparse import OptionParser
+from optparse import OptionParser, OptionGroup
from ConfigParser import NoOptionError
@@ -58,12 +59,15 @@ class VirtWho(object):
"""
Connect to the virtualization supervisor (libvirt or VDSM)
"""
- if self.options.useVDSM:
+ if self.options.virtType == "vdsm":
self.virt = VDSM(self.logger)
- else:
+ elif self.options.virtType == "libvirt":
self.virt = Virt(self.logger)
# We can listen for libvirt events
self.tryRegisterEventCallback()
+ else:
+ # ESX
+ self.virt = VSphere(self.logger, self.options.esx_server, self.options.esx_username, self.options.esx_password)
def initSM(self):
"""
@@ -88,7 +92,7 @@ class VirtWho(object):
monitor virt guests changes and send updates as soon as the change happens,
"""
- if self.options.background and not self.options.useVDSM:
+ if self.options.background and self.options.virtType == "libvirt":
if self.virt is not None and self.subscriptionManager is not None:
# Send list of virt guests when something changes in libvirt
self.virt.domainListChangedCallback(self.subscriptionManager.sendVirtGuests)
@@ -124,7 +128,19 @@ class VirtWho(object):
"""
try:
self.checkConnections()
- self.subscriptionManager.sendVirtGuests(self.virt.listDomains())
+ if self.options.virtType == "esx":
+ result = self.subscriptionManager.hypervisorCheckIn(self.options.esx_owner, self.options.esx_env, self.virt.getHostGuestMapping())
+ # Show the result of hypervisorCheckIn
+ for fail in result['failedUpdate']:
+ logger.error("Error during update list of guests: %s", str(fail))
+ for updated in result['updated']:
+ guests = [x['guestId'] for x in updated['guestIds']]
+ logger.debug("Updated host: %s with guests: [%s]", updated['uuid'], ", ".join(guests))
+ for created in result['created']:
+ guests = [x['guestId'] for x in created['guestIds']]
+ logger.debug("Created host: %s with guests: [%s]", created['uuid'], ", ".join(guests))
+ else:
+ self.subscriptionManager.sendVirtGuests(self.virt.listDomains())
return True
except SystemExit,e:
# In python2.4 SystemExit is inherited from Exception, so must be catched extra
@@ -183,8 +199,18 @@ if __name__ == '__main__':
parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable debugging output")
parser.add_option("-b", "--background", action="store_true", dest="background", default=False, help="Run in the background and monitor virtual guests")
parser.add_option("-i", "--interval", type="int", dest="interval", default=0, help="Acquire and send list of virtual guest each N seconds")
- parser.add_option("--libvirt", action="store_false", dest="useVDSM", default=False, help="Use libvirt to list virtual guests [default]")
- parser.add_option("--vdsm", action="store_true", dest="useVDSM", default=False, help="Use vdsm to list virtual guests")
+ parser.add_option("--libvirt", action="store_const", dest="virtType", const="libvirt", default="libvirt", help="Use libvirt to list virtual guests [default]")
+ parser.add_option("--vdsm", action="store_const", dest="virtType", const="vdsm", help="Use vdsm to list virtual guests")
+ parser.add_option("--esx", action="store_const", dest="virtType", const="esx", help="Register ESX machines using vCenter")
+
+ esxGroup = OptionGroup(parser, "vCenter/ESX options", "Use this options with --esx")
+ esxGroup.add_option("--esx-owner", action="store", dest="esx_owner", default="", help="Organization who has purchased subscriptions of the products")
+ esxGroup.add_option("--esx-env", action="store", dest="esx_env", default="", help="Environment where the vCenter server belongs to")
+ esxGroup.add_option("--esx-server", action="store", dest="esx_server", default="", help="URL of the vCenter server to connect to")
+ esxGroup.add_option("--esx-username", action="store", dest="esx_username", default="", help="Username for connecting to vCenter")
+ esxGroup.add_option("--esx-password", action="store", dest="esx_password", default="", help="Password for connecting to vCenter")
+ parser.add_option_group(esxGroup)
+
(options, args) = parser.parse_args()
@@ -213,7 +239,30 @@ if __name__ == '__main__':
env = os.getenv("VIRTWHO_VDSM", "0").strip().lower()
if env in ["1", "true"]:
- options.useVDSM = True
+ options.virtType = "vdsm"
+
+ env = os.getenv("VIRTWHO_ESX", "0").strip().lower()
+ if env in ["1", "true"]:
+ options.virtType = "esx"
+
+ def checkEnv(variable, option, name):
+ """
+ If `option` is empty, check enviromental `variable` and return its value.
+ Exit if it's still empty
+ """
+ if len(option) == 0:
+ option = os.getenv(variable, "").strip()
+ if len(option) == 0:
+ logger.error("Required parameter '%s' for vCenter is not set, exitting" % name)
+ sys.exit(1)
+ return option
+
+ if options.virtType == "esx":
+ options.esx_owner = checkEnv("VIRTWHO_ESX_OWNER", options.esx_owner, "owner")
+ options.esx_env = checkEnv("VIRTWHO_ESX_ENV", options.esx_env, "env")
+ options.esx_server = checkEnv("VIRTWHO_ESX_SERVER", options.esx_server, "server")
+ options.esx_username = checkEnv("VIRTWHO_ESX_USERNAME", options.esx_username, "username")
+ options.esx_password = checkEnv("VIRTWHO_ESX_PASSWORD", options.esx_password, "password")
if options.interval < 0:
logger.warning("Interval is not positive number, ignoring")
@@ -224,9 +273,8 @@ if __name__ == '__main__':
# (e.g. libvirtd restart)
options.interval = DefaultInterval
- if options.background and options.useVDSM:
- logger.error("Unable to start in background in VDSM mode, use interval instead")
- sys.exit(4)
+ if options.background and options.virtType != "libvirt":
+ logger.warning("Listening for events is not available in VDSM or ESX mode")
if options.background:
try:
@@ -247,11 +295,13 @@ if __name__ == '__main__':
except Exception, e:
logger.error("Unable to create pid file: %s" % str(e))
- if not options.useVDSM:
+ if options.virtType == "libvirt":
virEventLoopPureStart()
virtWho = VirtWho(logger, options)
+ logger.debug("Virt-who is running in %s mode" % options.virtType)
+
if options.interval > 0:
if options.background:
logger.debug("Starting infinite loop with %d seconds interval and event handling" % options.interval)
@@ -266,7 +316,7 @@ if __name__ == '__main__':
slept = 0
while slept < options.interval:
# Sleep 'RetryInterval' or the rest of options.interval
- t = min(RetryInterval, options.interval - RetryInterval)
+ t = min(RetryInterval, options.interval - slept)
time.sleep(t)
slept += t
# Check the connection
diff --git a/vsphere.py b/vsphere.py
index c6fdc43..80b5c7f 100644
--- a/vsphere.py
+++ b/vsphere.py
@@ -2,10 +2,6 @@
import sys
import suds
-import logging
-logging.basicConfig(level=logging.INFO)
-logging.getLogger('suds.client').setLevel(logging.DEBUG)
-
def get_search_filter_spec(client, begin_entity, property_spec):
""" Build a PropertyFilterSpec capable of full inventory traversal.
@@ -90,7 +86,8 @@ def get_search_filter_spec(client, begin_entity, property_spec):
class VSphere:
- def __init__(self, url, username, password):
+ def __init__(self, logger, url, username, password):
+ self.logger = logger
self.url = url
# Connect to the vCenter server
@@ -118,6 +115,11 @@ class VSphere:
all ComputeResources, Hosts and VirtualMachines.
"""
+ # Clear results from last run
+ self.clusters = {}
+ self.hosts = {}
+ self.vms = {}
+
# Find all ComputeResources in whole vsphere tree
ts = self.client.factory.create('ns0:PropertySpec')
ts.type = 'ComputeResource'
@@ -183,6 +185,8 @@ class VSphere:
elif propSet.name == 'config':
self.vms[obj.obj.value].uuid = propSet.val.uuid
+ def ping(self):
+ return True
def RetrieveProperties(self, propSetType, propSetPathSet, objects):
"""
@@ -214,6 +218,24 @@ class VSphere:
# Query the VSphere server
return self.client.service.RetrieveProperties(_this=self.sc.propertyCollector, specSet=[pfs])
+ def getHostGuestMapping(self):
+ """
+ Returns dictionary with host to guest mapping, e.g.:
+
+ { 'host_id_1': ['guest1', 'guest2'],
+ 'host_id_2': ['guest3', 'guest4'],
+ }
+ """
+ self.scan()
+ mapping = {}
+ for cluster in self.clusters.values():
+ for host in cluster.hosts:
+ l = []
+ for vm in host.vms:
+ l.append(vm.uuid)
+ mapping[host.uuid] = l
+ return mapping
+
def printLayout(self):
"""
Prints the layout of vCenter.
@@ -270,6 +292,8 @@ if __name__ == '__main__':
print "Usage: %s url username password"
sys.exit(0)
- vsphere = VSphere(sys.argv[1], sys.argv[2], sys.argv[3])
+ import logging
+ logger = logging.Logger("")
+ vsphere = VSphere(logger, sys.argv[1], sys.argv[2], sys.argv[3])
vsphere.scan()
vsphere.printLayout()
12 years, 5 months
[virt-who] Add workaround for xen for adding guests too
by Radek Novacek
commit 0d16918168b476b378e2ea16218fad4a5cd383fb
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Dec 9 15:31:57 2011 +0100
Add workaround for xen for adding guests too
virt.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/virt.py b/virt.py
index b4a62de..ba2d947 100644
--- a/virt.py
+++ b/virt.py
@@ -64,12 +64,21 @@ class Virt:
print "EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), eventToString(event), detailToString(event, detail))
if self.changedCallback:
l = self.listDomains()
- # Workaround: when removing machine from xen it is still in list of
- # domains, so we'll remove it manually
+ # Workaround: xen sometimes doesn't update domain list when the event happens, add/remove the
+ # affected domain manually
if event == libvirt.VIR_DOMAIN_EVENT_UNDEFINED:
uuid = dom.UUIDString()
# Copy the list of domains without deleted domain
l = [d for d in l if d.UUIDString() != uuid]
+ elif event == libvirt.VIR_DOMAIN_EVENT_DEFINED:
+ # Add domain if not already added
+ hasDomain = False
+ for d in l:
+ if d.UUIDString() == uuid:
+ hasDomain = True
+ break
+ if not hasDomain:
+ l.append(d)
self.changedCallback(l)
def domainListChangedCallback(self, callback):
12 years, 5 months
[virt-who] Don't print logs to stderr when not in debug mode
by Radek Novacek
commit 89a10677ba996cead0facba8e71ab45a88f7bf91
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Dec 9 15:29:14 2011 +0100
Don't print logs to stderr when not in debug mode
virt-who.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/virt-who.py b/virt-who.py
index 134274f..9fc545d 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -197,8 +197,8 @@ if __name__ == '__main__':
# Enable debugging output to be writen in /var/log
logger.setLevel(logging.DEBUG)
- # Print debugging output to stderr too
- logger.addHandler(logging.StreamHandler())
+ # Print debugging output to stderr too
+ logger.addHandler(logging.StreamHandler())
env = os.getenv("VIRTWHO_BACKGROUND", "0").strip().lower()
if env in ["1", "true"]:
12 years, 5 months