Task:
Create an account user and set-up API access:
Steps:
1. Create User:
Cloudstack UI --> Accounts (left menu)--> <select account> --> click View Users (box/button) --> click Add User + (button)
In the Add User dialog, complete the fields:
Username: acmeapi
Password: MyReally1AmazingPwd
Confirm password: MyReally1AmazingPwd
Email: acmeapi@mindwatering.net
First Name: API
Last name: ACME
Timezone: EST5EDT [Easter Standard Time]
Click OK (button)
2. Create API Keys for New User:
a. Open the new user:
Still in the Users view, click the new user just created (e.g. acmeapi)
b. View current key information:
The key information is on the left side at the bottom. The default is:
Api Key Access
INHERIT
c. Change key to Enabled:
Click the edit icon (pencil)
In the Edit dialog:
Api Key Access: Enabled
Click OK (button)
d. After enabling, generate the new keys:
Click the Generate New Keys icon.
In the Generate keys dialog, click OK to confirm.
The new keys are now displayed (partly) under the Api Key Access heading.
Copy the API key, using the copy icon.
Copy the Secret key with the copy icon.
They are now available for use with your REST call.
3. REST Example:
Notes:
- REST API commands are all GET calls
- Is restlike rather than restful, for example:
- - listUsers() view command is a GET (as would be expected)
- - createUser(), updateUser(), and deleteUser() are all a GET (instead of a POST, PATCH, and DELETE)
- GET call components:
- - Base URL + API Path + Command String + Signature
- The signature component is a hash.
How to create the signature hash:
- toLowerCase the "Command String" section
- Ensure all spaces in command string have replaced " " or "+" with %20
- Ensure the field key=value pairs are in ascending alphabetical order
- Pass the updated command string with a HMAC SHA-1 hashing algorithm
- Process the HMAC hash with a Base64 encoding (Base64 UTF-8)
Example URL from OpenStack Developer Guide:
(docs.cloudstack.apache.org/en/latest/developersguide/dev.html)
$ curl http://cloudstackmgmt.minwatering.net:8080/client/api?command=deployVirtualMachine&serviceOfferingId=1&diskOfferingId=1&templateId=2&zoneId=4&apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D
previous page
|