CNAPI - Triton Compute Node API

April 24, 2024 · View on GitHub

Overview

CNAPI is the 'Compute Node API' which presents an API to communicate and interact with Compute Nodes (CNs).

Responsibilities

CNAPI provides a unified interface to common Compute Node operations, such as server setup, factory-resetting, virtual machine life-cycle actions (creation, state transitions, destruction, etc.) In general, if it needs to talk to compute nodes, it should happen through CNAPI.

Compute Node Startup

When a compute node is started up from a shutdown state, regardless if it has been set up, it will broadcast a message containing the payload from the sysinfo utility. This broadcast message is picked up by CNAPI.

Configuration

Reference for configuration variables in cnapi, which are stored in config/config.json in a running setup. An example of this configuration can be found in sapi_manifests/cnapi/template.

VarTypeDefaultDescription
logLevelStringinfoLevel at which to log. One of the supported Bunyan log levels.
datacenter_nameString-Name of the SDC datacenter on which CNAPI is running.
adminUuidString-The UUID of the admin user in this SDC standup.
amqpObject-If either transport above specifies "amqp", this section is needed.
amqp.hostString-Host of AMQP broker.
moray.hostString-The Moray API URL.
moray.portNumber2020The Moray API port.
api.portNumber80Port number on which to listen.
wfapi.workflowsArray[]Array of workflows to load.
wfapi.urlString-The Workflow API URL.
napi.urlString-The NAPI API URL.
assets.urlString-
cnapi.urlString-The CNAPI API URL (e.g. of this instance)
imgapi.urlString-The IMGAPI API URL.
dapi.changeDefaultsObject-This provides some means to override VM allocation behaviour.
dapi.changeDefaults.server_spreadString-DEPRECATED How VMs are spread across CNs (one of: min-ram, max-ram, min-owner, and random)
dapi.changeDefaults.filter_docker_min_platformString-If present, minimum platform version useful for Docker instances.
dapi.changeDefaults.filter_flexible_disk_min_platformString-If present, minimum platform version useful for instances with flexible disk sizing.
dapi.changeDefaults.filter_capnessStringtrueWhether to disallow mixing of instances that set cpu_caps with instances that do not set cpu_caps on the same compute node.
dapi.changeDefaults.filter_headnodeStringtrueWhether VMs cannot allocate on the headnode.
dapi.changeDefaults.filter_min_resourcesStringtrueWhether CPU/RAM/disk limits are ignored when allocating.
dapi.changeDefaults.filter_large_serversStringtrueWhether large servers are reserved for larger allocations.
dapi.changeDefaults.overprovision_ratio_cpuString4.0How much CPU will be overprovisioned per CN by default.
dapi.changeDefaults.overprovision_ratio_ramString1.0How much RAM will be overprovisioned per CN by default.
dapi.changeDefaults.overprovision_ratio_diskString1.0How much disk will be overprovisioned per CN by default.
dapi.changeDefaults.disable_override_overprovisioningStringfalseWhether to turn off the hard setting of defaults for provisioning across CNs and packages.
dapi.changeDefaults.weight_current_platformString1.0Bias selection towards CNs with newer platforms.
dapi.changeDefaults.weight_next_rebootString0.5Bias selection away from CNs with nearer scheduled reboots.
dapi.changeDefaults.weight_num_owner_zonesString0.0Bias selection away from CNs with more VMs belonging to the current owner.
dapi.changeDefaults.weight_uniform_randomString0.5Bias selection towards random CNs.
dapi.changeDefaults.weight_unreserved_diskString1.0Bias selection towards CNs with more unreserved disk.
dapi.changeDefaults.weight_unreserved_ramString2.0Bias selection towards CNs with more unreserved disk.
dapi.allocationDescriptionArraysee templateThe pipeline used by the allocator to decide where a VM goes across CNs.

dapi.changeDefaults is a bit of an oddball, due to limitations in the hogan.js template engine. Booleans are represented by the "true" and "false" strings, not raw booleans; an empty string is treated as the default value. Be careful when changing from the defaults in production.

SAPI Configuration

When using the config-agent service in the CNAPI zone, which draws metadata from SAPI, it's possible to change the dapi.changeDefaults outlined in the Configuration section above.

In the SAPI "cnapi" service, adding or changing the following keys in metadata will affect allocation behaviour. This is useful for testing, or specialized circumstances in production.

KeyTypeDefaultDescription
ALLOC_SERVER_SPREADString-DEPRECATED How the allocator spreads VMs across CNs.
ALLOC_FILTER_CAPNESSBooleantrueWhether to disallow mixing of instances that set cpu_caps with instances that do not set cpu_caps on the same compute node.
ALLOC_FILTER_HEADNODEBooleantrueWhether the headnode should be removed from consideration during allocation.
ALLOC_FILTER_MIN_DISKBooleanfalseWhether CNs with insufficient spare disk should be removed.
ALLOC_FILTER_MIN_RESOURCESBooleantrueWhether CNs with insufficient spare CPU/RAM/disk should be removed.
ALLOC_FILTER_LARGE_SERVERSBooleantrueWhether large servers should be reserved primarily for large allocations.
ALLOC_FILTER_VM_COUNTInteger224CNs with equal or more VMs than this will be removed from consideration.
ALLOC_FILTER_DOCKER_MIN_PLATFORMString-If present, minimum platform version useful for Docker instances.
ALLOC_DISABLE_OVERRIDE_OVERPROVISIONINGBooleanfalseIf true, allow packages and CNs to dictate overprovision ratios.
ALLOC_OVERRIDE_OVERPROVISION_CPUFloat4.0The ratio of CPU overprovisioning that will be hard set.
ALLOC_OVERRIDE_OVERPROVISION_RAMFloat1.0The ratio of RAM overprovisioning that will be hard set.
ALLOC_OVERRIDE_OVERPROVISION_DISKFloat1.0The ratio of disk overprovisioning that will be hard set.
ALLOC_WEIGHT_CURRENT_PLATFORMFloat1.0Bias selection towards CNs with newer platforms.
ALLOC_WEIGHT_NEXT_REBOOTFloat0.5Bias selection away from CNs with nearer scheduled reboots.
ALLOC_WEIGHT_NUM_OWNER_ZONESFloat0.0Bias selection away from CNs with more VMs belonging to the current owner.
ALLOC_WEIGHT_UNIFORM_RANDOMFloat0.5Bias selection towards random CNs.
ALLOC_WEIGHT_UNRESERVED_DISKFloat1.0Bias selection towards CNs with more unreserved disk.
ALLOC_WEIGHT_UNRESERVED_RAMFloat2.0Bias selection towards CNs with more unreserved memory.
FEATURE_USE_CNAGENT_COMMAND_EXECUTEBooleanfalseExperimental: Use cn-agent's command_execute function instead of Ur when available.
SMT_ENABLED_DEFAULTBooleantrueThe default simultaneous multi-threading mode for newly-installed CNs.

If any of the keys above aren't in the sdc metadata section, it's treated as if the default value was specified. Be careful when changing from the default values in production.

