Project

General

Profile

Actions

Feature #2391

open

be able to query API for host parameter data

Added by Jon Shanks almost 11 years ago. Updated almost 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 #1

Updated by Dominic Cleal almost 11 years ago

  • Status changed from New to Feedback
  • Target version deleted (1.2.0)

What sort of parameters are you trying to retrieve? There is a v2 API in Foreman 1.2, which adds smart class management and parameters for hosts, which sounds like it might do what you want. (The generated docs aren't on the website yet as it's pre-release, sorry.)

Actions #2

Updated by Jon Shanks almost 11 years ago

I was looking for a way to return all host parameters, or perhaps the ability to filter using some glob. If not, then i would need to return all like the ENC and filter myself, which is what i am doing with the code above.

Actions #3

Updated by Dominic Cleal almost 11 years ago

  • Category set to API
  • Status changed from Feedback to New

Plain parameters, or smart class parameters? The former should be possible in API v1 (see host_parameters in "":http://theforeman.org/api/apidoc/hosts/show.html) and API v2 will enhance it with "nested" parameter API calls beneath the host.

There's no support for smart class parameters yet, nor a combined/rendered view of parameters as the external nodes YAML provides, so I'll leave this feature request open. Thanks for the report Jon.

Actions #4

Updated by Dominic Cleal over 8 years ago

  • Related to Feature #9199: API v2 should directly give the override value of smart class parameter for a given host added
Actions #5

Updated by Dominic Cleal over 8 years ago

  • Related to Feature #3220: API for "rendered" view of host parameters, taking into account inheritance added
Actions

Also available in: Atom PDF