Fix auth in collins.py inventory

This forces basic auth to be used. Using the normal HTTPPasswordMgrWithDefaultRealm
password manager from urllib2 fails since collins doesn't send a 401 retry on failure.
More about this can be seen here http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-problem.
I added a small comment about the format of the host so others don't waste time like i did.

(cherry picked from commit 21813ed83e)
This commit is contained in:
Michael Schuett 2016-10-31 12:19:22 -04:00 committed by Brian Coca
parent ff0b525608
commit 75cdac0d19
2 changed files with 4 additions and 1 deletions

View file

@ -3,6 +3,8 @@
[collins] [collins]
# You should not have a trailing slash or collins
# will not properly match the URI
host = http://localhost:9000 host = http://localhost:9000
username = blake username = blake

View file

@ -201,7 +201,8 @@ class CollinsInventory(object):
response = open_url(query_url, response = open_url(query_url,
timeout=self.collins_timeout_secs, timeout=self.collins_timeout_secs,
url_username=self.collins_username, url_username=self.collins_username,
url_password=self.collins_password) url_password=self.collins_password,
force_basic_auth=True)
json_response = json.loads(response.read()) json_response = json.loads(response.read())
# Adds any assets found to the array of assets. # Adds any assets found to the array of assets.
assets += json_response['data']['Data'] assets += json_response['data']['Data']