Commit b4ce3e61 authored by Agustin Pane's avatar Agustin Pane
Browse files

(Fix) - B2safe issues / operating system issues

parent 8a5cce90
......@@ -28,5 +28,14 @@ PySVMON is a develoment project for SVMON client. It migrates bash-based client
You can check the current available list also using svmon --list-service-type command
## How to build and deploy pysvmon
1) Go to pysvmon folder
2) Update the svmon version in setup.py
3) Run `python3 -m build`
4) Upload to python repository (credentials are needed):
* Production: `python3 -m twine upload dist/*`
* Development/test: `python3 -m twine upload --repository testpypi dist/*`
5) Then the new version will be available for instaling via pip:
* Production: `pip install svmon-client`
* Development: `pip install -i https://test.pypi.org/simple/ svmon-client`
......@@ -4,7 +4,7 @@ from setuptools import setup
setup(
name='svmon-client',
version='2.3.2',
version='2.3.3',
packages=['svmon_client'],
scripts=['svmon'],
package_data={'' : ['*.json','*.pem']},
......
......@@ -128,7 +128,7 @@ def main(argv):
for item in reports:
print(item)
else:
print("reporting zero service components in printing")
print("No service components found to report, skipping report...")
exit(0)
......
......@@ -8,10 +8,10 @@ def get_os_from_file():
# centos :
files=["/etc/redhat-release","/etc/centos-release","/etc/issue","/etc/os-release","/etc/SuSE-release","/etc/release"]
res_str= ""
ubuntuflag = 0
ubuntu_flag = 0
afile = ""
for afile in files:
exist = os.path.exists(afile)
exist = os.path.exists(afile)
if exist:
f=open(afile,'r')
while True:
......@@ -49,7 +49,7 @@ def get_os_from_file():
f.close()
tmp = line.split("\"")
return text_processing(tmp[1])
if afile == "/etc/SuSE-release":
if line.find("openSUSE") != -1 or line.find("SLE")!=-1:
f.close()
......@@ -62,8 +62,8 @@ def get_os_from_file():
print("The operating system can not resolved")
exit(1)
def text_processing(input_text):
if input_text == None or isinstance(input_text,str) == False or input_text == "":
print("wrong input for text processing in op parser")
......
......@@ -115,6 +115,7 @@ class SVMONReport:
exit(1)
else:
self.tags = services.get_service_tag(self.service_type)
self.service_names = services.get_service_name(self.service_type)
def get_site(self):
return self.site
......@@ -160,6 +161,9 @@ class SVMONReport:
this.tags.append(tag)
def print_report(self):
enableDebug = self.config["DEBUG_MODE"]
if(enableDebug):
print('print_report called with services: ', self.service_names)
if len(self.service_names) > 0:
res=[]
if self.service_names== None or len(self.service_names ) < 1:
......
......@@ -51,7 +51,12 @@ def get_service_name(service_type):
def get_service_tag(service_type,configs=None):
print("Get service tag called... with service type: ", service_type)
config = remoteConfig.RemoteConfig().getConfig()
enableDebug = config["DEBUG_MODE"]
if(enableDebug):
print("Get service tag called... with service type: ", service_type)
tags=[]
if service_type == None or service_type == "" or isinstance(service_type,str) == False:
print("The service type argument should be a non-empty string")
......@@ -68,6 +73,8 @@ def get_service_tag(service_type,configs=None):
elif service_type == "gitlab":
tmp = get_by_rpm_packages("gitlab", 0 , 1)
if(enableDebug):
print('get_service_tag for gitlab result: ', tmp)
if tmp == None or tmp == '' or tmp.find('Failed') >-1:
print("no gitlab version can be resolved")
exit(1)
......@@ -76,16 +83,22 @@ def get_service_tag(service_type,configs=None):
elif service_type == "b2safe":
tmp=get_by_rpm_packages("b2safe")
if(enableDebug):
print('get_service_tag for b2safe result: ', tmp)
if tmp == "":
print("no b2safe version can be resolved")
exit(1)
tags.append(tmp)
tmp=get_by_rpm_packages("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")
if(enableDebug):
print('get_service_tag for irods-icat result: '+tmp)
if tmp != None and tmp != '' and tmp.find('Failed') == -1:
tags.append(tmp)
return tags
......@@ -117,8 +130,12 @@ def get_service_tag(service_type,configs=None):
# 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 for software: '+software)
if isinstance(software,str) == False or software == "" or software == None:
print("software name should be a non-empty string")
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,")
......@@ -126,12 +143,17 @@ def get_by_rpm_packages(software,start=0,end=0):
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()
if(enableDebug):
print('Get_by_rpm_packages final rpm-qa before parse result: ', tmp)
tmp = tmp[0]
if tmp == None or tmp == "":
return "Failed, no rpm packages can be found for " + software
if tmp == None or tmp == "":
print('Failed, no rpm packages can be found for ', software)
return ''
ind=tmp.find(software)
ind=ind+len(software)
ltmp=tmp[ind+1:len(tmp)].split('-')
if(enableDebug):
print('Get_by_rpm_packages final ltmp test result: ',ltmp)
if len(ltmp) > end:
if start == end:
......@@ -142,16 +164,17 @@ def get_by_rpm_packages(software,start=0,end=0):
res=res+ltmp[i]
return res
else:
return "Failed, the start index should be smaller than end index for a correct rpm package resolver"
print('Failed, the start index should be smaller than end index for a correct rpm package resolver')
return ''
else:
return "Failed," + software +" version not resolved"
print("Failed," + software +" version not resolved")
return ''
def get_user():
tmp=subprocess.Popen("whoami",shell=True,stdout=subprocess.PIPE)
tmp=tmp.communicate()
return tmp[0].replace('\n','')
def get():
tags=get_service_tag("svmon_client")
return tags[0]
......
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