[virt-who] Created tag virt-who-0.10-1
by Radek Novacek
The unsigned tag 'virt-who-0.10-1' was created.
Tagger: Chris Duryee <cduryee(a)redhat.com>
Date: Sun Aug 25 20:33:57 2013 -0400
Tagging package [virt-who] version [0.10-1] in directory [/].
Changes since the last tag 'virt-who-0.9-1':
Chris Duryee (3):
put /var/lib in spec file
spec typo and filename typo
Automatic commit of package [virt-who] release [0.10-1].
10 years, 3 months
[virt-who] hyperv: fix missing hashlib import
by Radek Novacek
commit 81209796a3fc0383ac9d4d327a09f85d7f4a6c5b
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Thu Mar 13 14:16:57 2014 +0100
hyperv: fix missing hashlib import
ntlm.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/ntlm.py b/ntlm.py
index 2a6b816..32d33c3 100644
--- a/ntlm.py
+++ b/ntlm.py
@@ -17,6 +17,7 @@ import string
import subprocess
try:
+ import hashlib
from hashlib import md5, algorithms
except ImportError:
algorithms = []
10 years, 3 months
[virt-who] Created tag 0.9
by Radek Novacek
The signed tag '0.9' was created.
Tagger: Radek Novacek <rnovacek(a)redhat.com>
Date: Thu Mar 13 14:17:37 2014 +0100
0.9
Changes since the last tag '0.8':
Chris Duryee (3):
register one system per hypervisor
use 'sam' as smType, not 'rhsm'
Log message when no hypervisors are found
Radek Novacek (30):
Create PID file as soon as possible
Add support for Hyper-V hypervisor.
Fix couple of issues in Hyper-V support
Help and manpage improvements
Fix adding https:// to ESX url
Fix version in Makefile
Fix permissions for man page
Increase compatibility with ESXi
vsphere: use instanceUuid when uuid is empty
vsphere: Handle more than 100 objects in esx traversal
Add satellite support
Fix syntax for python 2.4
Handle exceptions in virt_notify function
spec: create /var dir in the spec instead of source
Require username to be present
Optimize creating satellite plan a little
Get rid of all mentions of virt-who-register-satellite
Fix typo in README
Set SAM mode as default (in order to maintain backward compatibility)
Fix getting more results from ESX
Query virtual guest per host, not all at once.
vdsm: Handle also NoSectionError in vdsm config file
vsphere: reconnect before each scan
Check if process defined by PID file exists
vsphere: create connection to vsphere each time
Don't require hashlib
vsphere: filter out hosts that don't have uuid
Hyperv: don't require uuid, it's not in python 2.4
hyperv: fix missing hashlib import
Bump to version 0.9
10 years, 3 months
[virt-who] Hyperv: don't require uuid, it's not in python 2.4
by Radek Novacek
commit ae635f065eca94098513cf5f04b47f09307be94c
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Thu Mar 13 10:29:51 2014 +0100
Hyperv: don't require uuid, it's not in python 2.4
hyperv.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/hyperv.py b/hyperv.py
index 2fcb1a3..3dc25c2 100644
--- a/hyperv.py
+++ b/hyperv.py
@@ -3,7 +3,14 @@ import sys
import httplib
import urlparse
import base64
-from uuid import uuid1
+
+try:
+ from uuid import uuid1
+except ImportError:
+ import subprocess
+ def uuid1():
+ # fallback to calling commandline uuidgen
+ return subprocess.Popen(["uuidgen"], stdout=subprocess.PIPE).communicate()[0].strip()
# Import XML parser
try:
10 years, 3 months
[virt-who] vsphere: filter out hosts that don't have uuid
by Radek Novacek
commit a1f06d4742d1ba7c9598351f96cdc080f5dd9a8e
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Thu Mar 13 10:14:25 2014 +0100
vsphere: filter out hosts that don't have uuid
vsphere.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/vsphere.py b/vsphere.py
index 5fbede2..20febd4 100644
--- a/vsphere.py
+++ b/vsphere.py
@@ -289,6 +289,9 @@ class VSphere:
mapping = {}
for cluster in self.clusters.values():
for host in cluster.hosts:
+ if host.uuid is None:
+ # Filter out hosts without uuid
+ continue
l = []
for vm in host.vms:
# Stopped machine doesn't have any uuid
10 years, 3 months
[virt-who] Don't require hashlib
by Radek Novacek
commit 04e2e6b71b95abe7ece2487f04a54e5bfb043172
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Mar 12 16:46:55 2014 +0100
Don't require hashlib
hashlib is not part of python2.4 and it might not contain md4 algorithm.
Use md5 library or openssl as a fallback.
ntlm.py | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/ntlm.py b/ntlm.py
index d950611..2a6b816 100644
--- a/ntlm.py
+++ b/ntlm.py
@@ -14,13 +14,37 @@
import struct
import base64
import string
-import hashlib
+import subprocess
+
+try:
+ from hashlib import md5, algorithms
+except ImportError:
+ algorithms = []
+ from md5 import md5
+
import hmac
import random
from socket import gethostname
import M2Crypto
+# Use md4 from hashlib or directly from openssl
+class OpenSslMd4(object):
+ def __init__(self, data):
+ self.data = data
+ def digest(self):
+ return subprocess.Popen(["openssl", "md4", "-binary"], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(self.data)[0]
+
+class HashlibMd4(object):
+ def __init__(self, data):
+ self.md4 = hashlib.new('md4', data)
+ def digest(self):
+ return self.md4.digest()
+
+if 'md4' in algorithms:
+ md4 = HashlibMd4
+else:
+ md4 = OpenSslMd4
# DES handling functions
@@ -411,7 +435,7 @@ def ComputeResponse(ResponseKeyNT, ResponseKeyLM, ServerChallenge, ServerName, C
def ntlm2sr_calc_resp(ResponseKeyNT, ServerChallenge, ClientChallenge='\xaa'*8):
LmChallengeResponse = ClientChallenge + '\0'*16
- sess = hashlib.md5(ServerChallenge+ClientChallenge).digest()
+ sess = md5(ServerChallenge+ClientChallenge).digest()
NtChallengeResponse = calc_resp(ResponseKeyNT, sess[0:8])
return (NtChallengeResponse, LmChallengeResponse)
@@ -431,7 +455,7 @@ def create_LM_hashed_password_v1(passwd):
def create_NT_hashed_password_v1(passwd, user=None, domain=None):
"create NT hashed password"
- digest = hashlib.new('md4', passwd.encode('utf-16le')).digest()
+ digest = md4(passwd.encode('utf-16le')).digest()
return digest
def create_NT_hashed_password_v2(passwd, user, domain):
@@ -442,7 +466,7 @@ def create_NT_hashed_password_v2(passwd, user, domain):
return digest
def create_sessionbasekey(password):
- return hashlib.new('md4', create_NT_hashed_password_v1(password)).digest()
+ return md4(create_NT_hashed_password_v1(password)).digest()
if __name__ == "__main__":
def ByteToHex( byteStr ):
10 years, 3 months
[virt-who] vsphere: create connection to vsphere each time
by Radek Novacek
commit 8d64569064ff132cc8ced0edd6df35d111909005
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Fri Jan 3 09:05:47 2014 +0100
vsphere: create connection to vsphere each time
The connection to the vsphere tends to timeout when not used for some
time. The login will fail after that. This commit forces virt-who to reconnect
to vsphere each time.
(cherry picked from commit 08c5db906c333a2a47e060af42c85df95c13d513)
vsphere.py | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/vsphere.py b/vsphere.py
index 8183a67..5fbede2 100644
--- a/vsphere.py
+++ b/vsphere.py
@@ -115,6 +115,16 @@ class VSphere:
if not "://" in self.url:
self.url = "https://%s" % self.url
+ self.clusters = {}
+ self.hosts = {}
+ self.vms = {}
+
+ def scan(self):
+ """
+ Scan method does full inventory traversal on the vCenter machine. It finds
+ all ComputeResources, Hosts and VirtualMachines.
+ """
+
# Connect to the vCenter server
self.client = suds.client.Client("%s/sdk/vimService.wsdl" % self.url)
@@ -127,16 +137,6 @@ class VSphere:
# Service Content object defines properties of the ServiceInstance object
self.sc = self.client.service.RetrieveServiceContent(_this=self.moRef)
- self.clusters = {}
- self.hosts = {}
- self.vms = {}
-
- def scan(self):
- """
- Scan method does full inventory traversal on the vCenter machine. It finds
- 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)
10 years, 3 months
[virt-who] Check if process defined by PID file exists
by Radek Novacek
commit d30dc8811fe77813394fae4183d98b0761d2be86
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Wed Dec 11 08:43:24 2013 +0100
Check if process defined by PID file exists
When virt-who is starting it now checks if the previous virt-who is
running (defined by PID file) and if not, deletes the pid file and
starts normally.
(cherry picked from commit 15abd71138e7421f7ab476027e74747e2115b9ea)
virt-who.py | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/virt-who.py b/virt-who.py
index 391207b..8cd68f6 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -300,6 +300,21 @@ def daemonize(debugMode):
os.chdir("/")
return True
+def checkPidFile():
+ try:
+ f = open(PIDFILE, "r")
+ pid = int(f.read().strip())
+ try:
+ os.kill(pid, 0)
+ print >>sys.stderr, "virt-who seems to be already running. If not, remove %s" % PIDFILE
+ sys.exit(1)
+ except OSError:
+ # Process no longer exists
+ print >>sys.stderr, "PID file exists but associated process does not, deleting PID file"
+ os.remove(PIDFILE)
+ except Exception:
+ pass
+
def createPidFile(logger=None):
atexit.register(cleanup)
signal.signal(signal.SIGINT, cleanup)
@@ -324,9 +339,7 @@ def cleanup(sig=None, stack=None):
sys.exit(0)
def main():
- if os.access(PIDFILE, os.F_OK):
- print >>sys.stderr, "virt-who seems to be already running. If not, remove %s" % PIDFILE
- sys.exit(1)
+ checkPidFile()
createPidFile()
parser = OptionParserEpilog(usage="virt-who [-d] [-i INTERVAL] [-b] [-o] [--sam|--satellite] [--libvirt|--vdsm|--esx|--rhevm|--hyperv]",
10 years, 3 months
[virt-who] vsphere: reconnect before each scan
by Radek Novacek
commit 50b160ec0d47676d73e7094fe7ea13f55c4a0886
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 84eca50..8183a67 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 = {}
10 years, 3 months