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.

Reply via email to