servers.com allows you to manage your cloud servers and storage via OpenStack API. This article describes how to get started with OpenStack API and avoid exceeding OpenStack rate limits.
Keystone is an OpenStack component responsible for authentication and authorization within the cloud platform. When using OpenStack API, you'll need to authorize via Keystone using its credentials. servers.com uses Keystone v3.
To get credentials, go to Cloud Storage → Create & Manage, select Region and get parameters from the Access credentials section. Credentials are valid within a single cloud region.
You will need the following variables:
Additional parameters that are not shown in the Access credentials section but are required in Keystone, include:
Authentication into Keystone is performed via getting a token that allows you to perform actions within OpenStack. A token is requested by an API request that has the following structure:
Method: POST
Endpoint: <OS_AUTH_URL>/v3/auth
Request headers: Content-Type: application/json
Request body:
{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "<User name>",
"domain": { "name": "default" },
"password": "<Password>"
}
}
},
"scope": {
"project": {,
"name": "<Tenant name>",
"domain": { "name": "default" }
}
}
}
}There are several methods and tools you can use to get a token. These include:
You can generate a token using cURL. This involves making a POST request to the specific API endpoint obtained from the Keystone credentials. Here is an example:
curl -i -X POST \
-H "Content-Type: application/json" \
-d '{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "<User name>",
"domain": { "name": "default" },
"password": "<Password>"
}
}
},
"scope": {
"project": {
"name": "<Tenant name>",
"domain": { "name": "default" }
}
}
}
}' \
https://<keystone_host>:5000/v3/auth/tokensOnce you've made a successful request, you will get a response with a Fernet token in the X-Subject-Token header. You will also see its expiration time in the expires_at parameter.
OpenStack SDK automatically retrieves and renews a token. To set set it up, go through the following steps:
pip install openstacksdk
clouds.yaml file with the following content:
clouds:
mycloud:
auth:
auth_url: https://<keystone_host>:5000/v3
username: <User name>
password: <Password>
project_name: <Tenant name>
user_domain_name: default
project_domain_name: default
region_name: <region_name>
interface: public
You can find the region name in the customer portal: Cloud storage → Access credentials → Shell variables → OS_REGION_NAME value.
from openstack import connection
conn = connection.Connection(cloud='mycloud')
To get a token via the OpenStack client, do the following:
openrc.sh file and insert variables you got on the previous step:
export OS_AUTH_URL=https://auth.servers.%location_id%.cloud.servers.com:5000/v3/
export OS_IMAGE_URL=https://images.servers.%location_id%.cloud.servers.com:9292
export OS_TENANT_NAME=XXX
export OS_USERNAME=YYY
export OS_PASSWORD=ZZZ
export OS_IDENTITY_API_VERSION=3
export OS_DEFAULT_DOMAIN_NAME=default
source openrc.sh
openstack server list
servers.com OpenStack platform has the following limitations:
Please follow the following recommendations to ensure secure token usage:
For security reasons, servers.com imposes limits on the number of authentication requests that you can make in Keystone. Use our recommendations to prevent request overuse: