Commit 3332aeb7 authored by Agustin Pane's avatar Agustin Pane
Browse files

Merge branch 'feature/debian-support' into 'development'

(Feature) - Debian support

See merge request !23
parents c4d68b82 e492994e
......@@ -4,7 +4,7 @@ from setuptools import setup
setup(
name='svmon-client',
version='2.3.3',
version='2.4.0',
packages=['svmon_client'],
scripts=['svmon'],
package_data={'' : ['*.json','*.pem']},
......
......@@ -72,7 +72,7 @@ def get_service_tag(service_type,configs=None):
return tags
elif service_type == "gitlab":
tmp = get_by_rpm_packages("gitlab", 0 , 1)
tmp = get_package_version("gitlab", 0 , 1)
if(enableDebug):
print('get_service_tag for gitlab result: ', tmp)
if tmp == None or tmp == '' or tmp.find('Failed') >-1:
......@@ -82,7 +82,7 @@ def get_service_tag(service_type,configs=None):
return tags
elif service_type == "b2safe":
tmp=get_by_rpm_packages("b2safe")
tmp=get_package_version("b2safe")
if(enableDebug):
print('get_service_tag for b2safe result: ', tmp)
if tmp == "":
......@@ -90,13 +90,13 @@ def get_service_tag(service_type,configs=None):
exit(1)
tags.append(tmp)
tmp=get_by_rpm_packages("irods-server")
tmp=get_package_version("irods-server")
if(enableDebug):
print('get_service_tag for irods-server result: '+ tmp)
if tmp != None and tmp != '' and tmp.find('Failed') == -1:
tags.append(tmp)
return tags
tmp=get_by_rpm_packages("irods-icat")
tmp=get_package_version("irods-icat")
if(enableDebug):
print('get_service_tag for irods-icat result: '+tmp)
if tmp != None and tmp != '' and tmp.find('Failed') == -1:
......@@ -108,6 +108,7 @@ def get_service_tag(service_type,configs=None):
elif service_type == "svmon":
if configs != None and 'svmon_app_path' in configs:
print('Getting svmon version from config file')
tmp=get_package_version("b2safe")
tags={}
if configs.get('svmon_app_path') != None and configs.get('svmon_app_path') != '' :
svmonVersions = get_svmon_version(configs.get('svmon_app_path'))
......@@ -128,40 +129,79 @@ def get_service_tag(service_type,configs=None):
print("No b2handle configuration to get versions")
exit(1)
# for package version that can be accessed via rpm management
def get_by_rpm_packages(software,start=0,end=0):
def get_package_version(software,start=0,end=0):
config = remoteConfig.RemoteConfig().getConfig()
enableDebug = config["DEBUG_MODE"]
if(enableDebug):
print('Get_by_rpm_packages for software: '+software)
print('Get_package_version for software: '+software)
if isinstance(software,str) == False or software == "" or software == None:
print("Software name should be a non-empty string")
exit(1)
if isinstance(start,int) == False or isinstance(end, int) == False:
print("The input of indices should be integers to fetch correct version,")
exit(1)
tmp = subprocess.Popen("rpm -qa", shell=True, stdout=subprocess.PIPE)
tmp = subprocess.Popen('grep ' + software, shell=True, stdin=tmp.stdout, stdout=subprocess.PIPE)
tmp = tmp.communicate()
dpkgResult = subprocess.Popen("which dpkg", shell=True, stdout=subprocess.PIPE)
dpkgResult = dpkgResult.communicate()
if dpkgResult[0] == None or dpkgResult == "":
if(enableDebug):
print('No dpkg found, running with rpm...')
return get_by_rpm_packages(software, start,end)
return get_by_dpkg_packages(software,start,end)
# for package version that can be accessed via rpm management
def get_by_dpkg_packages(software,start=0,end=0):
config = remoteConfig.RemoteConfig().getConfig()
enableDebug = config["DEBUG_MODE"]
if(enableDebug):
print('Get_by_rpm_packages final rpm-qa before parse result: ', tmp)
tmp = tmp[0]
if tmp == None or tmp == "":
print('Failed, no rpm packages can be found for ', software)
print('Get_by_dpkg_packages for software: '+software, start,end)
softwareListResult = subprocess.Popen("dpkg -l", shell=True, stdout=subprocess.PIPE)
softwareListResult = subprocess.Popen('grep ' + software, shell=True, stdin=softwareListResult.stdout, stdout=subprocess.PIPE)
softwareListResult = softwareListResult.communicate()
if(enableDebug):
print('Get_by_dpkg_packages final dpkg -l before parse result: ', softwareListResult)
if softwareListResult[0] == None or softwareListResult == "":
print('Failed, no dpkg packages can be found for ', software)
return ''
ind=tmp.find(software)
ind=ind+len(software)
ltmp=tmp[ind+1:len(tmp)].split('-')
return extractVersionFromCommandResult(software, softwareListResult[0], start,end)
# for package version that can be accessed via rpm management
def get_by_rpm_packages(software,start=0,end=0):
config = remoteConfig.RemoteConfig().getConfig()
enableDebug = config["DEBUG_MODE"]
if(enableDebug):
print('Get_by_rpm_packages final ltmp test result: ',ltmp)
print('Get_by_rpm_packages for software: '+software, start,end)
softwareListResult = subprocess.Popen("rpm -qa", shell=True, stdout=subprocess.PIPE)
softwareListResult = subprocess.Popen('grep ' + software, shell=True, stdin=softwareListResult.stdout, stdout=subprocess.PIPE)
softwareListResult = softwareListResult.communicate()
if(enableDebug):
print('Get_by_rpm_packages final rpm-qa before parse result: ', softwareListResult)
if softwareListResult[0] == None or softwareListResult == "":
print('Failed, no rpm packages can be found for ', software)
return ''
return extractVersionFromCommandResult(software, softwareListResult[0], start,end)
def extractVersionFromCommandResult(software,unparsedVersion, start,end):
softwareIndex=unparsedVersion.find(software)
softwareIndex=softwareIndex+len(software)
parsedVersion=unparsedVersion[softwareIndex+1:len(unparsedVersion)].split('-')
if len(ltmp) > end:
if len(parsedVersion) > end:
if start == end:
return ltmp[start]
return parsedVersion[start]
elif start < end:
res=""
for i in range(start,end+1):
res=res+ltmp[i]
res=res+parsedVersion[i]
return res
else:
print('Failed, the start index should be smaller than end index for a correct rpm package resolver')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment