aboutsummaryrefslogtreecommitdiff
path: root/foreman_ansible_inventory.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-02-07 15:16:55 +0100
committerGuido Günther <agx@sigxcpu.org>2016-02-07 15:45:40 +0100
commit3a09d1a5058a1baf80da84686c219f830a04620a (patch)
treed81fababfd5be3e395e918577b2869bbc43b75f7 /foreman_ansible_inventory.py
parent9972f3fff005a065ea6ebaee73e9fc66d0cf8961 (diff)
Raise exception in case of errors
Nicer than complaining about an empty result.
Diffstat (limited to 'foreman_ansible_inventory.py')
-rwxr-xr-xforeman_ansible_inventory.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/foreman_ansible_inventory.py b/foreman_ansible_inventory.py
index 03c2914..b1c0f19 100755
--- a/foreman_ansible_inventory.py
+++ b/foreman_ansible_inventory.py
@@ -119,9 +119,11 @@ class ForemanInventory(object):
self.args = parser.parse_args()
def _get_json(self, url):
- return requests.get(url,
- auth=HTTPBasicAuth(self.foreman_user, self.foreman_pw),
- verify=self.foreman_ssl_verify).json()
+ ret = requests.get(url,
+ auth=HTTPBasicAuth(self.foreman_user, self.foreman_pw),
+ verify=self.foreman_ssl_verify)
+ ret.raise_for_status()
+ return ret.json()
def _get_hosts(self):
return self._get_json("%s/api/v2/hosts" % self.foreman_url)['results']