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:
esampson 2018-10-30 08:56:00 -07:00 committed by Joseph Davis
parent 5756ed9b64
commit b39994529c
2 changed files with 9 additions and 9 deletions

View File

@ -145,19 +145,19 @@ class Apache(monasca_setup.detection.Plugin):
return config
if apache_user and apache_pass:
password_mgr = urllib.HTTPPasswordMgrWithDefaultRealm()
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None,
apache_url,
apache_user,
apache_pass)
handler = urllib.HTTPBasicAuthHandler(password_mgr)
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
else:
if 'https' in apache_url:
handler = urllib.HTTPSHandler()
handler = urllib.request.HTTPSHandler()
else:
handler = urllib.HTTPHandler()
handler = urllib.request.HTTPHandler()
opener = urllib.build_opener(handler)
opener = urllib.request.build_opener(handler)
try:
request = opener.open(apache_url)
@ -172,7 +172,7 @@ class Apache(monasca_setup.detection.Plugin):
log.info("\tSuccessfully setup Apache plugin.")
else:
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 = (
'\tError {0} received when accessing url {1}.'.format(e.reason, apache_url) +
'\n\tPlease ensure the Apache web server is running and your configuration ' +

View File

@ -90,13 +90,13 @@ class RabbitMQ(monasca_setup.detection.Plugin):
:return: bool status of the test
"""
url = self.api_url + '/aliveness-test/%2F'
password_mgr = urllib.HTTPPasswordMgrWithDefaultRealm()
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None,
self.api_url,
self.user,
self.password)
handler = urllib.HTTPBasicAuthHandler(password_mgr)
opener = urllib.build_opener(handler)
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
opener = urllib.request.build_opener(handler)
request = opener.open(url)
response = request.read()