ALLOC_SERVER_SPREAD is deprecated in favour of ALLOC_WEIGHT_*. It can have one of four values: min-ram, max-ram, min-owner, and random. min-ram selects CNs which have the least amount of sufficient space for a new VM. max-ram selects CNs which have the most amount of free space. min-owner makes the allocator much more aggressive about balancing all VMs belonging to one user across all CNs. And random assigns randomly across CNs.

ALLOC_WEIGHT_* attributes can have negative values, not just positive. Negative values have the opposite effect of negative values; e.g. a postive ALLOC_WEIGHT_NUM_OWNER_ZONES biases selection towards CNs with fewer VMs belonging to the owner of the current allocation, while a negative value would bias towards CNs with more such VMs.

A note of warning about ALLOC_FILTER_MIN_DISK: if this is set to true, but ALLOC_FILTER_MIN_RESOURCES is set to false, then disk checks will be ignored. Both must be true for disk checks to proceed.

ALLOC_OVERRIDE_OVERPROVISION_* is playing with fire. While twiddling with the default cpu overprovision ratio is fairly safe, RAM and disk are hazardous to increase beyond 1.0 if KVM instances are ever provisioned; it can lead to KVM instances which cannot boot, or KVM instances with corrupt filesystems. It's recommended you don't fiddle with these values unless you know what you're doing, have tested this heavily before pushing to production, and are willing to deal with the consequences if things go bad.

ALLOC_DISABLE_OVERRIDE_OVERPROVISIONING should only be set to true if all CNs and packages have had sane overprovision values set, after careful consideration of how the DC will be split up for the differing ratios. If in doubt, don't change the default.

FEATURE_USE_CNAGENT_COMMAND_EXECUTE should only be set true if you want CNAPI to send CommandExecute requests to a CN via cn-agent's command_execute task when that is available (I.e. cn-agent is new enough). If this is false (the default) or if a CN does not have a new enough cn-agent to support command_execute, the CommandExecute will fall back to using Ur transparently. Enabling this is currently considered experimental as its backward compatibility has not been tested with the full spectrum of possible production scripts.

Example

cnapi_svc=$(sdc-sapi /services?name=cnapi | json -Ha uuid)
sdc-sapi /services/$cnapi_svc -X PUT -d '{ "metadata": { "ALLOC_FILTER_HEADNODE": false } }'

Interacting with CNAPI

There are two ways of interacting with CNAPI. Indirectly: eg. adminui, cloudapi, workflow, vmapi. Directly: eg. sdc-cnapi, sdc-server, curl.

Use it as so:

-bash-4.1# sdc-cnapi /servers/5e4bafa8-9dfd-11e3-982d-a7dee2e79ac4 \
                -X POST \
                -d '{ "datacenter_name": "foo" }'

Metrics

CNAPI exposes metrics via node-triton-metrics on http://<ADMIN_IP>:8881/metrics.

Heartbeats

After setup, each server is populated with agents which allow the Triton services to monitor and perform actions on these servers. One of these agents is cn-agent, its responsibility is to execute tasks on the server and to periodically post server usage and information to CNAPI. CNAPI in turn uses these heartbeat events to determine whether a server is running.

Every time CNAPI receives a heartbeat via POST to /servers/:uuid/events/heartbeat, CNAPI updates its in-memory store which maps server_uuid to last_heartbeat, setting the value to the current time.

Every HEARTBEAT_RECONCILIATION_PERIOD_SECONDS (currently 5) seconds, CNAPI will check the heartbeats stored in its in-memory store and for each server:

  • If the last_heartbeat is not stale (more on this below), it does nothing for this server.

  • If CNAPI has not previously written data for this server, it tries to add/update an entry to the cnapi_status bucket in moray. If successful, it will also try to update the server's status property to running.

  • If the last_heartbeat is stale, it tries to update the cnapi_status bucket in moray with the last last_heartbeat value this CNAPI has seen. If the cnapi_status entry is updated, the server's status it also attempts to set the status property to unknown for this server.

To determine whether a heartbeat is "stale", CNAPI compares the last_heartbeat against the current time. If the last heartbeat is more than HEARTBEAT_LIFETIME_SECONDS seconds old, the heartbeat is considered stale. The process that runs periodically to check heartbeats is called the reconciler.

Any time CNAPI writes to the cnapi_status bucket, it also includes the cnapi_instance property identifying the CNAPI instance in which the value was observed. This way, if there are multiple CNAPI's, it is possible to determine which CNAPI has last received heartbeats for a given CN.

There are a few artedi metrics that are exposed related to heartbeating. These will be available when polling the /metrics endpoint with prometheus. The available metrics are:

heartbeating_servers_count

A gauge indicating how many servers have recently (within the heartbeat lifetime) heartbeated to this server.

reconciler_new_heartbeaters_total

A counter that indicates how many times this CNAPI has seen a heartbeat from a new server, or a server that it had forgotten (e.g. because it went stale).

reconciler_stale_heartbeaters_total

A counter that indicates the number of times CNAPI noticed that a server had not heartbeated recently and the last_heartbeat was considered stale.

reconciler_usurped_heartbeaters_total

A counter that indicates the of times CNAPI went to update cnapi_status but found that another server had updated it more recently.

reconciler_server_put_total

A counter indicating the number of times CNAPI attempted to put cnapi_servers objects into moray.

reconciler_server_put_etag_failures_total

A counter indicating how many times there were Etag failures putting cnapi_servers objects into moray because the data changed between get and put.

reconciler_server_put_failures_total

A counter indicating the total number of putObject calls to cnapi_servers have failed.

reconciler_status_put_total

A counter indicating the number of times CNAPI attempted to put cnapi_status objects into moray.

reconciler_status_put_etag_failures_total

A counter indicating how many times there were Etag failures putting cnapi_status objects into moray because the data changed between get and put.

reconciler_status_failures_total

A counter indicating the total number of putObject calls to cnapi_status have failed.

Resetting to Factory Defaults

To reset a compute node to its factory default state, PUT to the server's factory-reset endpoint:

-bash-4.1# sdc-cnapi /servers/564d5f0d-3517-5f60-78f1-ce6d0b8f58df/factory-reset \
                -X PUT
HTTP/1.1 202 Accepted
Content-Type: application/json
Content-Length: 51
Date: Tue, 25 Feb 2014 09:24:52 GMT
Server: Compute Node API
x-request-id: ae6426e0-9dfe-11e3-96ca-d3493bcec4fe
x-response-time: 28
x-server-name: a6b7ba97-deb7-44b1-85da-3d7ae328c710
Connection: keep-alive

{
  "job_uuid": "4a664491-aa29-4d77-9fc2-592308d56922"
}

The UUID of the factory reset job is returned and can be used to poll for the completion of the operation.

Virtual Machine Actions

One of the main mechanisms via which CNAPI interacts with compute nodes VMs is via AMQP messages sent to and received from the provisioner agent on the compute node.

-bash-4.1# sdc-cnapi /servers/$(sysinfo |json UUID)/vms/f9940090-a065-11e3-81fd-274008e46b67machine_reboot \
        -X POST \
        -d '{}'

See the reference for the API for available VM endpoitns.

Remote Execution (deprecated)

IMPORTANT: This functionality is deprecated and will be removed in a future release. It exists only for backward compatibility and should not be used for any new development. If you wish to execute commands on a CN, this should be done through a new cn-agent task, or a new agent.

CNAPI exposes a mechanism to allow remote execution of commands.

-bash-4.1# sdc-cnapi /servers/$(sysinfo |json UUID)/execute \
        -X POST \
        -d '{ "script": "#!/bin/bash\necho hi \$1 $FOO", "args": ["hello"],
              "env": { "FOO": "1" } }'

Using the script, args, and env properties we can control the source we execute, the arguments to that script and any environment variables.

Boot parameters

When a compute node boots up, its boot-loader fetches the necessary information from booter. These booter in turn requests this data, consisting of platform, kernel_flags and kernel_modules from CNAPI.

Operations on boot parameters are done via the /boot endpoint.

On the the initial, boot from a "factory default" state, the "default" boot parameters will be fetched from the /boot/default endpoint.

Setting the default boot platform for new compute nodes:

-bash-4.1# sdc-cnapi /boot/ac586cae-9ace-11e3-a64e-7f4008875a90 \
    -X PUT \
    -d '{ "platform": "20140219T205617Z" }'

Kernel arguments are key/value pairs passed in to the kernel. They are distinct from kernel flags.

For example, to set the kernel arguments and flags for a compute node with uuid 21306a50-9dad-11e3-9404-53f0c3de6cb8:

-bash-4.1# sdc-cnapi /boot/21306a50-9dad-11e3-9404-53f0c3de6cb8 \
    -X POST
    -d '{ "kernel_args": { "foo": "bar" }, "kernel_flags": { "-k": true } }'

The same as the above, but with -kd:

-bash-4.1# sdc-cnapi /boot/21306a50-9dad-11e3-9404-53f0c3de6cb8 \
    -X POST
    -d '{ "kernel_args": { "foo": "bar" }, "kernel_flags": { "-kd": true } }'

Setting noimport:

-bash-4.1# sdc-cnapi /boot/21306a50-9dad-11e3-9404-53f0c3de6cb8 \
    -X POST
    -d '{ "kernel_args": { "noimport": "true" } }'

Passing null as the value to a key deletes that key/value.

For instance, to delete the foo key:

sdc-cnapi /boot/21306a50-9dad-11e3-9404-53f0c3de6cb8 \
    -X POST
    -d '{ "kernel_args": { "foo": null } }'

To completely overwrite values, use PUT instead of POST:

-bash-4.1# sdc-cnapi /boot/21306a50-9dad-11e3-9404-53f0c3de6cb8 \
    -X PUT
    -d '{ "kernel_args": { "alpha": "able" } }'

It's also possible to set boot_modules either for a single compute node or by default for any compute node. boot_modules is a collection of module objects. Each member of this collection is expected to have the following structure:

  {
      "path": "boot module path to be used by booter",
      "type": "Content type. Right now only base64 is supported",
      "content": "File contents, if necessary encoded as specified"
  }

While it's possible that new content types could be added in the future, right now file contents are expected to be base64 encoded and max content length is of 4KB. When no value for content if specified, it's assumed to be the default.

-bash-4.1# sdc-cnapi /boot/21306a50-9dad-11e3-9404-53f0c3de6cb8 \
    -X PUT \
    -d '{ "boot_modules": [ { "path": "etc/ppt_aliases", "content": "cHB0ICIvcGNpQDAsMC9wY2k4MDg2LDE1MUAxL2Rpc3BsYXlAMCIK" } ] }'

Setting up a new Server

Setting when a new server comes online its status should be be visible as 'running', and its setup state should be 'unsetup':

-bash-4.1# sdc-cnapi /servers | json -Hga uuid setup status
564d2cec-76f9-2438-7f66-9140267bed05 true running
564d5f0d-3517-5f60-78f1-ce6d0b8f58df false running

To set up the new server, one may use one of the indirect methods (adminui, etc).

Additionally, one may also use sdc-server:

-bash-4.1# sdc-server setup 564d5f0d-3517-5f60-78f1-ce6d0b8f58df

Or, sdc-cnapi:

-bash-4.1# sdc-cnapi /servers/564d5f0d-3517-5f60-78f1-ce6d0b8f58df/setup \
                -X PUT

To run a script after successful setup completion, use the postsetup_script parameter. The script will be run within the global zone of the compute node in question:

-bash-4.1# sdc-cnapi /servers/564d5f0d-3517-5f60-78f1-ce6d0b8f58df/setup -X PUT -d '{ "postsetup_script": "#!/bin/bash\necho > /var/tmp/myfile" }'

Updating Nics

The only parameter of the server's nics that can be changed is nic_tags_provided. This parameter can be changed depending on the following values for the action parameter:

  • update: Add nic tags to the target nics
  • replace: Replace the nic tags (ie: completely overwrite the list) for the target nics
  • delete: Remove the nic tags from the target nics

Examples

update

Add the manta nic tag to a nic with sdc-cnapi:

sdc-cnapi /servers/564d4d2c-ddd0-7be7-40ae-bae473a1d53e/nics \
-X PUT '\
    {
        "action": "update",
        "nics": [
            {
                "mac": "00:0c:29:a1:d5:3e",
                "nic_tags_provided": [ "manta" ]
            }
        ]
    }'

Or with sdc-server:

sdc-server update-nictags -s 564d4d2c-ddd0-7be7-40ae-bae473a1d53e \
    manta_nic=00:0c:29:a1:d5:3e

replace

Set the nic tags for a nic to external and mantanat (removing all other nic tags) with sdc-cnapi:

sdc-cnapi /servers/564d4d2c-ddd0-7be7-40ae-bae473a1d53e/nics \
-X PUT '\
    {
        "action": "replace",
        "nics": [
            {
                "mac": "00:0c:29:a1:d5:3e",
                "nic_tags_provided": [ "external", "mantanat" ]
            }
        ]
    }'

Or with sdc-server:

sdc-server replace-nictags -s 564d4d2c-ddd0-7be7-40ae-bae473a1d53e \
    external_nic=00:0c:29:a1:d5:3e mantanat_nic=00:0c:29:a1:d5:3e

delete

Remove the mantanat nic tag from a nic with sdc-cnapi:

sdc-cnapi /servers/564d4d2c-ddd0-7be7-40ae-bae473a1d53e/nics \
-X PUT '\
    {
        "action": "delete",
        "nics": [
            {
                "mac": "00:0c:29:a1:d5:3e",
                "nic_tags_provided": [ "mantanat" ]
            }
        ]
    }'

Or with sdc-server:

sdc-server delete-nictags -s 564d4d2c-ddd0-7be7-40ae-bae473a1d53e \
    mantanat_nic=00:0c:29:a1:d5:3e

Server records

A CNAPI server record looks like the following

# sdc-cnapi /servers/564d4374-d703-b97b-ca9f-7375f05f337c

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 9848
Date: Tue, 22 Apr 2014 08:35:10 GMT
Server: Compute Node API
x-request-id: 03f340c0-c9f9-11e3-9a2b-e36882367c85
x-response-time: 15
x-server-name: c587f0fc-a962-49cb-a4d2-cd9cb0efb9b9
Connection: keep-alive

{
  "sysinfo": {
     --- compute node sysinfo ---
  },
  "ram": 4095,
  "current_platform": "20140421T214627Z",
  "headnode": true,
  "boot_platform": "20140421T214627Z",
  "datacenter": "coal",
  "overprovision_ratio": 1,
  "reservation_ratio": 0.15,
  "reservoir": false,
  "traits": {},
  "rack_identifier": "",
  "comments": "",
  "uuid": "564d4374-d703-b97b-ca9f-7375f05f337c",
  "hostname": "headnode",
  "reserved": false,
  "boot_params": {
    "rabbitmq": "guest:guest:rabbitmq.coal.joyent.us:5672"
  },
  "kernel_flags": {},
  "default_console": "vga",
  "serial": "ttyb",
  "setup": true,
  "setting_up": false,
  "last_boot": "2014-04-22T07:39:50.000Z",
  "created": "2014-04-22T07:37:30.000Z",
  "vms": {
     --- compute node vm objects ---
  },
  "transitional_status": "",
  "last_heartbeat": "2014-04-22T08:35:07.776Z",
  "status": "running",
  "memory_available_bytes": 2044813312,
  "memory_arc_bytes": 184096272,
  "memory_total_bytes": 4284993536,
  "memory_provisionable_bytes": -44936986624,
  "disk_kvm_zvol_used_bytes": 0,
  "disk_kvm_zvol_volsize_bytes": 0,
  "disk_kvm_quota_bytes": 0,
  "disk_zone_quota_bytes": 536870912000,
  "disk_cores_quota_bytes": 429496729600,
  "disk_installed_images_used_bytes": 950053376,
  "disk_pool_size_bytes": 159987531776,
  "overprovision_ratios": {
    "ram": 1
  },
  "unreserved_cpu": 400,
  "unreserved_ram": -42863,
  "unreserved_disk": 151669
}

Server properties

ParamTypeExtrasDescription
agentsArray of ObjectagentsThe installed agents on this server
boot_paramsObject
boot_platformStringThe platform image to be booted from on next boot
commentsStringDescription of server
createdString dateDate of server creation
current_platformStringThe platform image currently in use by server
datacenterStringDatacenter in which server resides
default_consoleString
disk_cores_quota_bytesNumberdisk
disk_cores_quota_used_bytesNumberdisk
disk_installed_images_used_bytesNumberdisk
disk_kvm_quota_bytesNumberdisk
disk_kvm_quota_used_bytesNumberdisk
disk_kvm_zvol_used_bytesNumberdisk
disk_kvm_zvol_volsize_bytesNumberdisk
disk_pool_alloc_bytesNumberdisk
disk_pool_size_bytesNumberdisk
disk_system_used_bytesNumberdisk
disk_zone_quota_bytesNumberdisk
disk_zone_quota_used_bytesNumberdisk
headnodeBooleanWhether server is a headnode
hostnameStringHostname of server if any
kernel_flagsObject
last_bootISODate StringTime of last boot
last_heartbeatstatusTimestamp indicating last-received heartbeat from compute node DEPRECATED
memory_arc_bytesmemory
memory_available_bytesmemory
memory_provisionable_bytesmemory
memory_total_bytesmemory
overprovision_ratiosall
rack_identifierString
ramNumberAmount of ram
reservation_ratio
reservedBoolean
reservoirBoolean
scoreStringall
serialString
setting_upBooleanWhether server is in the process of setting up
setupBooleanWhether server has been marked as set up
statusStringEither 'running' or 'unknown' based on how recently CNAPI has heard from server
sysinfoObjectsysinfoThe last given sysinfo payload for server
traitsObject
transitional_statusStringThis field is an implementation detail and should not be used in any way by CNAPI clients. It is exposed only for debugging. It is optional and may be: a string (currently only 'rebooting'), an empty string, or undefined
unreserved_cpuall
unreserved_diskall
unreserved_ramall
uuidStringThe server's unique identifier
vmsObjectvmsAn object representing all the vms on server

Note that the ServerList API will only return a subset of these server properties - use the extras parameter to include more/all of the fields as necessary.

Waitlist

Certain actions on datacenter resources require serialization of execution to prevent undesireable or undefined results. Such actions include – but are not limited to – DAPI allocation, VM lifecycle requests (creation, start, stop, reboot, destroy), and dataset import. Waitlist should be used on any workflow job where it is possible that concurrent jobs may interfere with each other if actions on the compute node are not deconflicted by a system such as this.

Jobs should be grouped by the combination of [server_uuid, scope, id] and serialized such that a server will only be executing one job per combination at a time. In this way it would be possible to enforce that only one job be active on a particular vm on a server, but would still allow jobs to be run against another vm. Any jobs that come in after one is active will be queued and dispatched as preceding jobs finish.

This system allows for concurrent jobs where the scoping has been set such that two jobs will not interfere with each other. For instance, two reboot jobs for two different vms may be run at the same time, however, two reboots for the same vm will happen in sequential order.

Use of waitlist does not happen implicitly in workflow jobs. It is up to the workflow job to create a ticket and wait for it to become active. As such, it is possible to not use the waitlist at all. However, one then runs the risk of concurrent jobs trampling each other.

Waitlist tickets are serialized and dispatched one by one according to their server_uuid, scope and id parameters.

The first step to using the waitlist is to determine the scope and subject (ie the resource on which the action will be performed). For example this may be something like 'vm', 'dataset', etc. This means that the action will be performed on a resource identified by id of the type given by scope.

The basic process is as follows: a job starts and it first acquires a ticket from CNAPI for that particular server and passes in a scope and an id.

Because waitlist tickets are serviced in creation order, once a ticket has been created the next step is to wait for it to become active. Tickets become active once all extant tickets for that server/scope/id are finished or expired.

To find out whether a ticket has become 'active' (i.e. indicating the job may proceed and do its work), the job may poll the ticket values, or use the blocking wait endpoint for that ticket.

Once the work has been completed, it is up to the job to "release" the ticket, so that subsequent tickets for that scope/id combination can be serviced.

Acquiring a ticket before performing work is an explicit step (as opposed to CNAPI doing the serialization internally) in effort to add transparency and to know what is happening with the SDC pipeline from just looking at the top-level workflow for some work to be performed.

Request (create) a ticket

Using the waitlist begins with requesting a ticket. POST to the CreateWaitlistTicket endpoint. Specify the scope and unique id. An expiry date must also be specified. Endpoint returns a ticket uuid.

-bash-4.1# sdc-cnapi /servers/$(sysinfo | json UUID)/tickets -X POST -d '{ "scope": "vm", "id": "nuts", "expires_at": "2015-10-10T00:00:00"}'
HTTP/1.1 202 Accepted
Content-Type: application/json
Content-Length: 47
Date: Fri, 27 Jun 2014 19:36:47 GMT
Server: Compute Node API
x-request-id: 60c72290-fe32-11e3-913f-b11ed03e831d
x-response-time: 49
x-server-name: 9d2c3229-1e92-4c3f-98fd-5a7ac5fb28ed
Connection: keep-alive

{
  "uuid": "ec8d5ef3-24b6-4582-ade8-c9e9bfb70906"
}

Display all tickets

-bash-4.1# sdc-cnapi /servers/$(sysinfo | json UUID)/tickets
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 260
Date: Fri, 27 Jun 2014 19:37:12 GMT
Server: Compute Node API
x-request-id: 6fcc80a0-fe32-11e3-913f-b11ed03e831d
x-response-time: 14
x-server-name: 9d2c3229-1e92-4c3f-98fd-5a7ac5fb28ed
Connection: keep-alive

