Skip to content

Commit

Permalink
xen: remove duplicated entries from the log
Browse files Browse the repository at this point in the history
  • Loading branch information
Radek Novacek committed Aug 16, 2016
1 parent 1cd16c1 commit 920eb8c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions virtwho/virt/xen/xen.py
Expand Up @@ -31,6 +31,7 @@ def __init__(self, logger, config):
self.username = config.username
self.password = config.password
self.config = config
self.ignored_guests = set()

# Url must contain protocol (usually https://)
if "://" not in self.url:
Expand Down Expand Up @@ -78,13 +79,18 @@ def getHostGuestMapping(self):

for resident in self.session.xenapi.host.get_resident_VMs(host):
vm = self.session.xenapi.VM.get_record(resident)
uuid = vm['uuid']

if vm.get('is_control_domain', False):
self.logger.debug("Control Domain %s is ignored", vm['uuid'])
if uuid not in self.ignored_guests:
self.ignored_guests.add(uuid)
self.logger.debug("Control Domain %s is ignored", uuid)
continue

if vm.get('is_a_snapshot', False) or vm.get('is_a_template', False):
self.logger.debug("Guest %s is snapshot or template, ignoring", vm['uuid'])
if uuid not in self.ignored_guests:
self.ignored_guests.add(uuid)
self.logger.debug("Guest %s is snapshot or template, ignoring", uuid)
continue

if vm['power_state'] == 'Running':
Expand All @@ -98,7 +104,7 @@ def getHostGuestMapping(self):
else:
state = virt.Guest.STATE_UNKNOWN

guests.append(virt.Guest(uuid=vm["uuid"], virt=self, state=state))
guests.append(virt.Guest(uuid=uuid, virt=self, state=state))

facts = {}
sockets = record.get('cpu_info', {}).get('socket_count')
Expand Down Expand Up @@ -150,7 +156,10 @@ def _wait(self, token, timeout):
raise
except Exception:
self.logger.exception("Waiting on XEN events failed: ")
return None
return {
'events': [],
'token': token
}

def _run(self):
self._prepare()
Expand Down

0 comments on commit 920eb8c

Please sign in to comment.