Introducing Scaleway NextGen NVMe Cloud Servers with Hot-Snapshots. 🚀

Help


Community tutorials and documentations

How to start a server with additional volume from the API

How to start a server with additional volume from the API

This page shows you some basics to interact with the Compute API.

Requirements

API tokens are unique identifiers associated with your Scaleway account and consist of an Access Key (--o or -organisation in the Scaleway CLI) and a Secret Key (--t or -token in the Scaleway CLI). The Secret key is required to authenticate against our API and will only be displayed when you create the token. Make sure to take a note of it and to keep it secret.

There are five steps to provision and start a server with additional volume from the API.

IMPORTANT:

The API endpoint depends on the location where you want to perform an operation. Currently we provide two avialability zones:

  • PAR1 (Paris, France): cp-par1.scaleway.com
  • AMS1 (Amsterdam, Netherlands): cp-ams1.scaleway.com

In this section, we will:

  1. Retrieve the list of images available
  2. Create a new server
  3. Create a new volume
  4. Attach the volume to the server
  5. Start a server

Step 1 - Retrieve the list of images available

The following request returns the list of available images. In this example we only have one image which is named Ubuntu Trusty (14.04) on SSD 2014.06.04 and has id fe8dfea7-bb8c-490c-a554-1a44a3c4af8c.

Request

curl -H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" https://cp-par1.scaleway.com/images

Response

{
  "images": [
    {
      "arch": "arm",
      "creation_date": "2014-06-04T12:38:32.534063+00:00",
      "extra_volumes": "[]",
      "from_image": null,
      "from_server": null,
->    "id": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
      "marketplace_key": null,
      "modification_date": "2014-06-04T12:38:32.534063+00:00",
->    "name": "Ubuntu Trusty (14.04) on SSD 2014.06.04",
      "organization": "cc57d96c-03ac-44a5-bc91-8d1de2bbf8a8",
      "public": true,
      "root_volume": {
        "id": "c583bf78-ebd5-4ebc-863f-71905d2c39fd",
        "name": "Ubuntu Trusty RootFS snapshot"
      }
    }
  ]
}

Step 2 - Create a new server

To create a server, you have to fill out the following input:

  • The commercial type (for example: C1, VC1S, C2M, …)
  • A server name
  • An Organization ID
  • An Image ID
  • Tags (Optional)

Request

curl https://cp-par1.scaleway.com/servers \
-H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" \
-H "Content-Type: application/json" \
-d '{ \
"name": "<YOUR_SERVER_NAME>",
"image": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
"commercial_type": "VC1S",
"tags": ["temporary", "test"],
"organization": "<YOUR_ORGANIZATION_ID>"
}'

Response

{
  "server": {
    "bootscript": null,
    "dynamic_ip_required": true,
    "id": "3cb18e2d-f4f7-48f7-b452-59b88ae8fc8c",
    "image": {
      "id": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
      "name": "Ubuntu Trusty (14.04) on SSD 2014.06.04"
    },
    "name": "<YOUR_SERVER_NAME>",
    "organization": "<YOUR_ORGANIZATION_ID>",
    "private_ip": null,
    "public_ip": null,
    "enable_ipv6": true,
    "state": "stopped",
    "ipv6": null,
    "commercial_type": "VC1S",
    "arch": "x86_64",
    "tags": [
      "test",
      "www"
    ],
    "volumes": {
      "0": {
        "export_uri": null,
        "id": "d9257116-6919-49b4-a420-dcfdff51fcb1",
        "name": "vol simple snapshot",
        "organization": "<YOUR_ORGANIZATION_ID>",
        "server": {
          "id": "3cb18e2d-f4f7-48f7-b452-59b88ae8fc8c",
          "name": "<YOUR_SERVER_NAME>"
        },
        "size": 10000000000,
        "volume_type": "l_ssd"
      }
    }
  }
}

The response above returns an HTTP 201 code with the server details.

Step 3 - Create a new volume

To create a volume, you have to fill out the following input:

  • A volume name
  • An Organization ID
  • A size in GB
  • The volume type - LSSD (Local solid state drive)

