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

(Fix) - Get versions for b2handle

parent 0eaf3c54
......@@ -4,7 +4,7 @@ from setuptools import setup
setup(
name='svmon-client',
version='2.3.1',
version='2.3.2',
packages=['svmon_client'],
scripts=['svmon'],
package_data={'' : ['*.json','*.pem']},
......
......@@ -74,9 +74,8 @@ class SVMONReport:
exit(-1)
else:
self.service_names = services.get_service_name(self.service_type)
b2handle_config= {}
if self.service_type == 'b2handle' or self.service_type == "B2HANDLE":
b2handle_config= {}
cwd = os.path.dirname(services.__file__)
filename = cwd + "/config.json"
readok = os.access(filename, os.R_OK)
......@@ -86,9 +85,11 @@ class SVMONReport:
with open(filename, 'r') as f:
load_dict= json.load(f)
if 'handle_server_path' in load_dict:
if load_dict.get('handle_server_path') != None and load_dict.get('handle_server_path') != '':
if load_dict.get('handle_server_path') != None and load_dict.get('handle_server_path') != '':
b2handle_config['handle_server_path'] = load_dict.get('handle_server_path')
self.tags = services.get_service_tag(self.service_type,b2handle_config)
self.service_names = services.get_service_name(self.service_type)
return
else:
print("No configuration for b2handle, please see svmon help")
exit(1)
......@@ -104,10 +105,11 @@ class SVMONReport:
with open(filename, 'r') as f:
load_dict= json.load(f)
if 'svmon_app_path' in load_dict:
if load_dict.get('svmon_app_path') != None and load_dict.get('svmon_app_path') != '':
if load_dict.get('svmon_app_path') != None and load_dict.get('svmon_app_path') != '':
svmon_config['svmon_app_path'] = load_dict.get('svmon_app_path')
self.tags = services.get_service_tag(self.service_type,svmon_config)
self.service_names = services.get_service_name(self.service_type)
return
else:
print("No configuration for svmon, please see svmon help")
exit(1)
......@@ -406,7 +408,9 @@ class SVMONReport:
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
r = re.post(url, data=json.dumps(res), headers=headers, verify=cert)
#r = re.post(url, data=json.dumps(res), headers=headers, verify=cert)
#r = re.post(url, headers=headers, data=json.dumps(res), verify=False)
print('Request to svmon server finished with status code:', r.status_code)
if(r.status_code == 401):
......
......@@ -51,7 +51,7 @@ def get_service_name(service_type):
def get_service_tag(service_type,configs=None):
print("Get service tag called...")
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")
......@@ -67,7 +67,6 @@ def get_service_tag(service_type,configs=None):
return tags
elif service_type == "gitlab":
#tags.append("ce15") #currently for test
tmp = get_by_rpm_packages("gitlab", 0 , 1)
if tmp == None or tmp == '' or tmp.find('Failed') >-1:
print("no gitlab version can be resolved")
......@@ -94,7 +93,7 @@ def get_service_tag(service_type,configs=None):
exit(-1)
elif service_type == "svmon":
if 'svmon_app_path' in configs:
if configs != None and 'svmon_app_path' in configs:
print('Getting svmon version from config file')
tags={}
if configs.get('svmon_app_path') != None and configs.get('svmon_app_path') != '' :
......@@ -102,13 +101,14 @@ def get_service_tag(service_type,configs=None):
tags['svmon'] = [svmonVersions[1], svmonVersions[3]]
_services['svmon']=[svmonVersions[0], svmonVersions[2]]
return tags['svmon']
print('Returning default versions for svmon')
return _tags['svmon']
else:
print('No svmon configuration to get versions, returning default versions for svmon')
return _tags['svmon']
elif service_type == "b2handle" or service_type == "B2HANDLE":
if 'handle_server_path' in configs:
if configs != None and 'handle_server_path' in configs:
tags=[]
if configs.get('handle_server_path') != None and configs.get('handle_server_path') != '' :
if configs.get('handle_server_path') != None and configs.get('handle_server_path') != '' :
tags.append(get_handle_server(configs.get('handle_server_path')))
return tags
else:
......@@ -217,11 +217,11 @@ def get_version():
if(python_version() >= '3.0'):
if(enableDebug):
print("Running getVersion() for python3...")
tmp = subprocess.Popen('python3 -m pip show svmon-python-client', shell=True, stdout=subprocess.PIPE)
tmp = subprocess.Popen('python3 -m pip show svmon-client', shell=True, stdout=subprocess.PIPE)
else:
if(enableDebug):
print("Running getVersion() for python2...")
tmp = subprocess.Popen('python -m pip show svmon-python-client', shell=True, stdout=subprocess.PIPE)
tmp = subprocess.Popen('python -m pip show svmon-client', shell=True, stdout=subprocess.PIPE)
tmp = subprocess.Popen('grep Version', shell=True, stdin=tmp.stdout, stdout=subprocess.PIPE)
tmp = tmp.communicate()
......
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