mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
introduce cloud-grab-dependent-library-versions grabbing dependent libraries version of mgmt server
This commit is contained in:
parent
d0b394b39b
commit
71a8ad1a32
@ -581,6 +581,7 @@ fi
|
||||
%files cli
|
||||
%{_bindir}/%{name}-tool
|
||||
%{_bindir}/cloudvoladm
|
||||
%{_bindir}/cloud-grab-dependent-library-versions
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/cli/commands.xml
|
||||
%dir %{_prefix}/lib*/python*/site-packages/%{name}tool
|
||||
%{_prefix}/lib*/python*/site-packages/%{name}tool/*
|
||||
|
||||
63
python/bindir/cloud-grab-dependent-library-versions
Executable file
63
python/bindir/cloud-grab-dependent-library-versions
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
Created on Nov 21, 2011
|
||||
|
||||
@author: frank
|
||||
'''
|
||||
import subprocess
|
||||
|
||||
depLibraries = ['python', 'bzip2', 'gzip', 'unzip', 'openssh-clients', 'nfs-utils', 'wget', 'tomcat6', 'ws-commons-util', 'commons-dbcp',
|
||||
'commons-collections', 'commons-httpclient', 'jpackage-utils', 'MySQL-python', 'python-paramiko', 'ipmitool', 'commons-httpclient', 'commons-collections',
|
||||
'commons-pool', 'commons-dbcp', 'jakarta-commons-logging', 'java-*-openjdk']
|
||||
|
||||
def runCmd(cmds):
|
||||
process = subprocess.Popen(' '.join(cmds), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if process.returncode != 0:
|
||||
raise Exception(stderr)
|
||||
return stdout
|
||||
|
||||
|
||||
def getDependentLibraryInfo():
|
||||
def getVersion(res, pkgname):
|
||||
start = False
|
||||
for l in res.split('\n'):
|
||||
if "Installed Packages" in l:
|
||||
start = True
|
||||
continue
|
||||
if not start: continue
|
||||
|
||||
(key, value) = l.split(':', 2)
|
||||
key = key.strip()
|
||||
value = value.strip()
|
||||
if key == 'Name' and "*" not in pkgname and pkgname not in value:
|
||||
print "Required package name %s doesn't equal to package %s installed"%(pkgname, value)
|
||||
return 'UNKNOWN'
|
||||
if 'Version' in key: return value
|
||||
if 'Description' in key: return 'UNKNOWN' # we hit the end
|
||||
return 'UNKNOWN'
|
||||
|
||||
libraryMap = {}
|
||||
for l in depLibraries:
|
||||
cmd = ['yum', 'info', '"%s"'%l]
|
||||
try:
|
||||
result = runCmd(cmd)
|
||||
version = getVersion(result, l)
|
||||
libraryMap[l] = version
|
||||
except Exception, e:
|
||||
print "When finding %s, encounters %s"%(l, e)
|
||||
continue
|
||||
return libraryMap
|
||||
|
||||
def arrangeOutPut(libraryMap):
|
||||
msg = ['\n\n\nBelow is the checking list of library version that CloudStack depends on:']
|
||||
for l in depLibraries:
|
||||
if libraryMap.has_key(l):
|
||||
entry = "%-40s: %s"%(l, libraryMap[l])
|
||||
else:
|
||||
entry = "%-40s: %s"%(l, 'UNKNOWN')
|
||||
msg.append(entry)
|
||||
print '\n'.join(msg)
|
||||
|
||||
if __name__ == '__main__':
|
||||
arrangeOutPut(getDependentLibraryInfo())
|
||||
Loading…
x
Reference in New Issue
Block a user