Skip to content

Commit 71a8ad1

Browse files
author
frank
committed
introduce cloud-grab-dependent-library-versions grabbing dependent libraries version of mgmt server
1 parent d0b394b commit 71a8ad1

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

cloud.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ fi
581581
%files cli
582582
%{_bindir}/%{name}-tool
583583
%{_bindir}/cloudvoladm
584+
%{_bindir}/cloud-grab-dependent-library-versions
584585
%config(noreplace) %{_sysconfdir}/%{name}/cli/commands.xml
585586
%dir %{_prefix}/lib*/python*/site-packages/%{name}tool
586587
%{_prefix}/lib*/python*/site-packages/%{name}tool/*
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/python
2+
'''
3+
Created on Nov 21, 2011
4+
5+
@author: frank
6+
'''
7+
import subprocess
8+
9+
depLibraries = ['python', 'bzip2', 'gzip', 'unzip', 'openssh-clients', 'nfs-utils', 'wget', 'tomcat6', 'ws-commons-util', 'commons-dbcp',
10+
'commons-collections', 'commons-httpclient', 'jpackage-utils', 'MySQL-python', 'python-paramiko', 'ipmitool', 'commons-httpclient', 'commons-collections',
11+
'commons-pool', 'commons-dbcp', 'jakarta-commons-logging', 'java-*-openjdk']
12+
13+
def runCmd(cmds):
14+
process = subprocess.Popen(' '.join(cmds), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
15+
stdout, stderr = process.communicate()
16+
if process.returncode != 0:
17+
raise Exception(stderr)
18+
return stdout
19+
20+
21+
def getDependentLibraryInfo():
22+
def getVersion(res, pkgname):
23+
start = False
24+
for l in res.split('\n'):
25+
if "Installed Packages" in l:
26+
start = True
27+
continue
28+
if not start: continue
29+
30+
(key, value) = l.split(':', 2)
31+
key = key.strip()
32+
value = value.strip()
33+
if key == 'Name' and "*" not in pkgname and pkgname not in value:
34+
print "Required package name %s doesn't equal to package %s installed"%(pkgname, value)
35+
return 'UNKNOWN'
36+
if 'Version' in key: return value
37+
if 'Description' in key: return 'UNKNOWN' # we hit the end
38+
return 'UNKNOWN'
39+
40+
libraryMap = {}
41+
for l in depLibraries:
42+
cmd = ['yum', 'info', '"%s"'%l]
43+
try:
44+
result = runCmd(cmd)
45+
version = getVersion(result, l)
46+
libraryMap[l] = version
47+
except Exception, e:
48+
print "When finding %s, encounters %s"%(l, e)
49+
continue
50+
return libraryMap
51+
52+
def arrangeOutPut(libraryMap):
53+
msg = ['\n\n\nBelow is the checking list of library version that CloudStack depends on:']
54+
for l in depLibraries:
55+
if libraryMap.has_key(l):
56+
entry = "%-40s: %s"%(l, libraryMap[l])
57+
else:
58+
entry = "%-40s: %s"%(l, 'UNKNOWN')
59+
msg.append(entry)
60+
print '\n'.join(msg)
61+
62+
if __name__ == '__main__':
63+
arrangeOutPut(getDependentLibraryInfo())

0 commit comments

Comments
 (0)