[
  {
    "uuid": "ec8d5ef3-24b6-4582-ade8-c9e9bfb70906",
    "server_uuid": "564d6e71-b375-4b81-07ec-ad77fe5fa680",
    "scope": "vm",
    "id": "nuts",
    "expires_at": "2015-10-10T00:00:00",
    "created_at": "2014-06-27T19:36:47.708Z",
    "updated_at": "2014-06-27T19:36:47.708Z",
    "status": "active"
  }
]

By default this endpoint will return 1000 tickets, sorted by creation time. This endpoint supports the use of limit and offset parameters to allow one to page through the results, with the caveat that the use of paging via limit and offset does not guarantee that duplicates will not be seen.

Additionally, if attribute is passed in, overriding the value on which to sort (creation time), it is possible that existing tickets may be missed from the results list if tickets are deleted.

Wait on a ticket

-bash-4.1# sdc-cnapi /tickets/bb5038c2-7498-4e07-b919-df072c76d2dc/wait
<returns when ticket is released or expires>

Release a ticket

Releasing a ticket allows subsequent tickets (if any) queued on that server/scope/id to become active.

-bash-4.1# sdc-cnapi /tickets/bb5038c2-7498-4e07-b919-df072c76d2dc/release -X PUT
HTTP/1.1 204 No Content
Date: Fri, 27 Jun 2014 19:42:46 GMT
Server: Compute Node API
x-request-id: 3678cb00-fe33-11e3-913f-b11ed03e831d
x-response-time: 19
x-server-name: 9d2c3229-1e92-4c3f-98fd-5a7ac5fb28ed
Connection: keep-alive

Delete a ticket

Explicitly deletes a waitlist ticket. This will allow the next ticket in line for the given scope/id to proceed. The next ticket waiting on the same scope/id will be allowed to proceed.

-bash-4.1# sdc-cnapi /tickets/ec8d5ef3-24b6-4582-ade8-c9e9bfb70906 -X DELETE
HTTP/1.1 204 No Content
Date: Fri, 27 Jun 2014 19:41:14 GMT
Server: Compute Node API
x-request-id: ff8dcd70-fe32-11e3-913f-b11ed03e831d
x-response-time: 14
x-server-name: 9d2c3229-1e92-4c3f-98fd-5a7ac5fb28ed
Connection: keep-alive

Allocation API

SelectServer (POST /allocate)

Given the provided constraints, returns a server chosen to allocate a new VM, as well as the steps taken to reach that decision. This does not cause the VM to actually be created (see VmCreate for that), but rather returns the UUID of an eligible server.

See DAPI docs for more details on how the vm, package, image and nic_tags parameters must be constructed.

Be aware when inpecting steps output that the servers which are considered for allocation must be both setup and unreserved. If a server you expected does not turn up in steps output, its because the server didn't meet those two criteria.

Inputs

ParamTypeDescription
vmObjectVarious required metadata for VM construction
packageObjectDescription of dimensions used to construct VM
imageObjectDescription of image used to construct VM
nic_tagsArrayNames of nic tags which servers must have
serversArrayOptionally limit which servers to consider by providing their UUIDs

Responses

CodeTypeDescription
200ObjectServer selected and steps taken
409ObjectNo server found, and steps and reasons why not
500ErrorCould not process request

ServerCapacity (POST /capacity)

Returns how much spare capacity there is on each server, specifically RAM (in MiB), CPU (in percentage of CPU, where 100 = 1 core), and disk (in MiB).

This call isn't cheap, so it's preferable to make fewer calls, and restrict the results to only the servers you're interested in by passing in the desired servers' UUIDs.

Inputs

ParamTypeDescription
serversArrayOptionally limit which servers to consider by providing their UUIDs

Responses

CodeTypeDescription
200ObjectServer capacities and any associated errors
500ErrorCould not process request

Boot Parameters API

BootParamsGetDefault (GET /boot/default)

Returns the default boot parameters.

Inputs

None.

Responses

CodeTypeDescription
200ObjectDefault boot parameters and kernel_args
404NoneNo such Server

BootParamsSetDefault (PUT /boot/default)

Set the default boot parameters.

Completely override the existing boot parameter values with the given payload. Any values not present in the payload will effectively be deleted.

Inputs

ParamTypeDescription
platformStringThe platform image to use on next boot
kernel_argsObjectKey value pairs to be sent to server on boot
boot_modulesArrayList of boot module objects
kernel_flagsObjectKernel flags to be sent to server on boot
serialObjectSerial device to use (i.e. "ttyb")
default_consoleObjectDefault console type (i.e. "serial")

Responses

CodeTypeDescription
204NoneBoot parameters successfully set.
404NoneNo such Server

BootParamsUpdateDefault (POST /boot/default)

Modify the default boot parameters.

If a value is present in the default boot parameters, but no new value is passed in, the currently effective value will remain unchanged.

Inputs

ParamTypeDescription
kernel_argsObjectBoot parms to update
boot_modulesArrayList of boot module objects
kernel_flagsObjectKernel flags to update
platformStringSet platform as the bootable platform

Responses

CodeTypeDescription
204NoneBoot parameters successfully set
404NoneNo such Server

BootParamsGet (GET /boot/:server_uuid)

Returns the boot parameters for a particular server.

Returns the platform to be booted on the next reboot in addition to what kernel parameters will be used to boot the server.

Inputs

None.

Responses

CodeTypeDescription
200ObjectDefault boot parameters and kernel_args
404NoneNo such Server

BootParamsSet (PUT /boot/:server_uuid)

Set the boot parameters of a server.

Completely overrides the platform and boot parameters of a server. If a value is not set in the new object but is in the old one, it will be effectively deleted when the new object replaces the old.

Inputs

ParamTypeDescription
kernel_argsObjectBoot parms to update
boot_modulesArrayList of boot module objects
kernel_valuesObjectKernel flags to update
platformStringSet platform as the bootable platform
serialObjectSerial device to use (i.e. "ttyb")
default_consoleObjectDefault console type (i.e. "serial")

Responses

CodeTypeDescription
202NoneNo content
404NoneNo such Server

BootParamsUpdate (POST /boot/:server_uuid)

Update only the given boot configuration values.

Does not overwrite any values which are not given.

Inputs

ParamTypeDescription
kernel_argsObjectBoot parms to update
kernel_flagsObjectHash containing flag key/value pairs
boot_modulesArrayList of boot module objects
platformStringSet platform as the bootable platform

Responses

CodeTypeDescription
202NoneNo content

Compute Node Agent Tasks API

TaskGet (GET /tasks/:task_id)

Returns the details of the given task.

Inputs

None.

Responses

CodeTypeDescription
200ObjectTask details
404NoneNo such task found

TaskWait (GET /tasks/:task_id/wait)

Waits for a given task to return or an expiry to be reached.

Inputs

None.

Responses

CodeTypeDescription
200ObjectTask details
404NoneNo such task found

Miscellaneous API

ImageGet (GET /servers/:server_uuid/images/:uuid)

Query the server for the Image's details.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id

Responses

