presume 401 from insights means invalid credential

* Tell the user about the invalid credentials
This commit is contained in:
Chris Meyers
2017-08-14 16:09:18 -04:00
parent 5ad29c9081
commit 90ea9b8bde
2 changed files with 11 additions and 1 deletions

View File

@@ -2116,7 +2116,9 @@ class HostInsights(GenericAPIView):
except requests.exceptions.RequestException as e:
return (dict(error=_('Unkown exception {} while trying to GET {}').format(e, url)), status.HTTP_502_BAD_GATEWAY)
if res.status_code != 200:
if res.status_code == 401:
return (dict(error=_('Unauthorized access. Please check your Insights Credential username and password.')), status.HTTP_502_BAD_GATEWAY)
elif res.status_code != 200:
return (dict(error=_('Failed to gather reports and maintenance plans from Insights API at URL {}. Server responded with {} status code and message {}').format(url, res.status_code, res.content)), status.HTTP_502_BAD_GATEWAY)
try: