From 21813ed83eb899a7c2c78b024abcd9db6ce01023 Mon Sep 17 00:00:00 2001 From: Michael Schuett Date: Mon, 31 Oct 2016 12:19:22 -0400 Subject: [PATCH] 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. --- contrib/inventory/collins.ini | 2 ++ contrib/inventory/collins.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/inventory/collins.ini b/contrib/inventory/collins.ini index 748fcf854a7..0ce0c2acbd9 100644 --- a/contrib/inventory/collins.ini +++ b/contrib/inventory/collins.ini @@ -3,6 +3,8 @@ [collins] +# You should not have a trailing slash or collins +# will not properly match the URI host = http://localhost:9000 username = blake diff --git a/contrib/inventory/collins.py b/contrib/inventory/collins.py index bbcb32b0178..b7193e2f8f1 100755 --- a/contrib/inventory/collins.py +++ b/contrib/inventory/collins.py @@ -201,7 +201,8 @@ class CollinsInventory(object): response = open_url(query_url, timeout=self.collins_timeout_secs, 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()) # Adds any assets found to the array of assets. assets += json_response['data']['Data']