Fix urllib references
The transition form urllib2 to urllib was not quite right. Some changes were missing .request and .error from the references. Change-Id: Icdc0eb7456b5385a0ef3aa67018f7c64985ed7c7 Story: 2000975 Task: 27818
This commit is contained in:
parent
5756ed9b64
commit
b39994529c
@ -145,19 +145,19 @@ class Apache(monasca_setup.detection.Plugin):
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
if apache_user and apache_pass:
|
if apache_user and apache_pass:
|
||||||
password_mgr = urllib.HTTPPasswordMgrWithDefaultRealm()
|
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
|
||||||
password_mgr.add_password(None,
|
password_mgr.add_password(None,
|
||||||
apache_url,
|
apache_url,
|
||||||
apache_user,
|
apache_user,
|
||||||
apache_pass)
|
apache_pass)
|
||||||
handler = urllib.HTTPBasicAuthHandler(password_mgr)
|
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
|
||||||
else:
|
else:
|
||||||
if 'https' in apache_url:
|
if 'https' in apache_url:
|
||||||
handler = urllib.HTTPSHandler()
|
handler = urllib.request.HTTPSHandler()
|
||||||
else:
|
else:
|
||||||
handler = urllib.HTTPHandler()
|
handler = urllib.request.HTTPHandler()
|
||||||
|
|
||||||
opener = urllib.build_opener(handler)
|
opener = urllib.request.build_opener(handler)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
request = opener.open(apache_url)
|
request = opener.open(apache_url)
|
||||||
@ -172,7 +172,7 @@ class Apache(monasca_setup.detection.Plugin):
|
|||||||
log.info("\tSuccessfully setup Apache plugin.")
|
log.info("\tSuccessfully setup Apache plugin.")
|
||||||
else:
|
else:
|
||||||
log.warn('Unable to access the Apache server-status URL;' + error_msg)
|
log.warn('Unable to access the Apache server-status URL;' + error_msg)
|
||||||
except urllib.URLError as e:
|
except urllib.error.URLError as e:
|
||||||
exception_msg = (
|
exception_msg = (
|
||||||
'\tError {0} received when accessing url {1}.'.format(e.reason, apache_url) +
|
'\tError {0} received when accessing url {1}.'.format(e.reason, apache_url) +
|
||||||
'\n\tPlease ensure the Apache web server is running and your configuration ' +
|
'\n\tPlease ensure the Apache web server is running and your configuration ' +
|
||||||
|
@ -90,13 +90,13 @@ class RabbitMQ(monasca_setup.detection.Plugin):
|
|||||||
:return: bool status of the test
|
:return: bool status of the test
|
||||||
"""
|
"""
|
||||||
url = self.api_url + '/aliveness-test/%2F'
|
url = self.api_url + '/aliveness-test/%2F'
|
||||||
password_mgr = urllib.HTTPPasswordMgrWithDefaultRealm()
|
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
|
||||||
password_mgr.add_password(None,
|
password_mgr.add_password(None,
|
||||||
self.api_url,
|
self.api_url,
|
||||||
self.user,
|
self.user,
|
||||||
self.password)
|
self.password)
|
||||||
handler = urllib.HTTPBasicAuthHandler(password_mgr)
|
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
|
||||||
opener = urllib.build_opener(handler)
|
opener = urllib.request.build_opener(handler)
|
||||||
|
|
||||||
request = opener.open(url)
|
request = opener.open(url)
|
||||||
response = request.read()
|
response = request.read()
|
||||||
|
Loading…
Reference in New Issue
Block a user