Let customers run Cloud Compute instances
The portal API your storefront uses to show a customer's Cloud Compute instances, and to power, reach, rebuild, snapshot and back them up.
Your storefront's instance panel runs on the portal API. Every route on this page is under /portal/vps/{uuid}/ and takes the customer's token as Authorization: Bearer $CUSTOMER_TOKEN. Only the customer who owns an instance can use it: instances cannot be shared, and any other customer gets 404 with Cloud Compute instance not found.
The routes work like the platform's /api/v1/client/vps/{uuid}/ routes that the Cloud Compute guides describe, and those guides explain each feature in more depth.
Before you begin
Section titled Before you begin- Get a customer token as Sign customers in to your storefront describes.
- Find the instance's
uuid. It isresource.uuidon the customer's service; see Show the customer's services. - Reverse DNS goes through the address's own IP service:
PATCH …/portal/ips/{service_id}/ptr, withhost_addressfor an address inside the instance's IPv6 /64 (Set reverse DNS).
Show an instance
Section titled Show an instancecurl "https://api.coritan.com/api/v1/orgs/acme/portal/vps/$INSTANCE_UUID" \
-H "Authorization: Bearer $CUSTOMER_TOKEN"
The answer is the instance with its status, its plan's size, and the image it runs as template_name, os_family and os_version. username is the account to sign in with, and migration describes a move to another host while one is under way.
| Route | What it returns |
|---|---|
GET /status |
The live state from the instance's host. |
GET /ips |
The instance's addresses, each with its address, gateway and whether it is_primary. |
GET /graphs |
Processor, memory, disk and network samples. timeframe is hour by default, or day, week, month or year. |
GET /bandwidth |
Traffic this period: bytes_in, bytes_out, bytes_used, the plan's limit_tb, remaining_tb, percent_used and over_quota. How instance traffic is counted explains the period. |
Power an instance
Section titled Power an instancecurl -X POST "https://api.coritan.com/api/v1/orgs/acme/portal/vps/$INSTANCE_UUID/power" \
-H "Authorization: Bearer $CUSTOMER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"action": "shutdown"}'
action is start, reboot, shutdown (a clean shutdown) or stop (power off at once), as Start, stop and restart an instance describes. The answer is {"status": "ok", "action": "shutdown"}.
Open the console
Section titled Open the consoleGET /console starts a console session on the instance's host. It answers vnc_ws, vnc_session, vnc_password, expires_in and display, as Use an instance's console shows, and the customer's token as token. Within expires_in seconds, connect a VNC client that speaks WebSocket, such as noVNC, and answer its password prompt with vnc_password:
wss://api.coritan.com/ws/vps/vnc/<instance uuid>?token=<customer token>&session=<vnc_session>
Ask for a new session for every connection. The socket closes with the codes that guide lists when it cannot connect.
Passwords and the hostname
Section titled Passwords and the hostnameGET /credentialsreturns theusername, whether we hold a password (password_stored) andupdated_at, without the password.POST /reset-passwordsets a new random password on a running instance and returns it once, as{"password": "…"}. Show it to the customer straight away, because it cannot be read again.PATCH /hostnamewithhostname(up to 63 characters) sets the hostname.rebootset totruerestarts the instance so the name takes effect at once.
curl -X PATCH "https://api.coritan.com/api/v1/orgs/acme/portal/vps/$INSTANCE_UUID/hostname" \
-H "Authorization: Bearer $CUSTOMER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"hostname": "web-2", "reboot": true}'
Rename and tag an instance gives the hostname rules. A name that breaks them answers 422.
SSH keys
Section titled SSH keysGET /ssh-keysreturns the public keys on the instance asssh_keys(one per line) and theircount.PUT /ssh-keyswithssh_keysreplaces them all. Send an empty string to remove every key. The operating system applies the keys as it starts, so they reach it the next time the customer restarts the instance from your panel (POST /powerwithreboot).
Start an edit from what GET returned, because PUT does not merge.
Reapply the account and network settings
Section titled Reapply the account and network settingsPOST /cloud-init/regenerate writes the instance's settings to it again. Use it when the instance did not pick up a change, such as a primary address the customer attached after it was built.
It writes the user account, the password we hold, the hostname, the DNS resolvers, the primary address and the IPv6 address. It leaves the SSH keys as the customer last saved them. The operating system applies the settings as it starts, so restart the instance afterwards with POST /power and reboot.
Rebuild an instance
Section titled Rebuild an instancePOST /rebuild erases the instance's disk and installs an operating system on it from scratch. The instance keeps its plan, hostname, addresses, SSH keys and backups. It loses every file on the disk and its snapshots, and gets a new random password. Rebuild an instance describes this in full. Because it erases the disk, the request must carry the instance's hostname as the customer typed it.
curl -X POST "https://api.coritan.com/api/v1/orgs/acme/portal/vps/$INSTANCE_UUID/rebuild" \
-H "Authorization: Bearer $CUSTOMER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"template_id": 8, "confirm_hostname": "web-2"}'
template_idis a template fromGET /api/v1/orgs/{org_slug}/storefront/vps-templates.confirm_hostnamemust be the instance's hostname. Letter case and outer spaces do not matter.- The answer is
{"status": "rebuild_queued"}. The rebuild runs as a job, one per instance at a time. PollGET /statusto see it finish. The customer then signs in with an SSH key, or sets a password withPOST /reset-password.
Ask the customer to type the hostname in your panel. Do not fill it in for them: the field is what stops a rebuild on a stray click.
Activity and guest details
Section titled Activity and guest detailsGET /activitylists what was done to the instance, newest first, as{"items": [{"id", "description", "by", "at"}]}.byisyoufor the customer's own actions,stafffor your staff or ours, andsystemfor the rest.limittakes 1 to 100 and defaults to 20.GET /guestreturns what the running system reports about itself:agent_online,os_infoandnetwork_interfaces.agent_onlineisfalsewhile the instance is off or still booting.
Snapshots
Section titled SnapshotsA snapshot saves the instance's disk on its host so the customer can roll back to it. Take and roll back instance snapshots explains how many an instance keeps.
| Route | What it does |
|---|---|
GET /snapshots |
Lists the instance's snapshots. |
POST /snapshots |
Takes one. name is 1–40 characters (default snapshot), description is optional, and vmstate set to true saves the memory too. |
POST /snapshots/{snapshot_id}/rollback |
Returns the instance to the snapshot, losing every change since. |
DELETE /snapshots/{snapshot_id} |
Deletes the snapshot. |
Backups
Section titled BackupsA backup is a full copy of the instance's disk, saved as an archive apart from the disk. Back up and restore an instance explains how many an instance keeps.
GET /backupslists them.POST /backupsstarts one and answers{"backup_id": 812, "status": "creating"}.POST /backups/{backup_id}/restoreanswers{"status": "restore_queued"}, andDELETE /backups/{backup_id}answers{"status": "delete_queued"}. ReadGET /backupsto follow them.
Rescue mode
Section titled Rescue modeRescue mode restarts the instance from a rescue image so the customer can repair its disk, as Repair an instance in rescue mode describes.
- List the images with
GET /rescue/media. Each has avolid. - Enter rescue mode with
POST /rescue/enter, and the image'svolidasiso_volid. With noiso_volid, the first image in the list is used. - When the repair is done,
POST /rescue/exitrestarts the instance from its disk.
Result
Section titled ResultCustomers see each instance they bought from you, with its state, traffic, graphs and activity, and can power it, reach its console, reset its password, change its SSH keys, reapply its settings, rebuild it, and take snapshots and backups without contacting your staff.
Troubleshooting
Section titled TroubleshootingCloud Compute instance not found- The instance is not this customer's, or its service has ended. Check the
uuidagainst their services. Instance is migrating- We are moving the instance to another host. Power actions and new backups are refused until the move ends.
Cannot perform power actions on a suspended instance- The instance is suspended. The service's
statussays so too; see Service statuses. Invalid action. Must be: start, stop, shutdown, reboot- Send one of those words as
action. Type the server's hostname to confirm. A rebuild deletes every file on it.confirm_hostnameis missing or is not the instance's hostname. Read the hostname fromGET /portal/vps/{uuid}and ask the customer to type it.Cannot rebuild a suspended instance- The instance is suspended. It can be rebuilt once its service is active again.
Instance must be running to reset password- Start the instance, wait for it to boot, then reset the password.
Monthly traffic quota exceeded; backups are blocked until the next period- The instance has used its traffic for this period. Backups work again when the next period starts.
iso_volid required- The host has no rescue image to fall back on. Pick a
volidfromGET /rescue/media.