commit 15bb845a3a8dd8765fb4949c033e89693f58e571
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Dec 11 08:36:50 2013 +0100
vsphere: reconnect before each scan
With long scan interval (3600 seconds) the login session expires
and virt-who can't read host/guest association from the ESX.
This commit forces virt-who to relogin each time before the scanning.
vsphere.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/vsphere.py b/vsphere.py
index 46b5fb3..415df65 100644
--- a/vsphere.py
+++ b/vsphere.py
@@ -108,6 +108,8 @@ class VSphere:
def __init__(self, logger, url, username, password):
self.logger = logger
self.url = url
+ self.username = username
+ self.password = password
# Url must contain protocol (usualy https://)
if not "://" in self.url:
@@ -125,9 +127,6 @@ class VSphere:
# Service Content object defines properties of the ServiceInstance object
self.sc = self.client.service.RetrieveServiceContent(_this=self.moRef)
- # Login to server using given credentials
- self.client.service.Login(_this=self.sc.sessionManager, userName=username,
password=password)
-
self.clusters = {}
self.hosts = {}
self.vms = {}
@@ -138,6 +137,9 @@ class VSphere:
all ComputeResources, Hosts and VirtualMachines.
"""
+ # Login to server using given credentials
+ self.client.service.Login(_this=self.sc.sessionManager, userName=self.username,
password=self.password)
+
# Clear results from last run
self.clusters = {}
self.hosts = {}
Show replies by date