Created
September 8, 2017 08:11
-
-
Save toabctl/0dba262b9422c3d92e044dc83048db5a to your computer and use it in GitHub Desktop.
Get a keystone token for time measurements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # Copy that script to the node where keystone API is running. | |
| # Use it with: | |
| # PYTHONPATH=. python -m timeit -n 100 -r 1 -s "from keystone_token_get import do_get" "do_get()" | |
| import requests | |
| headers = {'Content-Type': 'application/json'} | |
| data = """ | |
| { "auth": { | |
| "identity": { | |
| "methods": ["password"], | |
| "password": { | |
| "user": { | |
| "name": "admin", | |
| "domain": { "id": "default" }, | |
| "password": "crowbar" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| """ | |
| def do_get(): | |
| r = requests.post( | |
| 'http://localhost:5000/v3/auth/tokens', | |
| data=data, | |
| headers=headers) | |
| if r.status_code != 201: | |
| raise Exception(r.status_code, r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment