FORMAT: 1A HOST: http://nanos.cloud/api/v1 # FrontEnd API (Project Nano) RESTful API provided by FrontEnd module, listen at port 5870 by default. This document corresponds to version 1.3.1 Verify and allocate a new session before call functions, set session ID in header 'Nano-Session' for authentication. # Data Structures ## GuestConfig (object) + name (string) - guest name + owner (string) - user id + group (string) - user group + pool (string) - compute pool name + cores (number) - number of cpu cores + memory (number) - memory size in bytes + disks (array[number],fixed-type) - [system\_disk\_size, data\_disk\_n\_size...], size in bytes + auto_start (boolean) - auto start instance + system (string, optional) - system type, "linux", "windows", etc + network_address (string, optional) - optional specified ip address + ethernet_address (string, optional) - optional specified mac address + from_image (string, optional) - ID of source disk image when cloning + ports (array[number], optional) - nat ports + template (string) - id of system template + modules (array[string], optional) - installed guest module, "qemu"/"cloud-init" + cloud_init (CloudInit, optional) - cloud-init params + qos (QoS, optional) - qos config + security\_policy\_group(string, optional) - id of security group ## InterfaceStatus (object) + network_address (string) - network address of interface, IPv4 dot format: '172.10.6.8' + display_address (string) - monitor address of guest, 'host:port' + allocated_address (string,optional) - interface address allocated by system when attached with address pool ## InstanceData (GuestConfig) + id (string) - guest ID + created (boolean) - is instance created + running (boolean) - is instance running + cell(string,optional) - name of hosting cell + host(string,optional) - IP/domain of hosting server + lost(boolean,optional) - is instance lost + system(string,optional) - id of system + monitor_secret(string,optional) - monitor password + display_protocol(string,optional) - name of monitor protocol + total_disk (number) - total disk size in bytes + progress (number, optional) - creating progress, range from 0 to 100 + create_time (string, optional) - created time in format 'YYYY-MM-DD HH:MI:SS' + internal (InterfaceStatus,optional) - status of internal network interface + external (InterfaceStatus,optional) - status of external network interface ## InstanceStatus (InstanceData) + cpu_usage (number) - total CPU usage range from 0.00 to 100.00 + memory_available(number) - available memory size in bytes + disk_available(number) - available disk size in bytes + bytes_read (number) - total read disk bytes + bytes_written (number) - total written disk bytes + bytes_received (number) - total received network bytes + bytes_sent (number) - total sent network bytes + media_attached (boolean,optional) - is media image attached + media_source (string,optional) - id of attached media image ## QoS (object) + cpu_priority (enum[string], optional) - CPU priority + Default: `medium` + Members + `high` + `medium` + `low` + write_speed: 10485760 (number, optional) - disk write bps limit, 0 = unlimited + write_iops: 100 (number, optional) - disk write iops limit, 0 = unlimited + read_speed: 10485760 (number, optional) - disk read bps limit, 0 = unlimited + read_iops: 100 (number, optional) - disk read iops limit, 0 = unlimited + receive_speed: 10485760 (number, optional) - network receive bps, 0 = unlimited + send_speed: 10485760 (number, optional) - network send bps, 0 = unlimited ## CloudInit (object) + root_enabled: true (boolean, optional) - allow root user login via SSH, enable in default + admin_name: `nano` (string, optional) - specify admin name, using `root` when omitted + admin_secret (string, optional) - password in plain text, nano generate a new one when omitted + data_path (string, optional) - data disk mount path, `/opt/data` in default ## ComputePoolConfig (object) + storage(string,optional) - name of storage pool, using local storage when omit + network(string,optional) - name of address pool, using bridge mode by default when omit + failover(boolean) - enable failover on shared storage ## ComputePoolStatus (ComputePoolConfig) + name(string) - pool name + enabled(boolean) - is pool enabled + cells(number) - count of attached cells in the pool ## StoragePoolConfig (object) + type (enum[string]) - backend storage type + Default: `nfs` + Members + `nfs` - NFS storage + host (string, optional) - IP or hostname of target host + target (string, optional) - path of target host ## CellStorage (object) + mode (enum[string]) - cell storage mode + Default: `local` + Members + `local` + `nfs` + `ceph` + system(array[string],optional) - disk path for storage system disk of guests, available for local mode + data(array[string],optional) - disk path for storage data disk of guests, available for local mode ## StoragePoolStatus (StoragePoolConfig) + name(string) - name of storage pool ## AllocatedAddress (object) + address (string) - allocated address + instance (string) - id of allocated instance + type (enum[string], optional) - address type + Default: `internal` + Members + `internal` + `external` ## AddressRange (object) + start (string) - start of address range + end (string) - end of address range + netmask (string) - netmask of address range + type (enum[string], optional) - address type + Default: `internal` + Members + `internal` + `external` ## AddressPoolConfigure (object) + name(string) - pool name + gateway (string) - gateway address + provider (enum[string],optional) - provider method + Default: `dhcp` + Members + `dhcp` - using DHCP to provide instance address + `cloudinit` - using Cloud-Init to provide instance address + mode (enum[string],optional) - network interface mode + Default: `internal` + Members + `internal` - create an internal interface + `external` - create an external interface + `both` - create both an internal interface and an external interface ## AddressPoolStatus (AddressPoolConfigure) + ranges (array[AddressRange], optional) - list of address range + allocated (array[AllocatedAddress], optional) - list of allocated address ## AddressPoolSummary (AddressPoolConfigure) + addresses (number) - address count + allocated (number) - allocated count ## StatisticData (object) + name(string) - source name + cpu_usage(number) - used cores in total + max_cpu(number) - total number of cores + available_memory(number) - total usable memory in bytes + max_memory(number) - all memory in bytes + available_disk(number) - total usable disk in bytes + max_disk(number) - all disk in bytes + read_speed(number) - disk read speed in bytes per second + write_speed(number) - disk write speed in bytes per second + receive_speed(number) - network receive speed in bytes per second + send_speed(number) - network send speed in bytes per second ## ZoneStatistic (StatisticData) + pools(array[number],fixed-type) - [disabledPools, enabledPools] + cells(array[number],fixed-type) - [offlineCells, onlineCells] + instances(array[number],fixed-type) - [stoppedInstances, runningInstances, lostInstances, migratingInstances] + start_time(string) - system start time in 'YYYY-MM-DD HH:MI:SS' format ## PoolStatistic (StatisticData) + enabled(boolean) - is pool enabled + cells(array[number],fixed-type) - [offlineCells, onlineCells] + instances(array[number],fixed-type) - [stoppedInstances, runningInstances, lostInstances, migratingInstances] ## CellStatistic (StatisticData) + address(string) - IP or hostname of cell node + enabled(boolean) - is cell enabled + alive(boolean) - is cell alive ## Visibility (object) + instance_visible: true (boolean) - user can view instances in the same group + media_image_visible: true (boolean) - user can view media images in the same group + disk_image_visible: false (boolean) - user can view disk images in the same group ## TemplateConfigure (object) + name(string) - template name + admin(string) - default administrator name + operating_system(enum[string]) - operating system + Default: `linux` + Members + `linux` + `windows` + disk(enum[string]) - disk driver type + Default: `scsi` + Members + `scsi` + `sata` + `ide` + network(enum[string]) - network model + Default: `virtio` + Members + `virtio` + `e1000` + `rtl8139` + display(enum[string]) - display driver + Default: `vga` + Members + `vga` + `cirrus` + control(enum[string]) - remote control + Default: `vnc` + Members + `vnc` + `spice` + usb(enum[string]) - usb interface model + Default: `` + Members + `` + `nec-xhci` + tablet(enum[string]) - tablet interface model + Default: `` + Members + `` + `usb` ## TemplateStatus (TemplateConfigure) + id (string) - template id + created_time(string) - template created time, format `YYYY-MM-DD HH:MI:SS` + modified_time(string) - template modified time, format `YYYY-MM-DD HH:MI:SS` ## TemplateBrief (object) + id (string) - template id + name(string) - template name + operating_system(enum[string]) - operating system + Default: `linux` + Members + `linux` + `windows` + created_time(string) - template created time, format `YYYY-MM-DD HH:MI:SS` + modified_time(string) - template modified time, format `YYYY-MM-DD HH:MI:SS` ## SecurityPolicyRule (object) + action(enum[string]) - action when rule matched + Default: `accept` + Members + `accept` + `reject` + to_port(number) - destination port + protocol(enum[string]) - match protocol + Default: `all` + Members + `all` + `tcp` + `udp` + `icmp` + from_address(string, optional) - packet source address + interface(number, optional) - index of match interface, 0 for all, 1 for first ## SecurityPolicyGroupConfig (object) + name (string) - group name + description (string,optional) - group description + user(string) - creator id + group(string) - group id of creator + enabled(boolean) - policy group enabled + global(boolean) - global policy group visiable to all users + default_action(enum[string]) - default action when no rule matched + Default: `accept` + Members + `accept` + `reject` ## SecurityPolicyGroupStatus (SecurityPolicyGroupConfig) + id (string) - group id ## ImageConfigure (object) + name (string) - image name + owner (string) - owner name of image + group (string) - group name of owner + description (string, optional) - image description + tags (array[string], optional) - image tags ## ImageStatus (ImageConfigure) + id (string, optional) - image id + created (boolean) - image created + progress (number, optional) - progress range from 0 to 100 + create_time (string, optional) - created time, format YYYY-MM-DD HH:MI:SS + modify_time (string, optional) - modified time, format YYYY-MM-DD HH:MI:SS + size (number, optional) - image size in bytes ## DiskImage (ImageConfigure) + guest (string) - source guest id # Group Resource Pool APIs for manage resource pools ## Compute Pool [/compute_pools/] Manage compute pools ### Get All Compute Pools [GET] Query all compute pools in current zone + Request Get All Compute Pools + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of compute pools + (ComputePoolStatus) + Body { "error_code": 0, "message": "", "data":[ { "name": "default", "enabled": true, "cells": 10, "storage": "some\_ceph\_cluster", "network": "nat\_address\_pool\_1", "failover": true }, { "name": "fast_instance", "enabled": true, "cells": 12, "storage": "some\_ceph\_cluster", "network": "nat\_address\_pool\_1", "failover": false } ] } ### Get Compute Pool Status [GET /compute_pools/{pool}] Get status of a compute pool + Parameters + pool (string) - name of compute pool + Request Get Compute Pool Status + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(ComputePoolStatus) - status of compute pool + Body { "error_code": 0, "message": "", "data":{ "name": "default", "enabled": true, "cells": 10, "storage": "some_cluster", "network": "address_pool1", "failover": true } } ### Create New Compute Pool [POST /compute_pools/{pool}] Create a new compute pool + Parameters + pool (string) - name of compute pool + Request Create New Compute Pool (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(ComputePoolConfig) + Body [ { "storage": "some_cephcluster", "network": "address_pool1", "failover": true } ] + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Delete Compute Pool [DELETE /compute_pools/{pool}] Delete a compute pool + Parameters + pool (string) - name of compute pool + Request Delete Compute Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Modify Compute Pool [PUT /compute_pools/{pool}] Modify configure of a compute pool + Parameters + pool (string) - name of compute pool + Request Modify Compute Pool (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (ComputePoolConfig) + Body [ { "failover": true, "storage": "nfs-poo1" } ] + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Compute Pool Cell [/compute_pool_cells/] Manage compute cells in a pool ### Query Unallocated Cells [GET] query cells not attached to any pool + Request Query Unallocated Cells + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data": [ { "name": "cell3", "address": "172.16.3.78", "enabled": true, "alive": true, }, { "name": "cell4", "address": "172.16.3.79", "enabled": true, "alive": true, } ] } ] ### Query Cells In Pool [GET /compute_pool_cells/{pool}] Query all cells attached in a pool + Parameters + pool (string) - pool name + Request Query Attached Cells + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data": [ { "name": "cell1", "address": "172.16.4.7", "enabled": true, "alive": true, }, { "name": "cell2", "address": "172.16.7.3", "enabled": true, "alive": true, } ] } ] ### Add Compute Cell [POST /compute_pool_cells/{pool}/{cell}] Add a new cell to the compute pool + Parameters + pool (string) - pool name + cell (string) - cell name + Request Add Compute Cell + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Remove Compute Cell [DELETE /compute_pool_cells/{pool}/{cell}] Remove an attached cell from the compute pool + Parameters + pool (string) - pool name + cell (string) - cell name + Request Remove Compute Cell + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Modify Compute Cell [PUT /compute_pool_cells/{pool}/{cell}] Modify a compute cell + Parameters + pool (string) - pool name + cell (string) - cell name + Request Modify Compute Cell (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + enable(boolean) - enable cell. The disabled cell does not participate in instance allocation + Body { "enable": false } + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Get Cell Status [GET /compute_pool_cells/{pool}/{cell}] Get current status of a compute cell + Parameters + pool (string) - pool name + cell (string) - cell name + Request Get Cell Status + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data": { "name": "cell1", "address": "172.16.4.7", "enabled": true, "alive": true, "storage": [ { "name": "nfspool1", "attached": true }, { "name": "cephpool1", "attached": false, "error": "not support yet" } ] } } ] ## Storage Pool [/storage_pools/] APIs manage the storage pools ### Query Storage Pool [GET] Query configures of all storage pool + Request Query Storage Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data":[ { "name": "nfspool1", "type": "nfs", "host": "nfs.nano.com", "target": "/var/nano/pool1" }, { "name": "cephpool1", "type": "ceph", "host": "ceph.nano.com", "target": "some_pool_in_ceph" } ] } ] ### Get Storage Pool Configure [GET /storage_pools/{pool}] Get the configure of a storage pool + Parameters + pool(string) - name of storage pool + Request Get Storage Pool Configure + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data": { "type": "nfs", "host": "nfs.nano.com", "target": "/var/nano/pool1" } } ] ### Create New Storage Pool [POST /storage_pools/{pool}] Create a new stoarge pool + Parameters + pool(string) - name of storage pool + Request Create Storage Pool (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (StoragePoolConfig) + Body { "type": "nfs", "host": "nfs.nano.com", "target": "/var/nano/pool1" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Modify Storage Pool [PUT /storage_pools/{pool}] Modify stoarge pool, only available on an empty storage pool. + Parameters + pool(string) - name of storage pool + Request Modify Storage Pool (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (StoragePoolConfig) + Body { "type": "nfs", "host": "another_nfs.nano.com", "target": "/var/nano/new_location" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Delete Storage Pool [DELETE /storage_pools/{pool}] Delete a storage pool, only available on an empty storage pool. + Parameters + pool(string) - name of storage pool + Request Delete Storage Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Compute Zone Status [/compute_zone_status/] Collect status and statistic data on compute zone ### Query Zone Status [GET] Query lastest status of a whole zone + Request Query Zone Status + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(ZoneStatistic) - statistic status + Body [ { "error_code": 0, "message": "", "data":{ "name": "default", "pools": [1, 0]//[disabled, enabled] "cells": [0, 25], //[offline, online] "instances": [3, 100, 3, 1], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643, "start_time": "2018-01-02 15:04:05" } } ] ## Compute Pool Status [/compute_pool_status/] Collect statistic status of compute pools ### Query Status of All Compute Pools [GET] Collect status of all compute pools + Request Query Status of Compute Pools + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of statistic status + (PoolStatistic) + Body [ { "error_code": 0, "message": "", "data":[{ "name": "default", "enabled": true, "cells": [0, 25], //[offline, online] "instances": [3, 100, 3, 1], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643 }, { "name": "pool2", "enabled": true, "cells": [0, 15], //[offline, online] "instances": [3, 50, 0, 0], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643 }] } ] ### Get Status of a Compute Pool [GET /compute_pool_status/{pool}] Collect statistic status on a compute pool + Parameters + pool (string) - name of a compute pool + Request Get Status of A Compute Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(PoolStatistic) - statistic status + Body [ { "error_code": 0, "message": "", "data":{ "name": "default", "enabled": true, "cells": [0, 25], //[offline, online] "instances": [3, 100, 3, 1], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643 } } ] ## Compute Cell Status [/compute_cell_status/{pool}/] Collect statistic status of compute cells + Parameters + pool (string) - name of target pool ### Query Status of Compute Cells [GET] Collect statistic status of compute cells in a pool + Request Query Status of Compute Cells + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of statistic status + (CellStatistic) + Body [ { "error_code": 0, "message": "", "data":[ { "name": "cell_93e3de24f0a4", "address": "172.16.4.7", "enabled": true, "alive": true, "instances": [3, 15, 0, 0], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643 }, { "name": "cell_93e3de24f0a3", "address": "172.16.4.8", "enabled": true, "alive": true, "instances": [0, 12, 1, 0], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643 } ] } ] ### Get Compute Cell Status [GET /compute_cell_status/{pool}/{cell}] Collect statistic status of a compute cell + Parameters + cell (string) - name of target cell + Request Get Status of A Compute Cell + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(CellStatistic) - statistic status + Body [ { "error_code": 0, "message": "", "data":{ "name": "cell_93e3de24f0a4", "address": "172.16.4.7", "enabled": true, "alive": true, "instances": [3, 15, 0, 0], //[stopped, running, lost, migrate] "cpu_usage": 156.45, "max_cpu": 320, "available_memory": 560, "max_memory": 960, "available_disk": 12457, "max_disk": 34000, "read_speed": 8634, "write_speed": 3673, "receive_speed": 7634, "send_speed": 2643 } } ] ## Cell Storages [/compute_cell_status/{pool}/{cell}/storages/] Manage storage configure of a cell + Parameters + pool (string) - name of target pool + cell (string) - name of target cell ### Query Cell Storages [GET] Get Storage Paths for a cell + Request Query Storages (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(CellStorage) - cell storages configure + Body { "error_code": 0, "message": "", "data":{ "mode": "local", "system": [ "/var/lib/libvirt/images/" ], "data": [ "/var/lib/libvirt/images/" ], } } ### Modify Cell Storage Paths [PUT] Modify Storage Paths + Request Modify Storage Paths (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + default (string) - default storage path + Body { "default": "/var/lib/libvirt/images/" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Instance Status [/instance_status/{pool}/] Query status of instances + Parameters + pool (string) - name of target pool ### Query Status of Instances In Pool [GET] Query status of all instances in a pool + Request Query Instances In Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of statistic status + (InstanceStatus) + Body [ { "error_code": 0, "message": "", "data": [{ "name": "test01", "id": "df6723jhew67f3fdsf-fefew", "cell": "cell_abc", "host": "10.100.13.9", "created": true, "running": true, "cores": 4, "memory": 5120, "disks": [4864000, 854365], "auto_start": true, "system": "linux", "display_protocol": "vnc", "monitor_secret": "abd", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "media_attached": true, "media_source": "centos_7_x64_iso" }, { "name": "test02", "id": "dr6ufh73dgjf3fdsf-fefew", "cell": "cell_edv", "host": "10.100.13.6", "created": false, "progress": 46, "running": false, "cores": 4, "memory": 5120, "disks": [4864000, 854365], "auto_start": false, "system": "linux" }] } ] ### Query Instances In Cell [GET /instance_status/{pool}/{cell}/] Query status of instances in a cell + Parameters + cell (string) - name of target cell + Request Query Instances In Cell + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of statistic status + (InstanceStatus) + Body [ { "error_code": 0, "message": "", "data": [{ "name": "test01", "id": "df6723jhew67f3fdsf-fefew", "cell": "cell_abc", "host": "10.100.13.9", "created": true, "running": true, "cores": 4, "memory": 5120, "disks": [4864000, 854365], "auto_start": true, "system": "linux", "display_protocol": "vnc", "monitor_secret": "abd", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "media_attached": true, "media_source": "centos_7_x64_iso" }, { "name": "test02", "id": "dr6ufh73dgjf3fdsf-fefew", "cell": "cell_edv", "host": "10.100.13.6", "created": false, "progress": 46, "running": false, "cores": 4, "memory": 5120, "disks": [4864000, 854365], "auto_start": false, "system": "linux" }] } ] ## Address Pool [/address_pools/] Manage Address Pools ### Query All Address Pools [GET] Query all address pools + Request Query All Address Pools + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of address pool + (AddressPoolSummary) + Body { "error_code": 0, "message": "", "data":[ { "name": "address1", "gateway": "172.16.3.254", "addresses": 120, "allocated": 17 }, { "name": "address2", "gateway": "172.16.7.254", "addresses": 230, "allocated": 10 } ] } ### Get Address Pool Status [GET /address_pools/{name}] Get address pool status + Parameters + name (string) - pool name + Request Get Address Pool Status + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(AddressPoolStatus) - address pool status + Body { "error_code": 0, "message": "", "data":{ "gateway": "172.16.3.254", "dns": [ "8.8.8.8", "10.10.10.10" ], "provider": "dhcp", "mode": "internal", "ranges": [ { "start": "172.16.3.1", "end": "172.16.3.18", "netmask": "255.255.255.0", }, { "start": "172.16.3.20", "end": "172.16.3.190", "netmask": "255.255.255.0", } ], "allocated": [ { "address": "172.16.3.6", "instance": "abcdef-1234567890", }, { "address": "172.16.3.17", "instance": "abcdef-1234567893", } ] } } ### Create New Address Pool [POST /address_pools/{name}] Create a new address pool + Parameters + name (string) - pool name + Request Create A New Address Pool (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(AddressPoolConfigure) + Body { "gateway": "172.16.3.254", "dns": [ "8.8.8.8", "10.10.10.10" ], "provider": "cloudinit", "mode": "external" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Modify Address Pool [PUT /address_pools/{name}] Modify address pool + Parameters + name (string) - pool name + Request Modify A Address Pool (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(AddressPoolConfigure) + Body { "gateway": "172.16.3.254", "dns": [ "8.8.8.8", "10.10.10.10" ], "provider": "dhcp", "mode": "both" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Delete Address Pool [DELETE /address_pools/{name}] Delete an address pool + Parameters + name (string) - pool name + Request Delete Address Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Address Range [/address_pools/{name}/{type}/ranges/] Manage Address Range + Parameters + name (string) - name of address pool + type (enum[string],optional) - range type + Default: `internal` + Members + `internal` + `external` ### Query Address Ranges [GET] Query all ranges in pool + Request Query Address Ranges + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (array[AddressRange],fixed-type) - list of address range + Body { "error_code": 0, "message": "", "data":[ { "start": "172.16.3.1", "end": "172.16.3.18", "netmask": "255.255.255.0" }, { "start": "172.16.3.25", "end": "172.16.3.200", "netmask": "255.255.255.0" } ] } ### Get Address Ranges Status [GET /address_pools/{name}/{type}/ranges/{start}] Get address range status + Parameters + start (string) - start address of range + Request Get Address Ranges Status + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + start (string) - start address of ip range + end (string) - end address of ip range + netmask (string) - netmask of ip range + allocated(array[AllocatedAddress], optional) - list of allocated addresses + Body { "error_code": 0, "message": "", "data":{ "start": "172.16.3.1", "end": "172.16.3.18", "netmask": "255.255.255.0", "allocated": [ { "address": "172.16.3.6", "instance": "abcdef-1234567890", }, { "address": "172.16.3.17", "instance": "abcdef-1234567893", } ] } } ### Add Address Range [POST /address_pools/{name}/{type}/ranges/{start}] Add a new address range + Parameters + start (string) - start address of range + Request Add Address Range (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + end (string) - end address of ip range + netmask (string) - netmask of ip range + Body { "end": "172.16.3.18", "netmask": "255.255.255.0" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Remove Address Range [DELETE /address_pools/{name}/{type}/ranges/{start}] Remove an address range + Parameters + start (string) - start address of range + Request Remove Range + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } # Group Virtual machines Manage All guests and instances ## Guest Query [/guest_search/{?pool,cell,owner,group,status,created}] Interface for query all guest in specified pool, cell or status flags + Parameters + pool (string) - target pool name + cell (string, optional) - target cell + status (number, optional) - running status + created (boolean, optional) - guest created ### Query Guests With Conditions [GET] + Request Query Guests + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array,fixed-type) - list of instances + (InstanceData) + Body [ { "error_code": 0, "message": "", "data":[ { "name": "guest1", "id": "df6723jhew67f3fdsf-fefew", "running": false, "owner": "admin", "group": "manager", "pool": "pool1", "cell": "cell_93e3de24f0a4", "host": "172.10.4.1", "cores": 4, "memory": 5120, "total_disk": 4864000, "disks": [482345, 487534], "auto_start": true, "system": "windows", "ethernet_address": "ed:35:3d:5a:4e:3f", "display_protocol": "vnc", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "qos": { "cpu_priority": "high", "write_speed": 1048576, "write_iops": 100, "read_speed": 1048576, "read_iops": 100, "receive_speed": 10485760, "send_speed": 10485760 } } ], [ { "name": "guest2", "id": "df6723jhew67f3fdsf-fefet", "running": false, "owner": "admin", "group": "manager", "pool": "pool1", "cell": "cell_93e3de24f0a4", "host": "172.10.4.1", "cores": 4, "memory": 5120, "total_disk": 4864000, "disks": [482345, 487534] "auto_start": true, "system": "linux", "ethernet_address": "ed:35:3d:5a:4e:3f", "display_protocol": "vnc", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "qos": { "cpu_priority": "high", "write_speed": 1048576, "write_iops": 100, "read_speed": 1048576, "read_iops": 100, "receive_speed": 10485760, "send_speed": 10485760 } } ] } ] ## Manage Guest [/guests/] Creating, Deleting or query one guest ### Query Guest Status [GET /guests/{id}] Get status with ID when creating, 201 for creating guest, 200 for created guest + Parameters + id (string) - guest id + Request Guest Guest Status + Headers Nano-session: 1234567890-abcdef + Response 201 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + name(string,optional) - guest id + created(boolean) - is guest created + progress(number,optional) - range from 0 to 100 + Body [ { "error_code": 0, "message": "", "data":{ "name": "test01", "created": false, "progress": 57 } } ] + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(InstanceData) - current instance data + Body [ { "error_code": 0, "message": "", "data":{ "name": "test01", "created": true, "running": false, "owner": "admin", "group": "manager", "pool": "pool1", "cell": "cell_93e3de24f0a4", "host": "172.10.4.1", "cores": 4, "memory": 5120, "total_disk": 4864000, "disks": [482345, 487534], "auto_start": true, "system": "linux", "ethernet_address": "ed:35:3d:5a:4e:3f", "display_protocol": "vnc", "monitor_secret": "abd", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "qos": { "cpu_priority": "high", "write_speed": 1048576, "write_iops": 100, "read_speed": 1048576, "read_iops": 100, "receive_speed": 10485760, "send_speed": 10485760 } } } ] ### Create Guest [POST] Creating a new guest, return an ID for later querying + Request Create New Guest (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (InstanceData) + Body { "name": "some_instance", "owner": "admin", "group": "manager", "pool": "pool_1", "cores": 8, "memory": 4048, "disks": [4048, 38443], "auto_start": true, "template": "1234-axvdewd", "modules": ["qemu", "cloud-init"], "cloud_init":{ "root_enabled": true, "admin_name": "nano", "admin_secret": "12345678", "data_path": "/opt/data" }, "security_policy_group": "1234-abcdefg" } + Response 202 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - creating guest id + Body { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ### Delete Guest [DELETE /guests/{id}] delete guest, release all allocated resources + Parameters + id (string) - guest id + Attributes + force (boolean, optional) - whether stops instance for deleting + Request delete guest (application/json) { "force": true } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Auto Start [/guests/{id}/auto_start] Enable or disable auto start option of guest + Parameters + id (string) - guest ID ### Modify Auto Start Option [PUT] Change status of auto start option + Request Modify Auto Start Option (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + enable (boolean) - enable auto start + Body { "enable": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Number Of Cores [/guests/{id}/cores] Manage cores of guest + Parameters + id (string) - guest ID ### Modify Cores [PUT] Change number of cores + Request Modify Cores (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + cores (number) - core number + immediate(boolean,optional) - take effect when running + Body { "cores": 4, "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Memory Capacity [/guests/{id}/memory] + Parameters + id (string) - guest ID ### Modify Memory Capacity [PUT] Change memory size of guest, only available when guest offline + Request Change Memory Capacity (application/json) + Attributes + memory(number) - memory in bytes + immediate (boolean, optional) - take effect when running + Body { "memory": 4294967296, "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Resize Disk Capacity [/guests/{id}/disks/resize/{disk}] Manage disk capacity of guest + Parameters + id (string) - guest ID + disk (number) - index of target disk, system:0, data0:1, data1:2... ### Extend Disk Capacity [PUT] Change disk capacity of the guest to larger. Only allow operating in an offline instance. + Request Extend Disk Capacity (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + size(number) - size in bytes + immediate (boolean, optional) - take effect when running + Body { "size": 42949672960, "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Shrink Disk Capacity [/guests/{id}/disks/shrink/{disk}] Shrink the disk capacity of guest + Parameters + id (string) - guest ID + disk (number) - index of target disk, system:0, data0:1, data1:2... ### Shrink Disk File [PUT] Shrink size of guest disk file to minimal for building images. Only allow operating in an offline instance. + Request Shrink Disk File (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + immediate (boolean, optional) - take effect when running + Body { "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Operating System [/guests/{id}/system/] Manage operating system of guest + Parameters + id (string) - guest ID ### Reset Operating System [PUT] Reset operating system of the guest from a disk image, all user data discard. + Request Reset Guest System (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + from_image (string) - id of new system image + Body { "from_image": "0123456789-abcdef" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Administrator Password [/guests/{id}/auth] Manage administator password + Parameters + id (string) - guest ID ### Reset Administrator Password [PUT] Reset a new password for administator of guest + Request Reset Administrator Password (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + password (string, optional) - new password, automated generate when omitted + user(number, optional) - username, automated choose username by system type when omitted + Body { "password": "asdb12356", "user": "root" } + Response 200 (application/json) + Attributes + password (string) - admin password + user(number) - admin name + Body [ { "error_code": 0, "message": "", "data": { "password": "1235656756", "user": "root" } } ] ### Get Administrator Password [GET] Get current name and password of administrator + Request Get Administrator Password + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + password (string) - admin password + user(number) - admin name + Body [ { "error_code": 0, "message": "", "data": { "password": "1235656756", "user": "root" } } ] ## Guest Name [/guests/{id}/name/] Manage name of guest + Parameters + id (string) - guest ID ### Modify Guest Name [PUT] Change guest name + Request Modify Guest Name (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + name (string) - guest name + Body { "name": "some_instance", } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## CPU priority [/guests/{id}/qos/cpu/] Manage QoS of CPU cores + Parameters + id (string) - guest ID ### Change CPU prioirty [PUT] Change CPU priority + Request Modify CPU priority (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + priority (enum[string]) - CPU priority + Members + `high` + `medium` + `low` + Body { "priority": "high", } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Disk QoS [/guests/{id}/qos/disk/] Manage Disk QoS + Parameters + id (string) - guest ID ### Modify Disk QoS [PUT] Change disk QoS configure + Request Modify Disk QoS (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + write_speed: 10485760 (number, optional) - disk write bps limit, 0 = unlimited + write_iops: 100 (number, optional) - disk write iops limit, 0 = unlimited + read_speed: 10485760 (number, optional) - disk read bps limit, 0 = unlimited + read_iops: 100 (number, optional) - disk read iops limit, 0 = unlimited + Body { "write_speed": 1048576, "write_iops": 100, "read_speed": 1048576, "read_iops": 100 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Network QoS [/guests/{id}/qos/network/] Manage network QoS + Parameters + id (string) - guest ID ### Modify Network QoS [PUT] change network QoS configure + Request Modify Network QoS (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + receive_speed: 10485760 (number, optional) - network receive bps, 0 = unlimited + send_speed: 10485760 (number, optional) - network send bps, 0 = unlimited + Body { "receive_speed": 10485760, "send_speed": 10485760 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Guest Security Policy [/guests/{id}/security_policy/] Manage security policy of guest + Parameters + id (string) - guest id ### Get Security Policy [GET] + Request Get Security Policy + Headers Nano-session: 1234567890-abcdef Accept: text/plain + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + default_action(enum[string]) - default action when no rule matched + Default: `accept` + Members + `accept` + `reject` + rules(array[SecurityPolicyRule],fixed-type) - list of rules + Body { "error_code": 0, "message": "", "data": { "default_action": "reject", "rules": [ { "action": "accept", "to_port": 22, "protocol": "tcp" }, { "action": "accept", "to_port": 80, "protocol": "tcp" }, { "action": "accept", "to_port": 8080, "from_address": "127.0.0.1", "protocol": "tcp" } ] } } ## Guest Security Policy Default Action [/guests/{id}/security_policy/default_action] Manage default action of security policy, invoked when a packet does not match any rules. + Parameters + id (string) - guest id ### Change Default Action [PUT] Change the default action when no rules matched + Request Change Default Action (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + action(enum[string]) - default action when no rule matched + Default: `accept` + Members + `accept` + `reject` + Body { "action": "accept" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Guest Security Policy Rules [/guests/{id}/security_policy/rules/] Manage security policy rules + Parameters + id (string) - guest id ### Append New Security Policy Rule [POST] Append new security policy rule to tail + Request Append New Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(SecurityPolicyRule) + Body { "action": "accept", "to_port": 8088, "protocol": "tcp", "from_address": "127.0.0.1", "interface": 1 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Modify Security Policy Rule [PUT /guests/{id}/security_policy/rules/{index}] Modify Security Policy Rule + Parameters + index (number) - index of policy rule + Request Modify Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(SecurityPolicyRule) + Body { "action": "accept", "to_port": 8088, "protocol": "tcp", "from_address": "127.0.0.1", "interface": 1 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Change Rule Order [PUT /guests/{id}/security_policy/rules/{index}/order] Change Rule Order + Parameters + index (number) - index of policy rule + Request Change Rule Order (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + direction(enum[string]) - change direction + Members + `up` - move up + `down` - move down + Body { "direction": "up" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Remove Security Policy Rule [DELETE /guests/{id}/security_policy/rules/{index}] Remove Security Policy Rule + Parameters + index (number) - index of policy rule + Request Remove Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Manage Instances [/instances/{id}] Manage guest instances + Parameters + id (string) - guest ID ### Get Running Status [GET] Get current status of an instance + Request Get Instance Status + Headers Nano-Session: 12345678-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(InstanceStatus) - current status + Body [ { "error_code": 0, "message": "", "data": { "name": "test01", "created": true, "running": true, "owner": "admin", "group": "manager", "pool": "pool1", "cell": "cell_93e3de24f0a4", "cores": 4, "memory": 5120, "total_disk": 4864000, "disks": [482345, 487534], "auto_start": true, "ethernet_address": "ed:35:3d:5a:4e:3f", "display_protocol": "vnc", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "media_attached": true, "medi\_source": "centos\_7\_x64\_iso", "cpu_usage": 5.34, "memory_available": 1280, "disk_available": 4925700, "bytes_read": 3673, "bytes_written": 8634, "bytes_received": 2643, "bytes_sent": 7634 } } ] ### Start Guest/Instance [POST] Start guest(create instance) + Request Start Instance (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + from_media (boolean, optional) - boot from media + from_network (boolean, optional) - boot from network source/PXE + source (string, optional) - boot source id/URI + Body { "from_media": true, "source": "bd0fe127-a8db-4c89-98ea-9a5070b08aae" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Stop Guest/Instance [DELETE] Stop guest(delete instance) + Request Stop Guest (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + reboot (boolean) - shutdown or reboot + force(boolean) - force operate + Body { "reboot": false, "force": true } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Instance Media [/instances/{id}/media] Manage media in the running instance + Parameters + id (string) - guest ID ### Insert Media [POST] Insert media into a running instance + Request Insert Media (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + source (string) - media id + type (number, optional) - media type, 0 = Media Image + Body { "source": "bd0fe127-a8db-4c89-98ea-9a5070b08aae", "type": 0 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Eject Media [DELETE] Eject media from a running instance + Request Eject Media + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Guest Snapshots [/instances/{id}/snapshots/] Manage snapshots of a guest + Parameters + id (string) - guest ID ### Query Snapshots [GET] Query all snapshots attached to the guest + Request Query Snapshots + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data":[ "origin":{ "is_root": true }, "snapshot1": { "backing": "origin" }, "snapshot2": { "backing": "snapshot1" }, "snapshot3": { "backing": "snapshot2", "is_current": true }, "another_branch": { "backing": "origin" }, "another_end": { "backing": "another_branch" } ] } ] ### Create New Snapshot [POST] Create a new snapshot, only available when guest stopped + Request Create New Snapshot (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + name (string) - snapshot name + description (string, optional) - snapshot description + Body { "name": "snapshot1", "description": "this is a snapshot example" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Restore snapshot [PUT] Resume to a specified snapshot, available on stopped guest + Request Restore Snapshot (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + target (string) - snapshot name + Body { "target": "snapshot1" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Configure Snapshot [/instances/{id}/snapshots/{name}] Operate on a specified snapshot + Parameters + id (string) - guest id + name (string) - snapshot ### Get snapshot info [GET] Query info of a snapshot + Request Get Snapshot Info + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + running(boolean) - is running snapshot + create_time(string) - created time in 'YYYY-MM-DD HH:MI:SS' format + description(string,optional) - snapshot description + Body [ { "error_code": 0, "message": "", "data":{ "running": false, "description": "this is snapshot before installing cloud-init", "create_time": "2018-08-21 12:34:56" } } ] ### Delete snapshot [DELETE] Delete a snapshot + Request Delete Snapshot + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Monitor Channel [/monitor_channels/] create channel for monitor and control instance. Create a new temporary channel id `ABC` using POST Method, then connect and consumed channel with websocket address `ws://host/monitor_channels/ABC` using noVNC or other clients. Unused channel will be released if no connection established in time. ### Create New Channel [POST] Establish a new monitor channel + Request Create New Monitor Channel (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + guest (string) - target guest id + Body { "guest": "some_guest_id", } + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + id (string) - channel id + protocol(string) - monitor protocol + username(string) - monitor user name + password(string) - monitor password + Body [ { "error_code": 0, "message": "", "data":{ "id": "channel-id-123", "protocol": "vnc", "username": "", "password": "some_secret", } } ] # Group Image APIs manage disk and media images ## Media Image Search [/media_image_search/] Search Media Images ### Search Media Image [GET] Search media images with login session + Request Search Media Image + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (array[ImageStatus],fixed-type) - list of image status + Body { "error_code": 0, "message": "", "data":[ { "name": "centos7_64_minimal", "id": "sdf83kjfe-23r4wedf", "description": "some desc", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659735, "tags": ["linux", "64bit", "centos"] }, { "name": "win7_home_64", "id": "sdf83kjfe-23r4wertytdf", "description": "win desktop", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659774, "tags": ["windows", "64bit", "windows7"] } ] } ## Media Image [/media_images/] Manage Media Images ### Synchronize Local Media Images [PATCH] Synchronize media images from local directory + Request Synchronize Local Media Images + Headers Nano-session: 1234567890-abcdef + Attributes + owner (string) - owner of synchronized image + group (string) - group of synchronized image + Body { "owner": "admin", "group": "manager", } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Query All Media Images [GET] Query all media image + Request Query All Media Images + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (array[ImageStatus],fixed-type) - list of image status + Body { "error_code": 0, "message": "", "data":[ { "name": "centos7_64_minimal", "id": "sdf83kjfe-23r4wedf", "description": "some desc", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659735, "tags": ["linux", "64bit", "centos"] }, { "name": "win7_home_64", "id": "sdf83kjfe-23r4wertytdf", "description": "win desktop", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659774, "tags": ["windows", "64bit", "windows7"] } ] } ### Get Media Image [GET /media_images/{id}] Get info of media image + Parameters + id (string) - media image id + Request Get Media Image Status + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (ImageStatus) - image status + Body { "error_code": 0, "message": "", "data":{ "name": "centos7_64_minimal", "id": "sdf83kjfe-23r4wedf", "description": "some desc", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659735, "tags": ["linux", "64bit", "centos"] } } ### Create Media Image [POST] Create a new media image + Request Create A New Media Image (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (ImageConfigure) + Body { "name": "centos7_64_minimal", "owner": "admin", "group": "manager", "description": "some desc", "tags": ["linux", "64bit", "centos"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - image id + Body { "error_code": 0, "message": "", "data":[ { "id": "sdf83kjfe-23r4wedf", } ] } ### Modify Media Image [PUT /media_images/{id}] Modify info of media image + Parameters + id (string) - media image id + Request Modify Media Image (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (ImageConfigure) + Body { "name": "centos7_64_minimal", "owner": "admin", "group": "manager", "description": "some desc", "tags": ["linux", "64bit", "centos"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Detele Media Image [DELETE /media_images/{id}] Delete a media image + Parameters + id (string) - media image id + Request Detele Media Image + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Media Image File [/media_image_files/{id}] APIs manage file of media images + Parameters + id (string) - image id ### Download Image File [GET] Download binary media image data + Response 200 (application/octet-stream) ### Upload Image File [POST] Upload iso data as media image + Request upload (multipart/form-data) -----BOUNDARY Content-Disposition: form-data; name="image"; filename="image.iso" -----BOUNDARY + Response 200 (application/json) [ { "error_code": 0, "message": "", "data":"" } ] ## Disk Image Search [/disk_image_search/{?tags}] Search disk images + Parameters + tags (array[string], optional) - image tags ### Search Disk Image [GET] Search disk images + Request Search Disk Image By Conditions + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (array[ImageStatus],fixed-type) - list of image status + Body { "error_code": 0, "message": "", "data":[ { "name": "centos7_64_minimal", "id": "sdf83kjfe-23r4wedf", "description": "some desc", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659735, "tags": ["linux", "64bit", "centos"] }, { "name": "win7_home_64", "id": "sdf83kjfe-23r4wertytdf", "description": "win desktop", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659774, "tags": ["windows", "64bit", "windows7"] } ] } ## Disk Image [/disk_images/] Manage Disk Images ### Synchronize Local Disk Image [PATCH] Synchronize disk images from local directory + Request Synchronize Local Disk Image + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Get Disk Image [GET /disk_images/{id}] Get status of disk image + Parameters + id (string) - disk image id + Request Get Disk Image Status + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (ImageStatus) - image status + Body { "error_code": 0, "message": "", "data": { "name": "centos7_64_minimal", "created": false, "progress": 46, "description": "some desc", "tags": ["linux", "64bit", "centos"] } } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (ImageStatus) - image status + Body { "error_code": 0, "message": "", "data": { "name": "centos7_64_minimal", "created": true, "description": "some desc", "create_time": "2018-08-21 00:12:34", "modify_time": "2018-08-21 00:13:34", "size": 4872334659735, "tags": ["linux", "64bit", "centos"] } } ### Create Disk Image [POST] Clone a new disk image from the source guest, or create an empty one for uploading when the guest ID omits. + Request Create A New Disk Image (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (DiskImage) + Body { "name": "centos7_64_minimal", "guest": "dir723rgfyu-rre67grg-efw", "owner": "admin", "group": "manager", "description": "some desc", "tags": ["linux", "64bit", "centos"] } + Response 202 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - image id + Body { "error_code": 0, "message": "", "data":[ { "id": "sdf83kjfe-23r4wedf", } ] } ### Modify Disk Image [PUT /disk_images/{id}] Modify info of disk image + Parameters + id (string) - disk image id + Request Modify Disk Image (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (DiskImage) + Body { "name": "centos7_64_minimal", "owner": "admin", "group": "manager", "description": "some desc", "tags": ["linux", "64bit", "centos"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Delete Disk Image [DELETE /disk_images/{id}] delete a disk image + Parameters + id (string) - disk image id + Request Delete Disk Image + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Disk Image File [/disk_image_files/{id}] APIs manage files of disk images + Parameters + id (string) - image id ### Upload Image File [POST] Upload a qcow2 file as disk image + Request Upload New Image File (multipart/form-data) + Headers Nano-session: 1234567890-abcdef + Body -----BOUNDARY Content-Disposition: form-data; name="image"; filename="centos7.qcow2" -----BOUNDARY Content-Disposition: form-data; name="checksum" 0123456789abcdef -----BOUNDARY + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } # Group System Maintain APIs for maintaing system ## System Templates [/templates/] Manage system templates ### Query System Templates [GET] Query All Templates + Request Query Templates (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array[TemplateBrief],fixed-type) - list of templates + Body { "error_code": 0, "message": "", "data": [ { "id": "1234-abcdef", "name": "CentOS 7", "operating_system": "linux", "created_time": "2020-04-06 00:00:00", "modified_time": "2020-04-06 00:00:00" }, { "id": "1234-abcdee", "name": "CentOS 6", "operating_system": "linux", "created_time": "2020-04-06 00:00:00", "modify_time": "2020-04-06 00:00:00" } ] } ### Get System Template [GET /templates/{id}] Get configure of a system template + Parameters + id (string) - template id + Request Get Template Detail (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data (TemplateStatus) - status + Body { "error_code": 0, "message": "", "data": { "id": "1234-abcdef", "name": "CentOS 7", "admin": "root", "operating_system": "linux", "disk": "scsi", "network": "virtio", "display": "vga", "control": "vnc", "usb": "none", "tablet": "none", "created_time": "2020-04-06 00:00:00", "modified_time": "2020-04-06 00:00:00" } } ### Create New System Template [POST] Create System Template + Request Create System Template (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(TemplateConfigure) + Body { "name": "CentOS 7", "admin": "root", "operating_system": "linux", "disk": "scsi", "network": "virtio", "display": "vga", "control": "vnc", "usb": "", "tablet": "" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - template id + Body { "error_code": 0, "message": "", "data": { "id": "1234-abcdef" } } ### Modify System Templates [PUT /templates/{id}] Modify System Templates + Parameters + id (string) - template id + Request Modify System Templates (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(TemplateConfigure) + Body { "name": "CentOS 7", "admin": "root", "operating_system": "linux", "disk": "scsi", "network": "virtio", "display": "vga", "control": "vnc", "usb": "", "tablet": "" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Delete System Template [DELETE /templates/{id}] Delete System Template + Parameters + id (string) - template id + Request Delete System Template (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Security Policy Group [/security_policy_groups/{id}] APIs manage security policy groups ### Get Security Group [GET] Get Security Group + Parameters + id (string) - group id + Request Get Security Group (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(SecurityPolicyGroupStatus) - status + Body { "error_code": 0, "message": "", "data": { "name": "centos7_1", "description": "Some Group For CentOS 7", "user": "nano", "group": "super", "enabled": true, "global": true, "default_action": "reject", "id": "1234-asvddf" } } ### Create Security Group [POST /security_policy_groups/] Create Security Group + Request Create Security Group (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(SecurityPolicyGroupConfig) + Body { "name": "linux_1", "description": "Some Group for Linux", "user": "nano", "group": "super", "enabled": false, "global": false, "default_action": "accept" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - group id + Body { "error_code": 0, "message": "", "data": { "id": "1234-abcdef" } } ### Modify Security Group [PUT] Modify Security Group + Parameters + id (string) - group id + Request Modify Security Group (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(SecurityPolicyGroupConfig) + Body { "name": "linux_2", "description": "Some Group for Linux", "user": "nano", "group": "super", "enabled": false, "global": false, "default_action": "accept" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Delete Security Group [DELETE] Delete Security Group + Parameters + id (string) - group id + Request Delete Security Group (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Query Security Policy Rules [GET /security_policy_groups/{id}/rules/] Query Security Policy Rule + Parameters + id (string) - group id + Request Query Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array[SecurityPolicyRule],fixed-type) - list of rules + Body { "error_code": 0, "message": "", "data": [ { "action": "accept", "to_port": 22, "protocol": "tcp" }, { "action": "accept", "to_port": 80, "protocol": "tcp" }, { "action": "accept", "to_port": 8080, "from_address": "127.0.0.1", "protocol": "tcp" } ] } ### Add Security Policy Rule [POST /security_policy_groups/{id}/rules/] Add Security Policy Rule + Parameters + id (string) - group id + Request Add Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(SecurityPolicyRule) + Body { "action": "accept", "to_port": 8088, "protocol": "tcp", "from_address": "127.0.0.1", "interface": 1 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Modify Security Policy Rule [PUT /security_policy_groups/{id}/rules/{index}] Modify Security Policy Rule + Parameters + id (string) - group id + index (number) - index of policy rule, start from 0 + Request Modify Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes(SecurityPolicyRule) + Body { "action": "accept", "to_port": 8088, "protocol": "tcp", "from_address": "127.0.0.1", "interface": 1 } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Change Rule Order [PUT /security_policy_groups/{id}/rules/{index}/order] Change Rule Order + Parameters + id (string) - group id + index (number) - index of policy rule, start from 0 + Request Change Rule Order (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + direction(enum[string]) - move direction + Members + `up` - move up + `down` - move down + Body { "direction": "up" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ### Remove Security Policy Rule [DELETE /security_policy_groups/{id}/rules/{index}] Remove Security Policy Rule + Parameters + id (string) - group id + index (number) - index of policy rule, start from 0 + Request Remove Security Policy Rule (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body { "error_code": 0, "message": "" } ## Migration [/migrations/{id}] Manage instance migrations ### Start Migration [POST /migrations/] Create and start a new migration task + Request Start Migration (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + source_pool (string) - pool of instance host + source_cell (string) - cell of instance host + target_pool (string, optional) - target pool you want to migrate + target_cell (string, optional) - target cell you want to migrate + instances (array[string], optional) - UUID list of instances need to migrate + Body { "source_pool": "default", "source_cell": "cell1", "target_pool": "another-pool", "target_cell": "new-cell", "instances": ["jhfguf85-34uyf-4t4tghjh", "dfjui-euy37-dyuy3t5qn"] } + Response 202 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + id (string) - migration ID + Body [ { "error_code": 0, "message": "", "data":[ { "id": "abcdef-1234567890" } ] } ] ### Get Status Of Migration Task [GET] Query status of a migration task + Parameters + id (string) - migration task id + Request Get Migration Task Status + Headers Nano-session: 1234567890-abcdef + Response 201 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + finished(boolean) - is migration finished + progress(number,optional) - migration progress range from 0 to 100 + Body [ { "error_code": 0, "message": "", "data":{ "finished": false, "progress": 57 //limit to 100 } } ] + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + finished(boolean) - is migration finished + Body [ { "error_code": 0, "message": "", "data":{ "finished": true } } ] ### Query All Migration in progress [GET /migrations/] Query all pending migrations + Request Query Pending Migration Tasks + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + id(string) - migration id + finished(boolean) - is migration finished + progress(number,optional) - migration progress range from 0 to 100 + Body [ { "error_code": 0, "message": "", "data":[ { "id": "1234567890-abcdef", "finished": false, "progress": 57 //limit to 100 }, { "id": "1234567890-abcdef", "finished": true } ] } ] ## Batch Creating Guest [/batch/create_guest/{id}] Manage batch creating tasks ### Start Creation [POST /batch/create_guest/] Create a bulk of new guests, return a task ID for query status + Request Start Batch Creating (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + name_rule: `order` (enum[string]) - rule of generating guest name + Members + `order` - incremental digital by order, etc `xxx_0`, `xxx_1` + `MAC` - by guest MAC address + `address` - by assigned guest address + name_prefix (string, optional) - guest name prefix + owner (string) - user id + group (string) - user group + pool (string) - compute pool name + count (number) - instance count + cores (number) - vm cpu cores + memory (number) - vm memory + disks (array[number],fixed-type) - [system_disk_size, data_disk_n_size...] + auto_start (boolean) - auto start instance + from_image (string, optional) - initial disk image id + template (string) - id of system template + modules (array[string], optional) - installed guest module, "qemu"/"cloud-init" + cloud_init (CloudInit, optional) - cloud-init params + qos (QoS, optional) - QoS config + Body { "name_rule": "order", "name_prefix": "test", "owner": "admin", "group": "manager", "pool": "pool_1", "count": 3, "cores": 8, "memory": 4048, "disks": [4048, 38443], "auto_start": true, "template": "1234-abcde", "modules": ["qemu", "cloud-init"], "cloud_init":{ "root_enabled": true, "admin_name": "nano", "admin_secret": "12345678", "data_path": "/opt/data" } } + Response 202 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - batch id + Body { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ### Query Batch Creating Status [GET] Query task status of batch creating + Parameters + id (string) - id of batch task + Request Query Pending Creating + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + name(string) - guest name + id(string) - creating guest id + progress(number,optional) - creating progress range from 0 to 100 + error(string,optional) - error message when creating fail + status(enum[string]) - task status + Members + `creating` + `created` + `fail` + Body [ { "error_code": 0, "message": "", "data":[ { "name": "test_1", "id": "0123456789-abcdef-1", "progress": 45, "status": "creating" }, { "name": "test_2", "id": "0123456789-abcdef-2", "status": "fail", "error": "not enough space" }, { "name": "test_3", "id": "0123456789-abcdef-3", "status": "created" } ] } ] + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + name(string) - guest name + id(string) - creating guest id + error(string,optional) - error message when creating fail + status(enum[string]) - task status + Members + `creating` + `created` + `fail` + Body [ { "error_code": 0, "message": "", "data":[ { "name": "test_1", "id": "0123456789-abcdef-1", "status": "created" }, { "name": "test_2", "id": "0123456789-abcdef-2", "status": "fail", "error": "not enough space" }, { "name": "test_3", "id": "0123456789-abcdef-3", "status": "created" } ] } ] ## Batch Deleting Guest [/batch/delete_guest/{id}] Manage batch deleting tasks ### Start Batch Deleting [POST /batch/delete_guest/] Delete a bulk of guests, return a task ID for query status + Request Start Batch Deleting (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + guest (array[string],fixed-type) - list of target guest UUID + force (boolean, optional) - stop running instance for deleting + Body { "guest": [ "0123456789-abcdef-1", "0123456789-abcdef-2", "0123456789-abcdef-3" ], "force": false } + Response 202 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - batch id + Body [ { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ] ### Query Batch Deleting Status [GET] Query task status of batch deleting + Parameters + id (string) - id of batch task + Request Query Pending Deleting + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + id(string) - target guest id + error(string,optional) - error message when deleting fail + status(enum[string]) - task status + Members + `deleting` + `deleted` + `fail` + Body [ { "error_code": 0, "message": "", "data":[ { "id": "0123456789-abcdef-1", "status": "deleted" }, { "id": "0123456789-abcdef-2", "status": "fail", "error": "invalid guest" }, { "id": "0123456789-abcdef-3", "status": "deleting" } ] } ] + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + id(string) - target guest id + error(string,optional) - error message when deleting fail + status(enum[string]) - task status + Members + `deleted` + `fail` + Body [ { "error_code": 0, "message": "", "data":[ { "id": "0123456789-abcdef-1", "status": "deleted" }, { "id": "0123456789-abcdef-2", "status": "fail", "error": "invalid guest" }, { "id": "0123456789-abcdef-3", "status": "deleted" } ] } ] ## Batch Stopping Guest [/batch/stop_guest/{id}] APIs manage batch stopping tasks ### Start Batch Stopping [POST /batch/stop_guest/] Stop a bulk of guests, return a task ID for query status + Request Start Batch Stopping (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + guest (array[string],fixed-type) - list of target guest UUID + Body { "guests": [ "0123456789-abcdef-1", "0123456789-abcdef-2", "0123456789-abcdef-3" ] } + Response 202 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + id (string) - batch id + Body [ { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ] ### Query Batch Stopping Status [GET] Query task status of batch stopping + Parameters + id (string) - id of batch task + Request Query Pending Stopping + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + id(string) - target guest id + error(string,optional) - error message when stopping fail + status(enum[string]) - task status + Members + `stopping` + `stopped` + `fail` + Body [ { "error_code": 0, "message": "", "data":[ { "id": "0123456789-abcdef-1", "status": "stopped" }, { "id": "0123456789-abcdef-2", "status": "fail", "error": "invalid guest" }, { "id": "0123456789-abcdef-3", "status": "stopping" } ] } ] + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + id(string) - target guest id + error(string,optional) - error message when stopping fail + status(enum[string]) - task status + Members + `stopping` + `stopped` + `fail` + Body [ { "error_code": 0, "message": "", "data":[ { "id": "0123456789-abcdef-1", "status": "stopped" }, { "id": "0123456789-abcdef-2", "status": "fail", "error": "invalid guest" }, { "id": "0123456789-abcdef-3", "status": "stopped" } ] } ] # Group Resource Search APIs for search resources ## Search Security Policy Groups [/search/security_policy_groups/{?enabled_only,global_only,owner,group}] Search secuirity policy groups by condition + Parameters + owner (string, optional) - return policy created by owner + group (string, optional) - return policy in specified group + enabled_only (boolean, optional) - enabled group only + global_only (boolean, optional) - global group only ### Query Security Group [GET] Query security group by current user/group + Request Query Security Group (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array[SecurityPolicyGroupStatus],fixed-type) - list of security policy groups + Body { "error_code": 0, "message": "", "data": [ { "id": "123-5dfdf", "name": "group1", "user": "nano", "group": "super", "enabled": true, "global": true, "default_action": "accept" }, { "id": "123-5dfdd", "name": "group2", "user": "user_a", "group": "users", "enabled": true, "global": false, "default_action": "reject" } ] } ## Search Guests [/search/guests/] ### Search Guests [POST] Search guests by conditions with current user, keyword could using guest name or target IP + Request Search Guests (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + limit (number) - max record returned + offset (number,optional) - record offset + pool(string,optional) - hosting pool + cell(string,optional) - hosting cell + keyword(string,optional) - search keyword, match guest name/IP, hosting cell name/IP + Body { "limit": 10, "offset": 20, "keyword": "example" } + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + result(array[InstanceStatus],fixed-type) - list of guests + total(number) - total record count + limit (number) - max returned record count + offset (number) - search start offset + Body [ { "error_code": 0, "message": "", "data": { "result":[{ "name": "test01", "id": "df6723jhew67f3fdsf-fefew", "cell": "cell_abc", "host": "10.100.13.9", "created": true, "running": true, "cores": 4, "memory": 5120, "disks": [4864000, 854365], "auto_start": true, "system": "linux", "display_protocol": "vnc", "monitor_secret": "abd", "internal":{ "network_address": "172.18.6.7", "display_address": "172.18.5.3:5901", "allocated_address": "172.18.6.7" }, "external":{ "network_address": "202.3.1.34", "display_address": "202.3.1.34:5901" }, "create_time": "2018-08-21 00:12:34", "media_attached": true, "media_source": "centos_7_x64_iso" }, { "name": "test02", "id": "dr6ufh73dgjf3fdsf-fefew", "cell": "cell_edv", "host": "10.100.13.6", "created": false, "progress": 46, "running": false, "cores": 4, "memory": 5120, "disks": [4864000, 854365], "auto_start": false, "system": "linux" }], "total": 100, "limit": 2, "offset": 10 } } ] # Group FrontEnd Management Management APIs for FrontEnd module ## Role [/roles/{role_name}] Manage user roles ### List Roles [GET /roles/] Query all user roles in the system + Request Query All Roles + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array[string],optional) - list of role names + Body [ { "error_code": 0, "message": "", "data":[ "maintainer", "auditor", "user" ] } ] ### Get Role [GET] Get configure data for the specified role + Parameters + role_name (string) - name of user role + Request Get Role Data + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + menu(array[string],optional) - list of menu tags + Body [ { "error_code": 0, "message": "", "data":{ "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"] } } ] ### Add Role [POST] Add a new user role to system + Parameters + role_name (string) - name of user role + Request Add Role (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + menu (array[string],fixed-type) - menu tags list which can access using this role + Body { "menu": ["dashboard", "compute_pool", "address_pool", "instance"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Modify Role [PUT] Change resource can access for a specified role + Parameters + role_name (string) - name of user role + Request Modify Role (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + menu (array[string],fixed-type) - menu tags list which can access using this role + Body { "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Remove Role [DELETE] Remove a role from the system, only available when the role don't bind to any user or group + Parameters + role_name (string) - name of user role + Request Remove Role + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## User Group [/user_groups/{group_name}] APIs manage user groups ### Query All User Groups [GET /user_groups/] Query all user groups in the system + Request Query All User Groups + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array) + (object) + name(string) - group name + display(string) - display name of group + member(number) - group member count + Body [ { "error_code": 0, "message": "", "data":[ { "name": "manager_group", "display": "Group of Manager", "member": 3 }, { "name": "auditor_group", "display": "Group of Auditor", "member": 1 }, { "name": "user_group", "display": "Group of User", "member": 10 } ] } ] ### Get User Group Detail [GET] Get detail data of a user group + Parameters + group_name (string) - name of user group + Request Get User Group Data + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data + name(string) - group name + display(string) - display name of group + role(array[string],fixed-type) - list of attached roles + member(array[string],fixed-type) - list of group members + Body [ { "error_code": 0, "message": "", "data":{ "name": "manager_group", "display": "Group of Manager", "role": ["manager", "user"], "member": [ "admin", "nano", "akumas" ] } } ] ### Add User Group [POST] Add a new user group to the system + Parameters + group_name (string) - name of user group + Request Add User Group (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + display (string) - display name of group + role (array[string], optional) - list of attached roles + Body { "display": "Group of Manager", "role": ["manager", "user"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Modify User Group [PUT] Modify a user group + Parameters + group_name (string) - name of user group + Request Modify User Group (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + display (string) - display name of group + role (array[string], optional) - list of attached roles + Body { "display": "Group of Manager", "role": ["manager", "user"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Remove User Group [DELETE] Remove a user group from the system + Parameters + group_name (string) - name of user group + Request Remove User Group + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## User Group Members [/user_groups/{group_name}/members/{user_name}] APIs manage members of a user group + Parameters + group_name (string) - name of user group ### Query User Group Members [GET /user_groups/{group_name}/members/] Query all members of a user group + Request Query User Group Members + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + data(array[string],fixed-type) - list of member names + Body [ { "error_code": 0, "message": "", "data":[ "admin", "nano", "akumas" ] } ] ### Add User Group Member [POST] Add a new member to the user group + Parameters + user_name (string) - user name + Request Add User Group Member + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Remove User Group Member [DELETE] Remove a member from the user group + Parameters + user_name (string) - user name + Request Remove User Group Member + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## User [/users/{user_name}] APIs manage users ### Query All Users [GET /users/] Query all users in the system + Request Query All Users + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array[string],fixed-type) - list of users + Body [ { "error_code": 0, "message": "", "data":[ "admin", "nano", "akumas" ] } ] ### Get User Info [GET] Get info of a user + Parameters + user_name (string) - user name + Request Get User Info + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + nick(string) - nick name + mail(string) - user email address + Body [ { "error_code": 0, "message": "", "data":{ "nick": "AK", "mail": "a@b.com" } } ] ### Create New User [POST] Create a new user in the system + Parameters + user_name (string) - user name + Request Create New User (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + nick (string, optional) - nick name for display + mail (string, optional) - user email + password (string) - user password + Body { "nick": "AK", "mail": "a@b.com", "password": "abcdefg" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Modify User [PUT] Modify user info + Parameters + user_name (string) - user name + Request Modify User Info (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + nick (string, optional) - nick name for display + mail (string, optional) - user email + Body { "nick": "AK", "mail": "a@b.com" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Delete User [DELETE] Delete a user + Parameters + user_name (string) - user name + Request Delete User + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## User Password [/users/{user_name}/password/] APIs manage user password + Parameters + user_name (string) - user name ### Modify User Password [PUT] Verify and update a new user password + Request Modify Password (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + old (string) - old password for verify + new (string) - new password + Body { "old": "123456", "new": "abcdef" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## User Search [/user_search/{?group}] APIs for searching users ### Search User [GET] Search users by group + Parameters + group (string, optional) - user group + Request Search Users + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data(array[string],fixed-type) - list of users + Body [ { "error_code": 0, "message": "", "data":[ "nano", "alex", "sam" ] } ] ## Sessions [/sessions/{session_id}] Manage authenticated session ### Authenticate New Session [POST /sessions/] Verify and allocate a new sesion for all other requests, set session ID in header 'Nano-Session' for authentication. + Request Create New Session (application/json) + Attributes + user (string) - user name + password (string) - new password + nonce (string) - nonce for crypt + Body { "user": "alex", "password": "abcdef", "nonce": "1234567890" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + session(string) - allocated session ID + timeout(number) - session timeout in seconds + Body [ { "error_code": 0, "message": "", "data":{ "session": "bsu6384js3=", "timeout": 120 } } ] ### Update Session [PUT] Keep session alive + Parameters + session_id (string) - session ID + Request Keep Alive + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Obtain Authenticated Session [GET] Get attached info with authenticated session + Parameters + session_id (string) - session ID + Request Obtain Session Data + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + user(string) - authenticated user name + group(string) - authenticated group name + address(string) - current request IP + menu(array[string],optional) - list of menu tags + resource(array[string],optional) - list of allocated resources + Body [ { "error_code": 0, "message": "", "data":{ "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"], "resource": [], "user": "nano", "group": "admin", "address": "192.168.1.100" } } ] ## Resource Visibility [/resource_visibilities/] Manage resource visibility with login session ### Get Current Visibility [GET] Get current visibility configure with the group of current user + Request Get Visiblity + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data":{ "instance_visible": true, "media_image_visible": true, "disk_image_visible": false } } ] ### Set Current Visibility [PUT] Modify current visibility configure with the group of current user + Request Modify Visibility (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (Visibility) + Body { "instance_visible": true, "media_image_visible": true, "disk_image_visible": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ## Logs [/logs/{?limit,start,after,before}] APIs manage system logs ### Query Log Entry [GET] Query system logs by conditions + Parameters + limit (number) - max entries returned + start (number, optional) - start offset + after (string, optional) - query logs after this date + before (string, optional) - query logs before this date + Request Query Logs + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + data + logs(array) + (object) + id(string) - log id + time(string) - timestamp of log in format 'YYYY-MM-DD HH:MI:SS' + content(string) - log content + total(number) - total log entries + Body [ { "error_code": 0, "message": "", "data":{ "logs": [ { "id": "201812011457390001", "time": "2018-12-01 14:57:39", "content": "admin create new user example" }, { "id": "201812031427190001", "time": "2018-12-03 14:27:19", "content": "nano.sabrina create new guest nano.test1" } ], "total": 100 } } ] ### Add Log Entry [POST] Add a single log entry + Request Add Log (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + format (string, optional) - format of content + content (string) - log content + Body { "format": "string", "content": "here is a new log for somebody creating a new instance" } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ] ### Delete Log Entry [DELETE] Delete logs + Request Delete Log (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + entries (array[string],fixed-type) - list of log entry + Body { "entries": [ "201812011457390001", "201812031427190001" ] } + Response 200 (application/json) + Attributes (object) + error_code (number) - error code + message (string,optional) - error message + Body [ { "error_code": 0, "message": "" } ]