How to Configure and Use OpenStack API in GandiCloud VPS¶
This section explains how to configure the OpenStack public API and use the CLI to manage your GandiCloud resources.
Since GandiCloud VPS is based on OpenStack, you can use the OpenStack API to interact with your server through your command-line interface.
Prepare your environment to use the OpenStack CLI¶
Before you access to the public API, you must configure your command-line interface to access OpenStack.
Install the python OpenStack client.
pip3 install openstackclient
Create a configuration file for the OpenStack CLI, named “my_gandivps_conf.sh”, then enter the following lines, replacing placeholders in the first two lines with relevant values:
#!/usr/bin/env bash export OS_USERNAME="<your gandiv5 username>" export OS_PROJECT_NAME="<The name of the Gandi registered organization you wish to manage resources for>" export OS_USER_DOMAIN_NAME=public export OS_PROJECT_DOMAIN_NAME=public export OS_AUTH_URL=https://keystone.sd6.api.gandi.net:5000/v3 export OS_IDENTITY_API_VERSION=3 echo "Please enter your GandiCloud VPS Password for project $OS_PROJECT_NAME as user $OS_USERNAME: (same password as your gandi v5 account)" read -sr OS_PASSWORD_INPUT export OS_PASSWORD="$OS_PASSWORD_INPUT"
Then source it in your current shell (and on every other shell you wish to use OpenStack CLI):$ source my_gostack_conf.sh
It will prompt for your password. Your password will be stored in the OS_PASSWORD environment variable.
Your environment is ready, you can now use create your first server.
Create Your First OpenStack Server¶
You can now use your command-line interface to create a server, as explained below.
Select an image for your server. An image is a pre-installed operating system that your VM will use to boot.
$ openstack image list
Select a flavor for your server. A flavor is a the combination of CPU&RAM you want for your VM.
$ openstack flavor list
Create a keypair. A key pair is a linked set of public and private SSH keys. You only need to provide your public key. This public key will be installed on your VM, allowing you to SSH to it.
$ openstack keypair create --public-key <your_public_key_file> <keypair_name>
Create your server. This command will create a new volume and then attached it your server.
$ openstack server create --flavor <flavor_id_or_name> --image <image_id_or_name> --boot-from-volume <size-in-GB> --network public --key-name <keypair_name> <server_hostname>
Your server will be in status “BUILD” directly after creation, then it should switch to “ACTIVE”.
You can monitor its status using:
$ openstack server list
You can ssh to your server using your private key. Or, once you have set a password, you can get the console URL to open in your browser using the following:
openstack console url show <your_server_name_or_id>
Want to do more?¶
You can find the official CLI user documentation here: https://docs.openstack.org/python-openstackclient/ussuri/
For other tools or API direct access, the keystone endpoint is available at https://keystone.sd6.api.gandi.net:5000/v3
Projects are mapped to an organization, allowing you to share them the same as other Gandi products. The user is your Gandi username.