Use version 2 of the api. Pass version=2 in the accept header or
api/v2/hosts. Also, PUT of what you get with a GET isn't going to work. You
need to PUT {host: {build: 1}} to api/v2/54/
On Thursday, September 21, 2017 at 4:37:28 PM UTC-4, justin parker wrote:
>
> I am trying to toggle a host's build flag using the api and it's not work
> at all. I've tried setting build_hosts, build, build_status all at the
> same time, one at time, and multiple other combinations with True. Any
> help would greatly be appreciated.
>
> I am using this python script:
>
> import requests
> import json
> import sys
>
> user = 'devopsuser'
> paswd = 'password'
>
> def getHosts():
> targeturl = 'https://foreman.eng.fireeye.com/api/hosts'
> r = requests.get(targeturl, auth=(user, paswd), verify=False)
> return r
>
> def getHost(id):
> targeturl = 'https://foreman.eng.fireeye.com/api/hosts/%s' % id
> r = requests.get(targeturl, auth=(user, paswd), verify=False)
> return r
>
> def putHost(id, payload):
> targeturl = 'https://foreman.eng.fireeye.com/api/hosts/%s' % id
> r = requests.put(targeturl, data=payload, auth=(user, paswd),
> verify=False)
>
>
> r = getHost(54)
>
> results = json.loads(r.text)
> print ['results']
>
> #results['build_hosts'] = '1'
> results['build'] = 1
> #results['build_status'] = '1'
>
> putHost(54, results)
>
> r = getHost(54)
>
> results = json.loads(r.text)
>
> print results
>
>
--
You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.