CodeTypeDescription
200ObjectRequest succeeded
404ObjectNo such Image
404ObjectNo such server

Ping (GET /ping)

Return CNAPI's service status details.

Inputs

None.

Responses

CodeTypeDescription
200ObjectStatus details.

NicUpdate (PUT /servers/:server_uuid/nics)

Modify the target server's nics.

The only parameter of the server's nics that can be changed is nic_tags_provided. This parameter can be changed depending on the following values for the action parameter:

  • update: Add nic tags to the target nics
  • replace: Replace the nic tags (ie: completely overwrite the list) for the target nics
  • delete: Remove the nic tags from the target nics

For examples, see the Updating Nics section above.

As per the Updating Nics section above, the nics parameter must be an array of objects. Those objects must have both the mac and nic_tags_provided properties.

Inputs

ParamTypeDescription
actionStringNic action: 'update', 'replace' or 'delete'.
nicsObjectArray of nic objects.

Responses

CodeTypeDescription
202NoneWorkflow was created to modify nics
404ErrorNo such server

PlatformList (GET /platforms)

Returns available platform images in datacenter.

Inputs

ParamTypeDescription
osBooleanInclude or not the operating system into the list of platform images.

Responses

CodeTypeDescription
200ObjectCollection of platforms. See below.
$ sdc-cnapi /platforms|json -H
{
  "20190523T221915Z": {},
  "20190613T185529Z": {},
  "20190710T121115Z": {},
  "20191218T190857Z": {},
  "20200220T122949Z": {
    "latest": true
  }
}

$ sdc-cnapi /platforms?os=false|json -H
{
  "20190523T221915Z": {},
  "20190613T185529Z": {},
  "20190710T121115Z": {},
  "20191218T190857Z": {},
  "20200220T122949Z": {
    "latest": true
  }
}

$ sdc-cnapi /platforms?os=true|json -H
{
  "20190523T221915Z": {
    "os": "smartos"
  },
  "20190613T185529Z": {
    "os": "smartos"
  },
  "20190710T121115Z": {
    "os": "smartos"
  },
  "20191218T190857Z": {
    "os": "smartos"
  },
  "20200220T122949Z": {
    "os": "smartos",
    "latest": true
  }
}

Remote Execution API (deprecated)

CommandExecute (deprecated) (POST /servers/:server_uuid/execute)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. It exists only for backward compatibility and should not be used for any new development. If you wish to execute commands on a CN, this should be done through a new cn-agent task, or a new agent.

Synchronously execute a command on the target server.

If json is true, the result returned will be a JSON object with stdout, stderr and exitCode properties. If the json flag is not passed or not set true, the body of the response will contain only the stdout and if the script executed non-zero a 500 error will be returned.

Inputs

ParamTypeDescription
argsArrayArray containing arguments to be passed in to command
envObjectObject containing environment variables to be passed in
scriptStringScript to be executed. Must have a shebang line
jsonBooleanWhether to return results as JSON instead of just stdout (default = false)
timeoutIntegerNumber of ms to wait for command completion before killing task and returning (only supported when using cn-agent, See: FEATURE_USE_CNAGENT_COMMAND_EXECUTE)

Responses

CodeTypeDescription
404NoneNo such server
500NoneError occurred executing script

Server API

ServerList (GET /servers)

Returns Servers present in datacenter.

Inputs

ParamTypeDescription
uuidsStringComma seperated list of UUIDs to look up
setupBooleanReturn only setup servers
headnodeBooleanReturn only headnodes
reservedBooleanReturn only reserved servers
reservoirBooleanReturn only reservoir servers
hostnameStringReturn machine with given hostname
extrasStringComma separated values: agents, vms, memory, disk, sysinfo, capacity, all
fieldsStringComma separated property names that should be returned. E.g. 'uuid,status,headnode'. See Server Properties for the list of possible property names.
limitIntegerMaximum number of results to return. It must be between 1-1000, inclusive. Defaults to 1000 (the maxmimum allowed value).
offsetIntegerOffset the subset of results returned

Responses

CodeTypeDescription
200ArrayThe returned servers

ServerGet (GET /servers/:server_uuid)

Look up a single Server by UUID.

Inputs

None.

Responses

CodeTypeDescription
200ObjectThe server object

ServerUpdate (POST /servers/:server_uuid)

Set the value of a Server's attribute.

Inputs

ParamTypeDescription
agentsArrayArray of agents present on this server
boot_platformStringThe platform image to be used on next boot
default_consoleStringConsole type
etag_retriesNumbernumber of times to retry update in case of ETag conflict
rack_identifierStringThe id of the server's rack
commentsStringAny comments about the server
next_rebootStringISO timestamp when next reboot is scheduled for
nicsArrayList of NICs to update (see Updating NICs section)
reservedBooleanServer is available for provisioning
reservoirBooleanServer should be considered last for provisioning
reservation_ratioNumberThe reservation ratio
overprovision_ratiosObjectThe overprovisioning ratios. Must be an object with Number value keys and keys must be one of 'cpu', 'ram', 'disk', 'io', 'net'.
serialStringSerial device
setupBooleanTrue if server has been set up
setting_upBooleanTrue if server is in the process of setting up
transitional_statusStringA value to use to override status when the server has status 'unknown'. This is for internal use only and currently is only used by server-reboot to set the state to 'rebooting' while a server is rebooting.
traitsObjectServer traits

Responses

CodeTypeDescription
204NoneThe value was set successfuly

ServerReboot (POST /servers/:server_uuid/reboot)

Reboot the server.

Inputs

ParamTypeDescription
originString
creator_uuidString
drainBooleanWait for server's cn-agent to be drained before sending the reboot command
nojobBooleanIf true, don't create a workflow job, but instead talk to the server_reboot task in cn-agent (default: false)

Responses

CodeTypeDescription
202ObjectServer reboot initiated (object with job_uuid is returned)
204NoneServer reboot initiated
500NoneError attempting to set up server
503NoneWhen nojob=true, this means the server does not support the server_reboot cn-agent task

ServerFactoryReset (PUT /servers/:server_uuid/factory-reset)

Reset the server back to a factory state.

Inputs

None.

Responses

CodeTypeDescription
204ObjectSetup initated, returns object containing workflow id
500NoneError attempting to set up server

ServerSetup (PUT /servers/:server_uuid/setup)

Initiate the server setup process for a newly started server.

Inputs

ParamTypeDescription
nicsObjectNic parameters to update
postsetup_scriptStringScript to run after setup has completed
hostnameStringHostname to set for the specified server
disk_sparesStringSee man disklayout spares
disk_widthStringSee man disklayout width
disk_cacheStringSee man disklayout cache
disk_excludeStringSee man disklayout -e option
disk_layoutStringSee man disklayout type (single, mirror, raidz1, ...)
encryption_enabledStringSee man mkzpool -e

Responses

CodeTypeDescription
200ObjectSetup initated, returns object containing workflow id
500NoneError while processing request

ServerSysinfoRegister (POST /servers/:server_uuid/sysinfo)

Register a given server's sysinfo values and store them in the server object. Does the same thing as CNAPI receiving a sysinfo message via Ur. This means that if you post sysinfo for a non-existent server, a server record will be created.

IMPORTANT: This endpoint is only intended to be used by cn-agent. Any other use will not be supported and may break in the future.

