All test are performed from standalone VM outside of the OpenStack cloud. First, establish passwordless SSH authentication between Standalone VM and OpenStack controller. Use following method to invoke the script from standalone VM which will run o on controller VM and get the details.
ssh –T <controller hostname/ip> < script.sh
Here –T Disable pseudo-tty allocation from VM
External and Internal API networking.
- To access external API and internal API network I used curl utility to make API calls.
- Using curl generate a new token first by providing tenant name, username, password and controller IP. We can be used admin auth_token as well but that token will fetch details related to admin tenant only. Here we can generate a token for any tenant.
- This generates endpoint list with a token in the bottom.
- Now using this token we can gather any information from OpenStack cloud.
- Example get network details using this token.
- I have created one script which will create a token to get some info from OpenStack like tenants details and network details. If we get the result then the test is passed otherwise failed.
https://github.com/vishmule/OpenStack-Neutron-Validation-Scripts/blob/master/OpenStack_API_Check.sh
This file contains 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
#!/bin/bash | |
HOST_IP=192.168.56.105 | |
ADMIN_TOKEN=$(\ | |
curl http://192.168.56.105:5000/v3/auth/tokens \ | |
-s \ | |
-i \ | |
-H "Content-Type: application/json" \ | |
-d ' | |
{ | |
"auth": { | |
"identity": { | |
"methods": [ | |
"password" | |
], | |
"password": { | |
"user": { | |
"domain": { | |
"name": "Default" | |
}, | |
"name": "admin", | |
"password": "openstack" | |
} | |
} | |
}, | |
"scope": { | |
"project": { | |
"domain": { | |
"name": "Default" | |
}, | |
"name": "admin" | |
} | |
} | |
} | |
}' | grep ^X-Subject-Token: | awk '{print $2}' ) | |
#STORE TOKEN | |
header='X-Auth-Token: '$ADMIN_TOKEN | |
#NOW USE the AUTH TOKEN TO CHECK TENANTS | |
curl -X GET http://$HOST_IP:5000/v2.0/tenants/ -H "$header" | python -m json.tool | |
#NOW USE the AUTH TOKEN TO CHECK NETWORK DETAILS. | |
curl -H "Content-Type: application/json" -H "$header" -X GET http://$HOST_IP:9696/v2.0/networks | python -m json.tool |