Skip to content

Commit

Permalink
Merge pull request #31705 from peripatetic-sojourner/foreman_pillar
Browse files Browse the repository at this point in the history
Foreman pillar
  • Loading branch information
Mike Place committed Mar 7, 2016
2 parents aa5c13f + ba33d75 commit 8f28e45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions salt/pillar/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@
# Set up logging
log = logging.getLogger(__name__)

# Declare virtualname
__virtualname__ = 'foreman'


def __virtual__():
'''
Only return if all the modules are available
'''
if not HAS_REQUESTS:
return False
return __virtualname__


def ext_pillar(minion_id,
Expand Down Expand Up @@ -110,25 +114,14 @@ def ext_pillar(minion_id,
verify=verify,
cert=(certfile, keyfile)
)
result = resp.json
result = resp.json()

log.debug('Raw response of the Foreman request is %r', format(result))

if lookup_parameters:
parameters = dict()
for param in result['parameters']:
resp = requests.get(
url + '/hosts/' + minion_id + '/parameters/'
+ str(param[u'id']),
auth=(user, password),
headers=headers,
verify=verify,
cert=(certfile, keyfile)
)
body = resp.json
log.debug('Raw response of the Foreman parameter lookup'
'request is %r', format(body))
parameters.update({body[u'name']: body[u'value']})
for param in result['all_parameters']:
parameters.update({param[u'name']: param[u'value']})

result[u'parameters'] = parameters

Expand Down
Empty file modified tests/runtests.py
100755 → 100644
Empty file.

0 comments on commit 8f28e45

Please sign in to comment.