Inputs

ParamTypeDescription
sysinfoObjectSysinfo Object.

Responses

CodeTypeDescription
200NoneSysinfo registration initiated
500NoneError while processing request

ServerSysinfoRefresh (deprecated) (POST /servers/:server_uuid/sysinfo-refresh)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. It exists only for backward compatibility and should not be used for any new development. As of version 2.9.0, cn-agent will keep the sysinfo up-to-date, so there's no need to call this.

Fetch a given server's sysinfo values and store them in the server object.

Inputs

None.

Responses

CodeTypeDescription
200ObjectSysinfo refresh initiated
500NoneError while processing request

ServerDelete (DELETE /servers/:server_uuid)

Remove all references to given server. Does not change anything on the actual server.

Inputs

None.

Responses

CodeTypeDescription
204NoneServer was deleted successfully
500ErrorCould not process request

ServerTaskHistory (GET /servers/:server_uuid/task-history)

Return details of most recent cn-agent tasks run on the compute node since cn-agent was started.

Inputs

None.

Responses

CodeTypeDescription
200OkTasks returned successfully
500ErrorCould not process request

ServerPauseCnAgent (GET /servers/:server_uuid/cn-agent/pause)

Makes cn-agent stop accepting new tasks

Inputs

None.

Responses

CodeTypeDescription
204NoContent on success
500ErrorCould not process request

ServerResumeCnAgent (GET /servers/:server_uuid/cn-agent/resume)

Makes cn-agent accept new tasks

Note this is the default behavior and this end-point is useful only after a previous call to ServerPauseCnAgent

Inputs

None.

Responses

CodeTypeDescription
204NoContent on success
500ErrorCould not process request

ServerEnsureImage (GET /servers/:server_uuid/ensure-image)

Assert an image is present on a compute node and ready for use in provisioning. If this is not the case, fetch and install the image onto the compute node zpool.

Inputs

ParamTypeDescription
image_uuidStringUUID of image to install
zfs_storage_pool_nameStringzpool on which to install image

Responses

CodeTypeDescription
204NoneTasks returned successfully
500ErrorCould not process request

ServerInstallAgent (POST /servers/:server_uuid/install-agent)

Instruct server to install given agent. Pass in image uuid of package to install and server will download and install package.

Inputs

ParamTypeDescription
image_uuidStringUUID of image to install
package_nameStringPackage name
package_fileStringPackage file

Responses

CodeTypeDescription
200OkInstall task initiated successfully
500ErrorCould not process request

ServerUninstallAgents (POST /servers/:server_uuid/uninstall-agents)

Uninstall the given agents on the server. (Requires cn-agent v2.8.0 or later.)

Inputs

ParamTypeDescription
agentsArrayThe names of the agents to uninstall. Passing "cn-agent" as an agent to remove results in undefined (and likely destructive) behaviour.

Responses

CodeTypeDescription
200OkUninstall task created successfully
412ErrorPreconditionFailed if the target server has a cn-agent that is too old.
500ErrorCould not process request

ServerRecoveryConfig (POST /servers/:server_uuid/recovery-config)

Stage/Activate the given Recovery Configuration on the server, only if the server is using EDAR (Zpool Encrypted: true).

Requires cn-agent v2.13.0 or later

Inputs

ParamTypeDescription
recovery_uuidStringUUID of the recovery configuration to stage or activate.
actionStringname of the action to execute: "stage" or "activate". Cannot "activate" a recovery configuration not already reported by the Server's sysinfo as staged through the Zpool Recovery sysinfo property.
templateStringpivy-box recovery configuration template to be staged into the CN.
tokenStringthe recovery token to stage with the recovery configuration.
pivtokenStringGUID of the PIVToken the recovery token is associated with.

Responses

CodeTypeDescription
200OkTask initiated successfully
500ErrorCould not process request

Virtual Machine API

VmList (GET /servers/:server_uuid/vms)

(DEPRECATED: use VMAPI instead)

Query the server for a list of VMs.

Inputs

None.

Responses

CodeTypeDescription
204ArrayList of VMs
404ObjectNo such server

VmLoad (GET /servers/:server_uuid/vms/:uuid)

Query the server for the VM's details.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id
include_dniBooleanAllow a VM with the do_not_inventory flag set

Responses

CodeTypeDescription
204ObjectTask was sent to server
404ObjectNo such VM
404ObjectNo such server

VmInfo (GET /servers/:server_uuid/vms/:uuid/info)

Query the server for the VM's vmadm info output.

Inputs

None.

Responses

CodeTypeDescription
200ObjectRequest succeeded
404ObjectNo such VM
404ObjectNo such server

VmInfo (GET /servers/:server_uuid/vms/:uuid/vnc)

Query the server for the VM's VNC host and port.

Inputs

None.

Responses

CodeTypeDescription
200ObjectRequest succeeded
404ObjectNo such VM
404ObjectNo such server

VmUpdate (POST /servers/:server_uuid/vms/:uuid/update)

Modify the system parameters of the VM identified by :uuid on server with UUID :server_uuid.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server

VmNicsUpdate (POST /servers/:server_uuid/vms/nics/update)

Bulk modify VM nics

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id

Responses

CodeTypeDescription
204NoneTask was sent to server
400ErrorTask not supported on server
404ErrorNo such server

VmStart (POST /servers/:server_uuid/vms/:uuid/start)

Boot up a vm which is in the 'stopped' state.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server

VmStop (POST /servers/:server_uuid/vms/:uuid/stop)

Shut down a VM which is in the 'running' state.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmKill (POST /servers/:server_uuid/vms/:uuid/kill)

Send a signal to a given VM.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id
signalStringOptional: Signal to send to init process of VM

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmReboot (POST /servers/:server_uuid/vms/:uuid/reboot)

Reboot a VM which is in the 'running' state.

Inputs

ParamTypeDescription
jobidStringPost information to workflow with this id

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmCreate (POST /servers/:server_uuid/vms)

Create a VM on the specified server.

Inputs

ParamTypeDescription
jobidStringCreate a new virtual machine on the given server

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmReprovision (POST /servers/:server_uuid/vms/:uuid/reprovision)

Reprovision a given VM.

Inputs

ParamTypeDescription
jobidStringCreate a new virtual machine on the given server
image_uuidStringReprovision using the new image_uuid

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmDestroy (DELETE /servers/:server_uuid/vms/:uuid)

Delete the specified VM.

Inputs

None.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmDockerExec (POST /servers/:server_uuid/vms/:uuid/docker-exec)

Send a docker_exec task to the given server/vm. This starts a server on the given server which will spawn a process with the given docker payload.

Inputs

ParamTypeDescription
addressStringip:port where the stdio server will be listening
hostStringhost where the stdio server will be listening
portNumberport on host the stdio server will be listening

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmDockerCopy (POST /servers/:server_uuid/vms/:uuid/docker-copy)

Send a docker_copy task to the given server/vm. This starts a temporary service on the given server which will stream the the requested file.

Inputs

ParamTypeDescription
addressStringip:port where the stdio server will be listening
hostStringhost where the stdio server will be listening
portNumberport on host the stdio server will be listening

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmDockerStats (POST /servers/:server_uuid/vms/:uuid/docker-stats)

Send a docker_stats task to the given server/vm. This starts a temporary service on the given server which will stream back the container stats.

Inputs

ParamTypeDescription
addressStringip:port where the stdio server will be listening
hostStringhost where the stdio server will be listening
portNumberport on host the stdio server will be listening

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such VM
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmDockerBuild (POST /servers/:server_uuid/vms/:uuid/docker-build)

Send a docker_build task to the given server/vm. This starts a temporary service on the given server which will allow streaming of the build context to the server and then runs the docker build steps.

Inputs

None.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmMigrate (POST /servers/:server_uuid/vms/:uuid/migrate)

Start migrating the instance to a new server.

Inputs

None.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

Virtual Machine Images API

VmImagesCreate (POST /servers/:server_uuid/vms/:uuid/images)

Create a VM image.

Inputs

ParamTypeDescription
jobidStringCreate a new virtual machine on the given server
compressionStringCompression to use for creating image
imgapi_urlStringLocation of imgapi
incrementalBooleanMake this an incremental image? Optional. Default is false.
prepare_image_scriptStringA script run in a reboot of the VM to prepare it for imaging.
manifestObjectImage manifest object. Require at least "uuid", "owner", "name" and "version" keys. See "imgadm create" documentation for other required and optional fields.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

Virtual Machine Snapshots API

VmSnapshotCreate (PUT /servers/:server_uuid/vms/:uuid/snapshots)

Task a snapshot of a VM.

Inputs

None.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmSnapshotRollback (PUT /servers/:server_uuid/vms/:uuid/snapshots/:snapshot_name/rollback)

Roll back to a previous snapshot of a VM.

Inputs

None.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

VmSnapshotDestroy (DELETE /servers/:server_uuid/vms/:uuid/snapshots/:snapshot_name)

Delete a VM's snapshot.

Inputs

None.

Responses

CodeTypeDescription
204NoneTask was sent to server
404ErrorNo such server
500ErrorError encountered while attempting to fulfill request

Waitlist API

ServerWaitlistList (GET /servers/:server_uuid/tickets)

Returns all waitlist tickets currently active on a server. Returns the uuid of the newly created ticket as well as an array of all the tickets in the ticket's scope queue. By default servers are returned in the chronological order of their creation (created_at timestamp). By default the responses are limited to 1000 results. Use the limit and offset to page through results.

Inputs

ParamTypeDescription
limitNumberReturn at most this many results
offsetNumberReturn results starting at this position
attribhuteStringAttribute to sort on
orderStringSort in 'DESC' or 'ASC' order

Responses

CodeTypeDescription
200ArrayWaitlist returned successfully
500ErrorCould not process request

ServerWaitlistTicketCreate (POST /servers/:server_uuid/tickets)

Create a new waitlist ticket.

Inputs

ParamTypeDescription
scopeStringLimit the ticket to the given scope
idStringThe id of the resource of type 'scope'
expires_atStringISO 8601 date string when ticket will expire
actionStringDescription of acting to be undertaken
extraObjectObject containing client specific metadata

Responses

CodeTypeDescription
202ArrayWaitlist ticket created successfully
500ErrorCould not process request

ServerWaitlistGetTicket (POST /tickets/:ticket_uuid)

Retrieve a waitlist ticket.

Inputs

None.

Responses

CodeTypeDescription
200ArrayWaitlist ticket returned successfully
500ErrorCould not process request

ServerWaitlistDeleteTicket (DELETE /tickets/:ticket_uuid)

Delete a waitlist ticket.

Inputs

None.

Responses

CodeTypeDescription
204ArrayWaitlist ticket deleted successfully
500ErrorCould not process request

ServerWaitlistTicketsDeleteAll (DELETE /servers/:server_uuid/tickets)

Delete all of a server's waitlist tickets.

Inputs

ParamTypeDescription
forceBooleanMust be set to 'true' for delete to succeed

Responses

CodeTypeDescription
204ArrayWaitlist ticket deleted successfully
500ErrorCould not process request

ServerWaitlistTicketsWait (GET /tickets/:ticket_uuid/wait)

Wait until a waitlist ticket either expires or becomes active.

Inputs

None.

Responses

CodeTypeDescription
204ArrayTicket active or expired
500ErrorCould not process request

ServerWaitlistTicketsRelease (GET /tickets/:ticket_uuid/release)

Release a currently active or queued waitlist ticket.

Inputs

None.

Responses

CodeTypeDescription
204ArrayTicket released successfully
500ErrorCould not process request

ZFS API (deprecated)

DatasetsList (GET /servers/:server_uuid/datasets)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

List ZFS datasets on a server.

Inputs

None.

Responses

CodeTypeDescription
200ArrayArray of objects, one per dataset on server

DatasetCreate (POST /servers/:server_uuid/datasets)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Create a ZFS dataset on a server.

Inputs

None.

Responses

CodeTypeDescription
204NoneDataset successfully created

SnapshotCreate (POST /servers/:server_uuid/datasets/:dataset/snapshot)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Create a ZFS snapshot of a dataset on a server.

Inputs

ParamTypeDescription
nameStringThe name of the snapshot to create

Responses

CodeTypeDescription
204NoneSnapshot successfully created

SnapshotRollback (POST /servers/:server_uuid/datasets/:dataset/rollback)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Revert a ZFS dataset to back to a previous state captured by a snapshot.

Inputs

ParamTypeDescription
nameStringThe name of the snapshot to be created

Responses

CodeTypeDescription
204NoneSnapshot successfully rolled back

SnapshotList (GET /servers/:server_uuid/datasets/:dataset/snapshots)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

List all snapshots on a dataset

Inputs

None.

Responses

CodeTypeDescription
200ArrayArray of snapshot objects

DatasetPropertiesGetAll (GET /servers/:server_uuid/dataset-properties)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Get ZFS properties across all datasets on a server.

Inputs

ParamTypeDescription
StringGet the property given by the "prop1" value
StringGet the property given by the "prop2" value
StringGet the property given by the "propN" value

Responses

CodeTypeDescription
200Objectlist of property details

DatasetPropertiesGet (GET /servers/:server_uuid/datasets/:dataset/properties)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Get ZFS properties for a dataset. The specific properties to return can be filtered with ?prop1=foo&prop2=bar, etc.

Inputs

ParamTypeDescription
StringGet the property given by the "prop1" value
StringGet the property given by the "prop2" value
StringGet the property given by the "propN" value

Responses

CodeTypeDescription
200ArrayList of dataset property details

DatasetPropertiesSet (POST /servers/:server_uuid/datasets/:dataset/properties)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Set one or more properties for a ZFS dataset.

Inputs

ParamTypeDescription
propertiesObjectObject containing string property values

Responses

CodeTypeDescription
204NoneProperties were set successfully

DatasetDestroy (DELETE /servers/:server_uuid/datasets/:dataset)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

Destroy a ZFS dataset on a server.

Inputs

None.

Responses

CodeTypeDescription
204NoneDataset successfully deleted

ZpoolList (GET /servers/:server_uuid/zpools)

IMPORTANT: This endpoint is deprecated and will be removed in a future release. Do not use.

List the ZFS pools on a server.

Inputs

None.

Responses

CodeTypeDescription
200ArrayList of zpool detail objects