def test_connection(self):
"""tests connection to OpenNMS REST API and returns HTTP status code
returns -1, if there was an error connecting to the server
"""
# return code
output = -1
# config
config_rest_url = self.__source.source_url
config_rest_user = self.__source.source_user
config_rest_pw = self.__source.source_password
# test connection to OpenNMS REST API
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
request_url = config_rest_url + "/info"
try:
response = requests.get(request_url, auth=(config_rest_user, config_rest_pw),
verify=False)
except:
return output
return response.status_code
评论列表
文章目录