You can create and attach additional volumes to an existing server. The server must be stopped.

Let’s create a new volume of type SSD with a size of 50GB.

Request

curl https://cp-par1.scaleway.com/volumes \
-H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" \
-H "Content-Type: application/json" \
-d '{
"name": "<YOUR_VOLUME_NAME>",
"organization": "<YOUR_ORGANIZATION_ID>",
"size": 50000000000,
"volume_type": "l_ssd"
}'

Response

{
  "volume": {
    "export_uri": null,
    "id": "65e7d766-103b-4fb1-819a-fb95e3a15348",
    "name": "<YOUR_VOLUME_NAME>",
    "organization": "<YOUR_ORGANIZATION_ID>",
    "server": null,
    "size": 50000000000,
    "volume_type": "l_ssd"
  }
}

The response above returns an HTTP 201 code with the volume details.

Step 4 - Attach the volume to the server

To attach an additional volume to an existing server, you have to perform a PUT method requests on the server.

Request

curl https://cp-par1.scaleway.com/servers/<YOUR_SERVER_ID> \
-H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" \
-H "Content-Type: application/json" \
-X PUT
-d '{
"dynamic_public_ip": false,
"id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
"image": {
"id": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
"name": "Ubuntu Trusty (14.04) on SSD 2014.06.04"
},
"name": "<YOUR_SERVER_NAME>",
"organization": "<YOUR_ORGANIZATION_ID>",
"private_ip": null,
"public_ip": null,
"state": "stopped",
"state_detail": "",
"tags": [
"temporary",
"test"
],
"volumes": {
---> "0": {"id": "1a96f139-95f8-4680-aeeb-0a58229d18d5", "name": "volume 1"},
---> "1": {"id": "65e7d766-103b-4fb1-819a-fb95e3a15348", "name": "volume 2"}
}
}'

Response

{
  "server": {
    "dynamic_public_ip": false,
    "id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
    "image": {
      "id": "fe8dfea7-bb8c-490c-a554-1a44a3c4af8c",
      "name": "Ubuntu Trusty (14.04) on SSD 2014.06.04"
    },
    "name": "<YOUR_SERVER_NAME>",
    "organization": "<YOUR_ORGANIZATION_ID>",
    "private_ip": null,
    "public_ip": null,
    "state": "stopped",
    "state_detail": "",
    "tags": [
      "temporary",
      "test"
    ],
    "volumes": {
      "0": {
        "export_uri": null,
        "id": "1a96f139-95f8-4680-aeeb-0a58229d18d5",
        "name": "Ubuntu Trusty RootFS snapshot",
        "organization": "<YOUR_ORGANIZATION_ID>",
        "server": {
          "id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
          "name": "<YOUR_SERVER_NAME>"
        },
        "size": 20000000000,
        "volume_type": "l_ssd"
      },
      "1": {
        "export_uri": null,
        "id": "65e7d766-103b-4fb1-819a-fb95e3a15348",
        "name": "<YOUR_VOLUME_NAME>",
        "organization": "<YOUR_ORGANIZATION_ID>",
        "server": {
          "id": "c88d1aee-b65d-4ab9-bafd-3df293782693",
          "name": "<YOUR_SERVER_NAME>"
        },
        "size": 10000000000,
        "volume_type": "l_ssd"
      }
    }
  }
}

Step 5 - Start a server

To start your server, execute the following request where <YOUR_SERVER_ID> is your server id.

Request

 curl -H "X-Auth-Token: <YOUR_API_TOKEN_HERE>" https://cp-par1.scaleway.com/servers/<YOUR_SERVER_ID>/action \
 -d '{"action":"poweron"}' -H "Content-Type: application/json"

Response

{
  "task": {
    "description": "server_batch_poweron",
    "href_from": "/servers/c88d1aee-b65d-4ab9-bafd-3df293782693/action",
    "id": "1f8e2202-83b3-463b-948d-9d1e5aa7dfe1",
    "progress": "0",
    "started_at": "2014-07-22T12:17:39.067932+00:00",
    "status": "pending",
    "terminated_at": null
  }
}

To go even further you can access the API Documentation.

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.