From Fedora Project Wiki

DigitalOcean Installation Guide
}}}
How-To Guide


About

These steps could be useful to speed up a droplet deployment in order to test a Fedora image.

We will invoke DigitalOcean APIs using curl.

Steps

You need to setup an SSH key on DigitalOcean https://cloudsupport.digitalocean.com/s/#none%7Cka21N000000CpMeQAK in order to access Fedora cloud images.
You need to generate a personal access token on DigitalOcean https://cloudsupport.digitalocean.com/s/#none%7Cka21N000000Cp7lQAC in order to be able to use the APIs.

Export some environment variables

export TOKEN="xxxxxxxxxxxxyourtokenxxxxxxxxxxx"
export IMAGE_NAME="Fedora_Test_image"
export IMAGE_URL="https://kojipkgs.fedoraproject.org/compose/rawhide/Fedora-Rawhide-20190217.n.0/compose/Cloud/x86_64/images/Fedora-Cloud-Base-Rawhide-20190217.n.0.x86_64.qcow2"
export REGION="nyc3"
export DROPLET_SIZE="s-1vcpu-1gb"
export DROPLET_NAME="FedoraTest"

Adapt these variables to your needs.

IMAGE_URL should point to the Fedora image URL to test (DigitalOcean supports qcow2 images but it doesn't support compressed raw ones).

To get a list of regions you can use the appropriate API (https://developers.digitalocean.com/documentation/v2/#list-all-regions). Same thing for the droplet size.

Load an image to DigitalOcean

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"name": "'${IMAGE_NAME}'", "url": "'${IMAGE_URL}'", "distribution": "Fedora", "region": "'${REGION}'", "description": "Fedora Test", "tags":["base-image", "test"]}' "https://api.digitalocean.com/v2/images"

Wait some time, and verify that the image is in place

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/images?page=1&per_page=1&private=true"

Take note of the image ID, and export a new variable.

export IMAGE_ID="XXXXXXX"

List SSH keys and take note of the ID

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/account/keys"
export SSH_KEY_ID="YYYYYYYY"

Let's create a droplet

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"name":"'${DROPLET_NAME}'","region":"'${REGION}'","size":"'${DROPLET_SIZE}'","image":"'${IMAGE_ID}'","ssh_keys":['"${SSH_KEY_ID}"'],"backups":false,"ipv6":false,"user_data":null,"private_networking":null,"volumes": null,"tags":["test"]}' "https://api.digitalocean.com/v2/droplets"

List the droplet

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/droplets?tag_name=test"

Take note of the droplet ID and export another variable

export DROPLET_ID="ZZZZZZZZ"

Perform the tests

Now you can ssh as root to the virtual machine (you can get the IP using the list droplets API) and perform the test cases.

Don't forget to delete the droplet and the image

When you reach the end of your tests, and in order to avoid billing on unused resources, don't forget to delete the droplet and the image.

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"type":"destroy"}' "https://api.digitalocean.com/v2/droplets/${DROPLET_ID}/actions"
curl -X DELETE -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" "https://api.digitalocean.com/v2/images/${IMAGE_ID}"