Skip to content

Instantly share code, notes, and snippets.

@pbasov
Created April 19, 2016 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbasov/7123dcfe12516c32233d737bbe369587 to your computer and use it in GitHub Desktop.
Save pbasov/7123dcfe12516c32233d737bbe369587 to your computer and use it in GitHub Desktop.
import requests
import keystoneclient
import json
keystoneauth={"auth":{"passwordCredentials":{"username": "admin", "password": "admin"},"tenantName": "admin"}}
token = requests.post('http://localhost:5000/v2.0/tokens', headers={'Content-Type': 'application/json'}, data=json.dumps(keystoneauth))
token = json.loads(token.text)['access']['token']['id']
nodes = requests.get('http://localhost:8000/api/nodes', headers={'X-Auth-Token': token})
nodes = json.loads(nodes.text)
for node in nodes:
if node['id'] in nodes:
nodeready = requests.put('http://localhost:8000/api/nodes/%s' % node['id'], headers={'X-Auth-Token': token}, data=json.dumps({'status':'ready'}))
print(nodeready.status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment