Project

General

Profile

Actions

Feature #2391

open

be able to query API for host parameter data

Added by Jon Shanks about 11 years ago. Updated about 11 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Currently there is no API request which will return all data of a host, in terms of the parameters. The current returned data is very limited, IP, mac and date / time of creation etc of the host. The host data cannot be returned unless you own the host. If you attempt to query the External node URI

hosts/#{host_name}/externalNodes?name=#{host_name}

It will try and validate the request trying to fetch the CN i.e. it expects a CN to be there to then validate against a known smart proxy to check that it is that of the puppet master to retrieve the request.

No SSL cert with CN supplied - request from

will be displayed in the logs.

To get around this sessions have to be used with the login attempt to the box:

in python

import requests
login_data = {'formPosted':'1', 'login[login]': 'username', 'login[password]': 'password'}
s = requests.session()
s.post('https://foreman.host.com/users/login', login_data, verify='/var/lib/puppet/ssl/certs/ca.pem')

  1. or you can just use verify=False to not validate

r = s.get('http://foreman.host.com/hosts/host_name/externalNodes?name=host_name')
r.text

will return the output now from the host. without that, it will give a 500 error.


Related issues 2 (2 open0 closed)

Related to Foreman - Feature #9199: API v2 should directly give the override value of smart class parameter for a given hostNew02/03/2015Actions
Related to Foreman - Feature #3220: API for "rendered" view of host parameters, taking into account inheritanceNew10/08/2013Actions
Actions

Also available in: Atom PDF