Using cURL with the OpenStack API

A quick way to test drive the OpenStack API is to use the cURL(1) command line utility. cURL is a command-line tool that allows you to send HTTP requests and receive responses. The OpenStack API is based on OpenStack, which provides a RESTful API using standard HTTP methods (GET, POST, etc) and a convenient URL format.

First, log in with your client ID/username and password. You can get the API details from the Cloud Management screen.

Screen Shot 2016-06-14 at 1.28.36 PM
You’ll need the following info:

• Tenant Name
• API Username
• API Password/Secret: • Keystone URL

The Tenant, Name and Keystone URL will be displayed in the portal and are account-specific. You can obtain API Username and API Password by clicking the “Get New API User” button under the Cloud Management screen.

Screen Shot 2016-06-14 at 1.29.01 PM

NOTE: Clicking “Get New API User” will invalidate your previous API user/password.

For the examples below, we’ll assume the following info:

• Tenant Name: inap-1234
• API Username: api-abcd1234
• API Password/Secret: 0123456789abcdef
• Keystone URL: https://identity.api.cloud.iweb.com/v2.0

To authenticate and request a token, use a cURL command as follows:

# curl -i ’https://identity.api.cloud.iweb.com/v2.0/tokens’ -X POST \
-H “Content-Type: application/json” -H “Accept: application/json” \
-d ’{“auth”: {“tenantName”: “inap-1234”, “passwordCredentials”: {“username”: “api-

abcd1234″, “password”:”0123456789abcdef”}}}’

A successful response should look similar to the following:

HTTP /1.1 200 OK
Vary: X-Auth-Token
Content -Type: application/json Content -Length: 5858
Date: Wed, 06 Nov 2013 20:06:24 GMT

Note: Clicking “Get New API User” will invalidate your previous API user/password.

# curl -i ’https://identity.api.cloud.iweb.com/v2.0/tokens’ -X POST \
-H “Content-Type: application/json” -H “Accept: application/json” \
-d ’{“auth”: {“tenantName”: “inap-1234”, “passwordCredentials”: {“username”: “api-

abcd1234″, “password”:”0123456789abcdef”}}}’

{

“access”:{ “token”:{

“issued_at”:”2013-11-06T20:06:24.113908″, “expires”:”2013-11-07T20:06:24Z”,
“id”:”[a really huge long string of text]”, “tenant”:{

“description”:null,
“enabled”:true, “id”:”604bbe45ac7143a79e14f3158df67091″, “name”:”api_name”
}

}, “serviceCatalog”:[

{

“endpoints”:[

{
“adminURL”: “https://compute.api.da01.cloud.iweb.com/v2/[

tenantID]”,
“internalURL”: “https://compute.api.da01.cloud.iweb.com/v2/[

tenantID]”,

“publicURL”: “https://compute.api.da01.cloud.iweb.com/v2/[ tenantID]”,

“region”: “da01” }

], “endpoints_links”:[ ], “type”:”compute”, “name”:”nova”

“endpoints”:[

“adminURL”: “https://image.api.da01.cloud.iweb.com”, “internalURL”: “https://image.api.da01.cloud.iweb.com”, “publicURL”: “https://image.api.da01.cloud.iweb.com”, “region”: “da01”

}, {

{

} ],

“endpoints_links”:[ ],

“type”:”image”,

“name”:”glance” },

{
“endpoints”:[

{

} ],

“endpoints_links”:[ ],

“type”:”volume”,

“name”:”cinder” },

“adminURL”: “https://volume.api.da01.cloud.iweb.com/v1/ e8217e83ef32427bb4e4d217f1390ab4”,

“internalURL”: “https://volume.api.da01.cloud.iweb.com/v1/ e8217e83ef32427bb4e4d217f1390ab4”,

“publicURL”: “https://volume.api.da01.cloud.iweb.com/v1/ e8217e83ef32427bb4e4d217f1390ab4”,

“region”: “da01”

} }