FORMAT: 1A HOST: http://nanos.cloud/api/v1 # FrontEnd API (Project Nano) 本文档定义由Nano的FrontEnd模块提供的RESTful API接口,API服务默认监听端口为5870。 本文档内容对应版本1.3.1 调用文中绝大部分接口前,需要通过会话管理接口,首先分配一个授权会话,并将会话ID设置在HTTP请求头的'Nano-Session'字段,用于请求鉴权。 # Data Structures ## GuestConfig (object) + name (string) - 云主机名 + owner (string) - 用户ID + group (string) - 用户组 + pool (string) - 计算资源池名称 + cores (number) - 核心数量 + memory (number) - 内存容量(字节) + disks (array[number],fixed-type) - [系统盘大小, 数据盘n大小...], 以字节计算 + auto_start (boolean) - 云主机实例是否随宿主机开机启动 + system (string, optional) - 系统类型,比如"linux", "windows" + network_address (string, optional) - 指定云主机IP(可选),尚未支持 + ethernet_address (string, optional) - 指定云主机MAC地址(可选),尚未支持 + from_image (string, optional) - 克隆时使用的源磁盘镜像ID + ports (array[number], optional) - 需要开放的映射端口清单,尚未支持 + template (string) - 系统模板ID + modules (array[string], optional) - 云主机系统里已安装的模块,如"qemu"/"cloud-init" + cloud_init (CloudInit, optional) - Cloud-Init参数 + qos (QoS, optional) - QoS配置 + security\_policy\_group(string, optional) - 使用的安全策略组ID ## InterfaceStatus (object) + network_address (string) - 网卡地址,IPv4格式,比如: '172.10.6.8' + display_address (string) - 云主机监控地址,格式为'主机:端口' + allocated_address (string,optional) - 系统通过管理地址池为云主机分配的地址 ## InstanceData (GuestConfig) + id (string) - 云主机ID + created (boolean) - 是否已创建 + running (boolean) - 是否运行中 + cell(string,optional) - 承载资源节点名 + host(string,optional) - 承载资源节点地址 + lost(boolean,optional) - 云主机是否失联 + system(string,optional) - 云主机系统ID + monitor_secret(string,optional) - 监控密码 + display_protocol(string,optional) - 监控协议 + total_disk (number) - 总磁盘容量,以字节计算 + progress (number, optional) - 创建进度,0~100 + create_time (string, optional) - 创建时间,格式:'YYYY-MM-DD HH:MI:SS' + internal (InterfaceStatus,optional) - 内部网口状态 + external (InterfaceStatus,optional) - 外部网口状态 ## InstanceStatus (InstanceData) + cpu_usage (number) - 总CPU使用率,0.00 ~ 100.00 + memory_available(number) - 可用内存容量(字节) + disk_available(number) - 可用磁盘容量(字节) + bytes_read (number) - 总磁盘读取字节数 + bytes_written (number) - 总磁盘写入字节数 + bytes_received (number) - 总网络接收字节数 + bytes_sent (number) - 总网络发送字节数 + media_attached (boolean,optional) - 是否已挂载光盘镜像 + media_source (string,optional) - 挂载光盘镜像ID ## QoS (object) + cpu_priority (enum[string], optional) - CPU优先级 + Default: `medium` + Members + `high` - 高优先 + `medium` - 中优先 + `low` - 低优先 + write_speed: 10485760 (number, optional) - 磁盘写入限速(字节/每秒),0 = 无限制 + write_iops: 100 (number, optional) - 磁盘写入限速(操作/每秒),0 = 无限制 + read_speed: 10485760 (number, optional) - 磁盘读取限速(字节/每秒),0 = 无限制 + read_iops: 100 (number, optional) - 磁盘读取限速(操作/每秒),0 = 无限制 + receive_speed: 10485760 (number, optional) - 网络接收限速(字节/每秒),0 = 无限制 + send_speed: 10485760 (number, optional) - 网络发送限速(字节/每秒),0 = 无限制 ## CloudInit (object) + root_enabled: true (boolean, optional) - 允许root用户通过SSH远程登录,默认启用 + admin_name: `nano` (string, optional) - 指定超级管理员用户名,不指定则使用'root' + admin_secret (string, optional) - 超级管理员明码,不指定则由nano生成安全密码 + data_path (string, optional) - 数据磁盘挂载路径,默认为`/opt/data` ## ComputePoolConfig (object) + storage(string,optional) - 使用的存储池名称,不指定则使用本地存储(默认) + network(string,optional) - 使用的地址池名称,不指定则使用桥接模式(默认,云主机通过物理网络获取IP地址) + failover(boolean) - 是否启用故障切换(需要共享存储,默认关闭) ## ComputePoolStatus (ComputePoolConfig) + name(string) - 资源池名称 + enabled(boolean) - 是否启用 + cells(number) - 已经添加到的资源节点数量 ## StoragePoolConfig (object) + type (enum[string]) - 后端存储类型 + Default: `nfs` + Members + `nfs` - NFS存储 + host (string, optional) - 存储主机的IP或者域名 + target (string, optional) - 存储主机的路径 ## CellStorage (object) + mode (enum[string]) - Cell存储模式 + Default: `local` + Members + `local` - 本地存储(默认) + `nfs` - NFS + `ceph` - Ceph + system(array[string],optional) - 云主机的系统磁盘文件存储路径,仅用于本地存储模式 + data(array[string],optional) - 云主机的数据磁盘文件存储路径,仅用于本地存储模式 ## StoragePoolStatus (StoragePoolConfig) + name(string) - 存储资源池名称 ## AllocatedAddress (object) + address (string) - 已分配地址 + instance (string) - 地址关联的云主机ID + type (enum[string], optional) - 地址类型 + Default: `internal` + Members + `internal` - 内部地址 + `external` - 外部地址 ## AddressRange (object) + start (string) - 范围起始地址 + end (string) - 范围结束地址 + netmask (string) - 范围地址掩码 + type (enum[string], optional) - 地址类型 + Default: `internal` + Members + `internal` - 内部地址 + `external` - 外部地址 ## AddressPoolConfigure (object) + name(string) - 地址池名称 + gateway (string) - 网关地址 + provider (enum[string],optional) - 地址配置方式 + Default: `dhcp` + Members + `dhcp` - 使用DHCP配置云主机地址 + `cloudinit` - 使用Cloud-Init配置云主机地址 + mode (enum[string],optional) - 网口模式 + Default: `internal` + Members + `internal` - 创建内部网口 + `external` - 创建外部网口 + `both` - 同时创建内外部网口 ## AddressPoolStatus (AddressPoolConfigure) + ranges (array[AddressRange], optional) - 地址范围清单 + allocated (array[AllocatedAddress], optional) - 已分配地址清单 ## AddressPoolSummary (AddressPoolConfigure) + addresses (number) - 总地址数量 + allocated (number) - 已分配地址数量 ## StatisticData (object) + name(string) - 数据源名称 + cpu_usage(number) - 总使用核心数 + max_cpu(number) - 总核心数 + available_memory(number) - 总可用内存数量(字节) + max_memory(number) - 总内存数量(字节) + available_disk(number) - 总可用磁盘数量(字节) + max_disk(number) - 总磁盘数量(字节) + read_speed(number) - 磁盘读取速度(字节/秒) + write_speed(number) - 磁盘写入速度(字节/秒) + receive_speed(number) - 网络接收速度(字节/秒) + send_speed(number) - 网络发送速度(字节/秒) ## ZoneStatistic (StatisticData) + pools(array[number],fixed-type) - [禁用资源池数量, 启用资源池数量] + cells(array[number],fixed-type) - [离线节点数量, 在线节点数量] + instances(array[number],fixed-type) - [停止实例数量, 运行实例数量, 实例实例数量, 迁移实例数量] + start_time(string) - 系统启动时间,格式:'YYYY-MM-DD HH:MI:SS' ## PoolStatistic (StatisticData) + enabled(boolean) - 资源池是否启用 + cells(array[number],fixed-type) - [离线节点数量, 在线节点数量] + instances(array[number],fixed-type) - [停止实例数量, 运行实例数量, 实例实例数量, 迁移实例数量] ## CellStatistic (StatisticData) + address(string) - 资源节点地址 + enabled(boolean) - 节点是否启用 + alive(boolean) - 节点是否在线 ## Visibility (object) + instance_visible: true (boolean) - 是否允许访问同组云主机实例 + media_image_visible: true (boolean) - 是否允许访问同组光盘镜像 + disk_image_visible: false (boolean) - 是否允许访问同组磁盘镜像 ## TemplateConfigure (object) + name(string) - 系统模板名 + admin(string) - 默认管理员用户名 + operating_system(enum[string]) - 操作系统 + Default: `linux` + Members + `linux` + `windows` + disk(enum[string]) - 磁盘驱动类型 + Default: `scsi` + Members + `scsi` + `sata` + `ide` + network(enum[string]) - 网卡型号 + Default: `virtio` + Members + `virtio` + `e1000` + `rtl8139` + display(enum[string]) - 显卡驱动 + Default: `vga` + Members + `vga` + `cirrus` + control(enum[string]) - 远程控制 + Default: `vnc` + Members + `vnc` + `spice` + usb(enum[string]) - USB接口型号 + Default: `` + Members + `` + `nec-xhci` + tablet(enum[string]) - 平板接口型号 + Default: `` + Members + `` + `usb` ## TemplateStatus (TemplateConfigure) + id (string) - 系统模板ID + created_time(string) - 模板创建时间,格式`YYYY-MM-DD HH:MI:SS` + modified_time(string) - 模板修改时间,格式`YYYY-MM-DD HH:MI:SS` ## TemplateBrief (object) + id (string) - 系统模板ID + name(string) - 系统模板名 + operating_system(enum[string]) - 操作系统 + Default: `linux` + Members + `linux` + `windows` + created_time(string) - 模板创建时间,格式`YYYY-MM-DD HH:MI:SS` + modified_time(string) - 模板修改时间,格式`YYYY-MM-DD HH:MI:SS` ## SecurityPolicyRule (object) + action(enum[string]) - 处理动作 + Default: `accept` + Members + `accept` + `reject` + to_port(number) - 目标端口 + protocol(enum[string]) - 匹配协议 + Default: `all` + Members + `all` + `tcp` + `udp` + `icmp` + from_address(string, optional) - 来源地址 + interface(number, optional) - 匹配接口索引,0=全部接口, 1=第一个接口,以此类推 ## SecurityPolicyGroupConfig (object) + name (string) - 安全组名 + description (string,optional) - 安全组描述 + user(string) - 创建者ID + group(string) - 创建者组名 + enabled(boolean) - 是否启用 + global(boolean) - 是否全局可见 + default_action(enum[string]) - 默认处理动作,未匹配规则时触发default action when no rule matched + Default: `accept` + Members + `accept` - 接受 + `reject` - 拒绝 ## SecurityPolicyGroupStatus (SecurityPolicyGroupConfig) + id (string) - 安全组ID ## ImageConfigure (object) + name (string) - 镜像名 + owner (string) - 镜像所属用户 + group (string) - 镜像所属组 + description (string, optional) - 镜像描述 + tags (array[string], optional) - 镜像标签 ## ImageStatus (ImageConfigure) + id (string, optional) - 镜像ID + created (boolean) - 是否创建完成 + progress (number, optional) - 构建进度,0~100 + create_time (string, optional) - 创建时间,格式:YYYY-MM-DD HH:MI:SS + modify_time (string, optional) - 修改时间,格式:YYYY-MM-DD HH:MI:SS + size (number, optional) - 镜像尺寸(字节) ## DiskImage (ImageConfigure) + guest (string,optional) - 来源云主机ID,未指定则创建空白镜像 # Group 资源池 管理资源池接口 ## 计算资源池 [/compute_pools/] 管理计算资源池 ### 获取所有计算资源池 [GET] 查询当前域内所有计算资源池 + Request 获取所有计算资源池 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[ComputePoolStatus],fixed-type) - 资源池状态清单 + 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_pools/{pool}] 获取单个计算资源池状态 + Parameters + pool (string) - 资源池名称 + Request 获取计算资源池状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(ComputePoolStatus) - 计算资源池状态 + Body { "error_code": 0, "message": "", "data":{ "name": "default", "enabled": true, "cells": 10, "storage": "some_cluster", "network": "address_pool1", "failover": true } } ### 创建新计算资源池 [POST /compute_pools/{pool}] 创建一个新的计算资源池 + Parameters + pool (string) - 资源池名称 + Request 创建新计算资源池 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 删除计算资源池 [DELETE /compute_pools/{pool}] 删除一个空的计算资源池 + Parameters + pool (string) - 资源池名称 + Request 删除计算资源池 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 修改计算资源池 [PUT /compute_pools/{pool}] 修改计算资源池配置 + Parameters + pool (string) - 计算资源池名称 + Request 修改计算资源池 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes (ComputePoolConfig) + Body [ { "failover": true, "storage": "nfs-poo1" } ] + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 计算资源节点 [/compute_pool_cells/] 管理资源池中节点 ### 查询未分配节点 [GET] 查询尚未加入计算资源池的资源节点 + Request 查询未分配节点 + 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, } ] } ] ### 查询池内资源节点 [GET /compute_pool_cells/{pool}] 查询已经绑定资源池的所有资源节点 + Parameters + pool (string) - 计算资源池名称 + Request 查询池内资源节点 + 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, } ] } ] ### 添加资源节点 [POST /compute_pool_cells/{pool}/{cell}] 将新资源节点添加到计算资源池 + Parameters + pool (string) - 资源池名称 + cell (string) - 资源节点名称 + Request 添加资源节点 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 移除资源节点 [DELETE /compute_pool_cells/{pool}/{cell}] 将一个资源节点从计算资源池中移除,仅能移除未分配云主机的资源节点 + Parameters + pool (string) - 资源池名称 + cell (string) - 资源节点名称 + Request 移除资源节点 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 修改资源节点 [PUT /compute_pool_cells/{pool}/{cell}] 变更资源节点状态 + Parameters + pool (string) - 资源池名称 + cell (string) - 资源节点名称 + Request 修改资源节点 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + enable(boolean) - 启用节点,禁用节点不会分配新的云主机 + Body { "enable": false } + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 获取资源节点状态 [GET /compute_pool_cells/{pool}/{cell}] 获取资源节点当前状态 + Parameters + pool (string) - 资源池名称 + cell (string) - 资源节点名称 + Request 获取资源节点状态 + 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_pools/] 管理存储资源池 ### 查询所有存储资源池 [GET] 查询所有存储资源池的配置 + Request 查询所有存储资源池 + 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_pools/{pool}] 获取单个存储资源池的配置信息 + Parameters + pool(string) - 存储资源池名称 + Request 获取存储资源池配置 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) [ { "error_code": 0, "message": "", "data": { "type": "nfs", "host": "nfs.nano.com", "target": "/var/nano/pool1" } } ] ### 新建存储资源池 [POST /storage_pools/{pool}] 新建一个存储资源池 + Parameters + pool(string) - 存储资源池名称 + Request 新建存储资源池 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 修改存储资源池 [PUT /storage_pools/{pool}] 修改存储资源池配置,仅用于未承载云主机数据的空存储池 + Parameters + pool(string) - 存储资源池名称 + Request 修改存储资源池 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 删除存储资源池 [DELETE /storage_pools/{pool}] 删除存储资源池,仅用于未承载云主机数据的空存储池 + Parameters + pool(string) - 存储资源池名称 + Request Delete Storage Pool + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 计算域状态 [/compute_zone_status/] 采集域内所有资源用量和运行状态 ### 查询域状态 [GET] 查询全域最新状态 + Request 查询域状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(ZoneStatistic) - 统计状态 + 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/] 采集计算资源池状态 ### 查询所有计算资源池状态 [GET] 查询统计域内所有计算资源池状态和用量 + Request 查询所有计算资源池状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[PoolStatistic],fixed-type) - 统计状态清单 + 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 /compute_pool_status/{pool}] 采集和统计某个计算资源池的状态和资源用量 + Parameters + pool (string) - 计算资源池名称 + Request 获取单个计算资源池状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(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 } } ] ## 计算资源节点状态 [/compute_cell_status/{pool}/] 获取和采集计算资源节点的状态和用量 + Parameters + pool (string) - 目标节点名称 ### 查询池内资源节点状态 [GET] 采集某个资源池内所有资源节点的状态和资源用量 + Request 查询池内资源节点状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[CellStatistic],fixed-type) - 统计状态清单 + 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/{pool}/{cell}] 采集某个资源节点的状态和资源用量 + Parameters + cell (string) - 目标节点名称 + Request 获取单个资源节点状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(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 } } ] ## 资源节点存储配置 [/compute_cell_status/{pool}/{cell}/storages/] 管理资源节点的本地存储配置 + Parameters + pool (string) - 计算资源池名称 + cell (string) - 计算节点名称 ### 查询资源节点存储信息 [GET] 获取某个资源节点的存储路径配置 + Request 查询资源节点存储信息 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(CellStorage) - 存储配置 + Body { "error_code": 0, "message": "", "data":{ "mode": "local", "system": [ "/var/lib/libvirt/images/" ], "data": [ "/var/lib/libvirt/images/" ], } } ### 修改资源节点存储路径 [PUT] 修改资源节点存储路径 + Request 修改资源节点存储路径 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + default (string) - 默认存储路径 + Body { "default": "/var/lib/libvirt/images/" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 实例状态 [/instance_status/{pool}/] 查询云主机实例状态 + Parameters + pool (string) - name of target pool ### 资源池内实例状态 [GET] 查询资源池内所有的云主机实例状态 + Request 查询资源池内云主机实例状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[InstanceStatus],fixed-type) - 状态清单 + 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" }] } ] ### 节点内实例状态 [GET /instance_status/{pool}/{cell}/] 查询指定资源节点承载的云主机实例状态 + Parameters + cell (string) - 目标节点名称 + Request 查询节点内实例状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[InstanceStatus],fixed-type) - 状态清单 + 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_pools/] 配置可用地址资源,分配给云主机 ### 地址资源池清单 [GET] 查询系统内所有地址池资源池 + Request 查询系统内所有地址池资源池 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[AddressPoolSummary],fixed-type) - 地址池清单 + 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_pools/{name}] 获取地址池状态 + Parameters + name (string) - 地址池名称 + Request 获取地址池状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(AddressPoolStatus) - 状态信息 + 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", } ] } } ### 创建新地址池 [POST /address_pools/{name}] 创建新地址池,用于云主机分配地址 + Parameters + name (string) - 地址池名称 + Request 创建新地址池 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 修改地址池 [PUT /address_pools/{name}] 修改地址池配置信息 + Parameters + name (string) - 地址池信息 + Request 修改地址池配置 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除地址池 [DELETE /address_pools/{name}] 删除一个地址池,仅适用于未分配地址的地址池 + Parameters + name (string) - 地址池名称 + Request 删除地址池 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 地址段 [/address_pools/{name}/{type}/ranges/] 管理地址段,用于给地址池添加可分配的地址资源 + Parameters + name (string) - 地址池名称 + type (enum[string],optional) - 地址段类型 + Default: `internal` + Members + `internal` - 内部地址 + `external` - 外部地址 ### 查询地址段 [GET] 查询地址池内所有可用地址段 + Request 查询地址段 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (array[AddressRange],fixed-type) - 地址段清单 + 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_pools/{name}/{type}/ranges/{start}] 获取地址段状态和地址分配情况 + Parameters + start (string) - 段起始地址 + Request 获取地址段状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + start (string) - 地址段起始IP + end (string) - 地址段结束IP + netmask (string) - 地址段掩码 + allocated(array[AllocatedAddress], optional) - 已分配地址清单 + 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", } ] } } ### 新增地址段 [POST /address_pools/{name}/{type}/ranges/{start}] 添加地址段到地址池中备用 + Parameters + start (string) - 地址段起始IP + Request 新增地址段 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + end (string) - 地址段结束IP + netmask (string) - 地址段掩码 + Body { "end": "172.16.3.18", "netmask": "255.255.255.0" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除地址段 [DELETE /address_pools/{name}/{type}/ranges/{start}] 从地址池中移除地址段,仅限于未分配地址段 + Parameters + start (string) - 地址段起始IP + Request Remove Range + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } # Group 云主机 管理云主机配置及运行实例 ## 云主机查询 [/guest_search/{?pool,cell,owner,group,status,created}] 查询指定资源池或者节点内云主机状态 + Parameters + pool (string) - 目标资源池名称 + cell (string, optional) - 目标节点名称 + status (number, optional) - 运行状态标识 + created (boolean, optional) - 是否仅查询已创建云主机 ### Query Guests With Conditions [GET] + Request Query Guests + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array,fixed) - 实例清单 + (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 } } ] } ] ## 云主机配置 [/guests/] 管理云主机配置 ### 查询云主机状态 [GET /guests/{id}] 通过创建时生成的云主机ID查询当前状态,201为创建中,200为已创建 + Parameters + id (string) - 云主机ID + Request 查询云主机状态 + Headers Nano-session: 1234567890-abcdef + Response 201(application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + name(string,optional) - 云主机ID + created(boolean) - 是否创建完成 + progress(number,optional) - 构建进度,范围0~100 + Body [ { "error_code": 0, "message": "", "data":{ "name": "test01", "created": false, "progress": 57 } } ] + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(InstanceData) - 当前实例状态 + 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 } } } ] ### 创建云主机 [POST] 创建云主机,返回ID用于后续查询 + Request 创建新主机 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 创建的云主机ID + Body { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ### 删除云主机 [DELETE /guests/{id}] 删除云主机,释放所有分配资源 + Parameters + id (string) - 云主机ID + Attributes + force (boolean, optional) - 删除前是否停止云主机实例 + Request delete guest (application/json) { "force": true } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 开机启动 [/guests/{id}/auto_start] 启用或者停用云主机随宿主机开机启动 + Parameters + id (string) - 云主机ID ### 修改开机启动选项 [PUT] 修改开机启动选项 + Request 修改开机启动选项 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + enable (boolean) - 是否启用开机启动 + Body { "enable": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 核心数量 [/guests/{id}/cores] 管理云主机核心数量 + Parameters + id (string) - guest ID ### 修改云主机核心数量 [PUT] 修改云主机核心数量,仅支持停机操作 + Request 修改云主机核心数量 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + cores (number) - 核心数量 + immediate(boolean,optional) - 是否运行时生效(尚不支持) + Body { "cores": 4, "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 内存容量 [/guests/{id}/memory] 管理云主机内存容量 + Parameters + id (string) - guest ID ### 修改内存容量 [PUT] 修改云主机内存容量,仅支持离线云主机 + Request 修改内存容量 (application/json) + Attributes + memory(number) - 内存容量(字节) + immediate (boolean, optional) - 运行时是否实时生效(尚不支持) + Body { "memory": 4294967296, "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 调整磁盘容量 [/guests/{id}/disks/resize/{disk}] 管理云主机磁盘容量 + Parameters + id (string) - 云主机ID + disk (number) - 目标磁盘索引,系统盘=0,数据盘1=1,数据盘2=2,以此类推 ### 扩展磁盘容量 [PUT] 扩充云主机磁盘容量,仅支持离线云主机 + Request 扩展磁盘容量 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + size(number) - 新的磁盘容量(字节) + immediate (boolean, optional) - 运行时是否立即生效(尚不支持) + Body { "size": 42949672960, "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 压缩磁盘容量 [/guests/{id}/disks/shrink/{disk}] 压缩云主机磁盘容量 + Parameters + id (string) - 云主机ID + disk (number) - 目标磁盘索引,系统盘=0,数据盘1=1,数据盘2=2,以此类推 ### 压缩磁盘文件 [PUT] 将云主机磁盘文件压缩到最小,通常用于构建云主机镜像,仅支持离线云主机 + Request 压缩磁盘文件 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + immediate (boolean, optional) - 运行时是否直接生效(尚未支持) + Body { "immediate": false } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 操作系统 [/guests/{id}/system/] 管理云主机操作系统 + Parameters + id (string) - 云主机ID ### 重置云主机操作系统 [PUT] 从磁盘镜像重刷云主机操作系统,放弃所有原有数据 + Request 重置云主机操作系统 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + from_image (string) - 源镜像ID + Body { "from_image": "0123456789-abcdef" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 管理员密码 [/guests/{id}/auth] 管理云主机管理员密码 + Parameters + id (string) - 云主机ID ### 重置管理员密码 [PUT] 为云主机重置新管理员密码 + Request 重置管理员密码 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + password (string, optional) - 新密码,未指定则由系统生成安全密码 + user(number, optional) - 管理员用户名,未指定则根据系统类型自动选择 + Body { "password": "asdb12356", "user": "root" } + Response 200 (application/json) + Attributes + password (string) - 管理员密码 + user(number) - 管理员用户名 + Body [ { "error_code": 0, "message": "", "data": { "password": "1235656756", "user": "root" } } ] ### 获取管理员密码 [GET] 获取当前云主机的管理员密码和用户名 + Request 获取管理员密码 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + password (string) - 管理员密码 + user(number) - 管理员用户名 + Body [ { "error_code": 0, "message": "", "data": { "password": "1235656756", "user": "root" } } ] ## 云主机名称 [/guests/{id}/name/] 管理云主机名称 + Parameters + id (string) - 云主机ID ### 修改云主机名称 [PUT] 修改云主机名称 + Request 修改云主机名称 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + name (string) - 云主机名称 + Body { "name": "some_instance", } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## CPU优先级 [/guests/{id}/qos/cpu/] 管理云主机CPU优先级,高优先级云主机容易获得更多CPU资源,用于处理自己业务 + Parameters + id (string) - 云主机ID ### 修改CPU优先级 [PUT] 修改CPU优先级 + Request 修改CPU优先级 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + priority (enum[string]) - CPU优先级 + Members + `high` - 高优先级 + `medium` - 中优先级 + `low` - 低优先级 + Body { "priority": "high", } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 磁盘QoS [/guests/{id}/qos/disk/] 管理磁盘QoS,优化云主机磁盘IO性能 + Parameters + id (string) - 云主机ID ### 修改磁盘QoS配置 [PUT] 调整云主机磁盘QoS配置,优化云主机磁盘性能和响应速度 + Request 修改磁盘QoS配置 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + write_speed: 10485760 (number, optional) - 磁盘写入速度限制(字节/秒),0为不限制 + write_iops: 100 (number, optional) - 磁盘写入操作限制(写入/秒),0为不限制 + read_speed: 10485760 (number, optional) -磁盘读取速度限制(字节/秒),0为不限制 + read_iops: 100 (number, optional) - 磁盘读取操作限制(读取/秒),0为不限制 + Body { "write_speed": 1048576, "write_iops": 100, "read_speed": 1048576, "read_iops": 100 } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 网络QoS [/guests/{id}/qos/network/] 管理云主机的网络QoS配置参数,优化网络IO性能 + Parameters + id (string) - 云主机ID ### 修改云主机网络QoS参数 [PUT] 修改云主机网络QoS参数,优化网络IO性能 + Request 修改云主机网络QoS参数 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + receive_speed: 10485760 (number, optional) - 网络接收速度限制(字节/秒),0为不限制 + send_speed: 10485760 (number, optional) - 网络发送速度限制(字节/秒),0为不限制 + Body { "receive_speed": 10485760, "send_speed": 10485760 } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 云主机安全策略 [/guests/{id}/security_policy/] 管理云主机安全策略 + Parameters + id (string) - 云主机ID ### 获取安全策略配置 [GET] 获取云主机当前的安全策略配置 + Request 获取安全策略配置 + Headers Nano-session: 1234567890-abcdef Accept: text/plain + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + default_action(enum[string]) - 报文默认处理规则 + Default: `accept` + Members + `accept` - 接受 + `reject` - 拒绝 + rules(array[SecurityPolicyRule],fixed-type) - 处理规则清单 + 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" } ] } } ## 默认处理规则 [/guests/{id}/security_policy/default_action] 管理云主机安全策略的默认规则,当接收报文不匹配任何已知规则时,按照默认规则处理 + Parameters + id (string) - 云主机ID ### 修改默认处理动作 [PUT] 设置当报文不匹配任何规则时的处理动作 + Request 修改默认处理动作 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + action(enum[string]) - 报文匹配规则失败时的默认处理 + Default: `accept` + Members + `accept` - 接受 + `reject` - 拒绝 + Body { "action": "accept" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 云主机安全策略规则 [/guests/{id}/security_policy/rules/] 管理云主机安全策略规则 + Parameters + id (string) - 云主机ID ### 追加安全策略规则 [POST] 为云主机添加新的安全策略规则 + Request 追加安全策略规则 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 修改安全策略规则 [PUT /guests/{id}/security_policy/rules/{index}] 修改安全策略规则 + Parameters + index (number) - 规则索引,从0开始 + Request 修改安全策略规则 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 调整规则顺序 [PUT /guests/{id}/security_policy/rules/{index}/order] 调整安全策略顺序规则 + Parameters + index (number) - 规则索引,从0开始 + Request 调整规则顺序 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + direction(enum[string]) - 规则移动方向 + Members + `up` - 向上移动 + `down` - 向下移动 + Body { "direction": "up" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除安全策略规则 [DELETE /guests/{id}/security_policy/rules/{index}] 删除安全策略规则 + Parameters + index (number) - 规则索引,从0开始 + Request 删除安全策略规则 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 云主机实例 [/instances/{id}] 管理云主机实例 + Parameters + id (string) - 云主机ID ### 获取实例运行状态 [GET] 获取当前云主机实例运行状态 + Request 获取实例运行状态 + Headers Nano-Session: 12345678-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(InstanceStatus) - 当前状态 + 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 } } ] ### 启动云主机实例 [POST] 启动云主机实例 + Request 启动云主机实例 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + from_media (boolean, optional) - 从光盘镜像启动 + from_network (boolean, optional) - 从网络源启动(尚未支持) + source (string, optional) - 源镜像ID或者地址 + Body { "from_media": true, "source": "bd0fe127-a8db-4c89-98ea-9a5070b08aae" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 停止云主机实例 [DELETE] 停止云主机运行 + Request 停止云主机实例 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + reboot (boolean) - 重启或者关机,默认为重启 + force(boolean) - 是否强制执行 + Body { "reboot": false, "force": true } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 媒体镜像 [/instances/{id}/media] 管理云主机实例加载的媒体镜像 + Parameters + id (string) - guest ID ### 插入媒体镜像 [POST] 运行云主机实例中插入媒体镜像,需要先把ISO光盘镜像上传系统后使用 + Request 插入媒体镜像 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + source (string) - 镜像ID + type (number, optional) - 媒体类型,0=媒体镜像(默认) + Body { "source": "bd0fe127-a8db-4c89-98ea-9a5070b08aae", "type": 0 } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 弹出媒体镜像 [DELETE] 在运行的云主机实例中弹出已经加载的媒体镜像 + Request 弹出媒体镜像 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 云主机快照 [/instances/{id}/snapshots/] 管理云主机快照 + Parameters + id (string) - 云主机ID ### 查询云主机快照清单 [GET] 查询某云主机用的全部快照清单 + Request 查询云主机快照清单 + 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" } ] } ] ### 创建新快照 [POST] 为云主机创建新快照,仅云主机停止时可用 + Request 创建新快照 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + name (string) - 快照名称 + description (string, optional) - 快照描述 + Body { "name": "snapshot1", "description": "this is a snapshot example" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 恢复快照 [PUT] 将系统还原到快照创建时刻,仅对停止云主机可用 + Request 恢复快照 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + target (string) - 快照名称 + Body { "target": "snapshot1" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 快照配置 [/instances/{id}/snapshots/{name}] 配置指定的云主机快照 + Parameters + id (string) - 云主机ID + name (string) - 快照名称 ### 获取快照信息 [GET] 查询指定快照信息 + Request 获取快照信息 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + running(boolean) - 是否运行中的快照 + create_time(string) - 创建时间,格式:'YYYY-MM-DD HH:MI:SS' + description(string,optional) - 快照描述 + 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] 删除云主机快照 + Request 删除快照 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 监控通道 [/monitor_channels/] 为了保障云主机访问安全,统一管理外部连接,Nano建立一个临时的安全监控通道用于管理和控制云主机。 使用创建接口分配通道后,可以通过Websocket地址`ws://host/monitor_channels/{channel_id}`使用VNC协议进行访问,支持noNVC或者其他标准客户端。 如果通道分配后未及时建立连接,则通道会自动释放。 ### 创建新监控通道 [POST] 建立连接指定云主机的监控通道 + Request 创建新监控通道 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + guest (string) - 需要监控的云主机ID + Body { "guest": "some_guest_id", } + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 监控通道ID + protocol(string) - 监控协议 + username(string) - 连接用户名 + password(string) - 连接密码 + Body [ { "error_code": 0, "message": "", "data":{ "id": "channel-id-123", "protocol": "vnc", "username": "", "password": "some_secret", } } ] # Group 镜像管理 管理磁盘镜像和光盘镜像 ## 媒体镜像搜索 [/media_image_search/] 搜索媒体镜像 ### 搜索媒体镜像 [GET] 使用已登录用户权限搜索可访问的媒体镜像菜单 + Request 搜索媒体镜像 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (array[ImageStatus],fixed-type) - 可用镜像清单 + 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_images/] 管理媒体镜像 ### 同步本地媒体镜像文件 [PATCH] 从Core模块的本地镜像文件存储路径读取并同步媒体镜像数据 + Request 同步本地媒体镜像文件 + Headers Nano-session: 1234567890-abcdef + Attributes + owner (string) - 指定同步镜像的创建者 + group (string) - 指定同步镜像的所属用户组 + Body { "owner": "admin", "group": "manager", } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 查询所有媒体镜像 [GET] 查询所有媒体镜像 + Request 查询所有媒体镜像 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (array[ImageStatus],fixed-type) - 镜像清单 + 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_images/{id}] 获取媒体镜像信息 + Parameters + id (string) - 媒体镜像ID + Request 获取媒体镜像状态 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (ImageStatus) - 镜像状态 + 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"] } } ### 创建媒体镜像 [POST] 创建空白媒体镜像,用于上传和更新媒体镜像数据,需要配合后续接口工作 + Request 创建新媒体镜像 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 镜像ID + Body { "error_code": 0, "message": "", "data":[ { "id": "sdf83kjfe-23r4wedf", } ] } ### 修改媒体镜像信息 [PUT /media_images/{id}] 修改媒体镜像信息 + Parameters + id (string) - 镜像ID + Request 修改媒体镜像信息 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除媒体镜像 [DELETE /media_images/{id}] 删除媒体镜像,清除关联文件数据 + Parameters + id (string) - 镜像ID + Request 删除媒体镜像 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 媒体镜像文件 [/media_image_files/{id}] 管理媒体镜像文件 + Parameters + id (string) - 镜像ID ### 下载媒体镜像文件 [GET] 下载二进制媒体镜像文件 + Response 200 (application/octet-stream) ### 上传媒体镜像文件 [POST] 上传ISO文件数据 + Request 上传媒体镜像文件 (multipart/form-data) -----BOUNDARY Content-Disposition: form-data; name="image"; filename="image.iso" -----BOUNDARY + Response 200 (application/json) [ { "error_code": 0, "message": "", } ] ## 磁盘镜像搜索 [/disk_image_search/{?tags}] 搜索磁盘镜像 + Parameters + tags (array[string], optional) - 镜像标签 ### 搜索磁盘镜像 [GET] 按照条件搜索磁盘镜像 + Request 搜索磁盘镜像 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (array[ImageStatus],fixed-type) - 镜像清单 + 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_images/] 管理磁盘镜像和文件 ### 同步本地磁盘镜像文件 [PATCH] 从Core模块的本地镜像文件存储路径读取并同步磁盘镜像数据 + Request 同步本地磁盘镜像文件 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 获取磁盘镜像状态 [GET /disk_images/{id}] 获取磁盘镜像状态 + Parameters + id (string) - 镜像ID + Request 获取磁盘镜像状态 + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (ImageStatus) - 镜像状态 + 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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (ImageStatus) - 镜像状态 + 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"] } } ### 创建磁盘镜像 [POST] 从源云主机系统磁盘克隆生成新镜像,如果没有指定云主机,则创建空白镜像用于后续上传 + Request 创建磁盘镜像 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 镜像ID + Body { "error_code": 0, "message": "", "data":[ { "id": "sdf83kjfe-23r4wedf", } ] } ### 修改磁盘镜像 [PUT /disk_images/{id}] 修改磁盘镜像信息 + Parameters + id (string) - 磁盘镜像ID + Request 修改磁盘镜像 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除磁盘镜像 [DELETE /disk_images/{id}] 删除镜像信息及磁盘文件 + Parameters + id (string) - 磁盘镜像ID + Request 删除磁盘镜像 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 磁盘镜像文件 [/disk_image_files/{id}] 管理磁盘镜像及文件 + Parameters + id (string) - 镜像ID ### 上传磁盘镜像文件 [POST] 上传二进制磁盘镜像文件数据,仅支持qcow2格式 + Request 上传磁盘镜像文件 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } # Group 系统维护 系统维护管理接口 ## 系统模板 [/templates/] 系统模板是用于选择云主机虚拟的一组硬件驱动和配置组合,便于管理员批量构建适合自己业务的硬件模板。 本接口提供系统模板管理和配置功能。 ### 查询系统模板 [GET] 查询所有可用系统模板 + Request 查询系统模板 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[TemplateBrief],fixed-type) - 模板清单 + 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 /templates/{id}] 获取模板配置详情 + Parameters + id (string) - 模板ID + Request 获取模板配置详情 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data (TemplateStatus) - 模板配置状态 + 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" } } ### 新建系统模板 [POST] 新建系统模板 + Request 新建系统模板 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 模板ID + Body { "error_code": 0, "message": "", "data": { "id": "1234-abcdef" } } ### 修改系统模板配置 [PUT /templates/{id}] 修改指定的系统模板配置 + Parameters + id (string) - 模板ID + Request 修改系统模板配置 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除系统模板 [DELETE /templates/{id}] 删除系统模板 + Parameters + id (string) - 模板ID + Request 删除系统模板 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 安全策略组 [/security_policy_groups/{id}] 多个安全策略规则组成一个安全策略组,创建云主机时选择对应策略组能够快速初始化安全策略 ### 获取安全策略组状态 [GET] 返回指定安全策略组的基本状态信息 + Parameters + id (string) - 策略组ID + Request 获取安全策略组状态 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(SecurityPolicyGroupStatus) - 策略组状态 + 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" } } ### 新建安全策略组 [POST /security_policy_groups/] 新建安全策略组 + Request 新建安全策略组 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 安全策略组ID + Body { "error_code": 0, "message": "", "data": { "id": "1234-abcdef" } } ### 修改安全策略组 [PUT] 修改策略组基本配置参数,使用该组创建的云主机不受影响 + Parameters + id (string) - 策略组ID + Request 修改安全策略组 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除安全策略组 [DELETE] 删除安全策略组,使用该组创建的云主机不受影响 + Parameters + id (string) - 策略组ID + Request 删除安全策略组 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 查询策略组规则 [GET /security_policy_groups/{id}/rules/] 返回某策略组包含的详细规则清单 + Parameters + id (string) - 策略组ID + Request 查询策略组规则 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[SecurityPolicyRule],fixed-type) - 规则清单 + 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" } ] } ### 添加策略组规则 [POST /security_policy_groups/{id}/rules/] 添加处理规则到指定策略组 + Parameters + id (string) - 策略组ID + Request 添加策略组规则 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 修改策略组规则 [PUT /security_policy_groups/{id}/rules/{index}] 修改指定规则 + Parameters + id (string) - 策略组ID + index (number) - 规则索引,从0开始 + Request 修改策略组规则 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 调整规则顺序 [PUT /security_policy_groups/{id}/rules/{index}/order] 安全规则从上往下匹配(从0开始),本接口调整指定规则的排列顺序,改变处理优先级 + Parameters + id (string) - 策略组ID + index (number) - 规则索引,从0开始 + Request 调整规则顺序 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + direction(enum[string]) - 移动方向 + Members + `up` - 上移 + `down` - 下移 + Body { "direction": "up" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ### 删除策略组规则 [DELETE /security_policy_groups/{id}/rules/{index}] 将指定规则从策略组中移除 + Parameters + id (string) - 策略组ID + index (number) - 规则索引,从0开始 + Request 删除策略组规则 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body { "error_code": 0, "message": "" } ## 云主机迁移 [/migrations/{id}] 主动迁移云主机,目前仅支持在同一资源池内的节点中迁移,需要后端存储支持 ### 启动迁移 [POST /migrations/] 指定迁移云主机和迁移目标,启动迁移任务 + Request 启动迁移 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + source_pool (string) - 需要迁移的云主机所在资源池 + source_cell (string) - 需要迁移的云主机所在资源节点 + target_pool (string, optional) - 需要迁移的目标资源池(尚未支持) + target_cell (string, optional) - 需要迁移的目标节点,未指定则均衡分配到池内各节点 + instances (array[string], optional) - 需要迁移的云主机ID清单,未指定则迁移该节点所有云主机 + 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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 迁移任务ID + Body [ { "error_code": 0, "message": "", "data":[ { "id": "abcdef-1234567890" } ] } ] ### 查询迁移任务状态 [GET] 查询指定迁移任务的当前状态 + Parameters + id (string) - 迁移任务ID + Request 查询迁移任务状态 + Headers Nano-session: 1234567890-abcdef + Response 201 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + finished(boolean) - 迁移是否完成 + progress(number,optional) - 迁移进度,0~100 + Body [ { "error_code": 0, "message": "", "data":{ "finished": false, "progress": 57 //limit to 100 } } ] + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + finished(boolean) - 迁移是否完成 + Body [ { "error_code": 0, "message": "", "data":{ "finished": true } } ] ### 查询所有处理中的迁移任务 [GET /migrations/] 查询所有处理中的迁移任务 + Request 查询所有处理中的迁移任务 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + id(string) - 迁移任务ID + finished(boolean) - 迁移是否完成 + progress(number,optional) - 迁移进度,0~100 + Body [ { "error_code": 0, "message": "", "data":[ { "id": "1234567890-abcdef", "finished": false, "progress": 57 //limit to 100 }, { "id": "1234567890-abcdef", "finished": true } ] } ] ## 批量创建云主机 [/batch/create_guest/{id}] 管理批量创建云主机任务 ### 启动批量创建 [POST /batch/create_guest/] 批量创建云主机,返回任务ID用于查询创建状态 + Request 启动批量创建 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + name_rule: `order` (enum[string]) - 批量生成云主机名称的规则 + Members + `order` - 前缀加递增序号,比如`xxx_0`, `xxx_1` + `MAC` - 按照MAC地址(尚未支持) + `address` - 按照指定的云主机地址(尚未支持) + name_prefix (string, optional) - 云主机名称前缀 + owner (string) - 创建用户ID + group (string) - 创建用户组 + pool (string) - 承载的计算资源池名称 + count (number) - 批量创建的云主机数量 + cores (number) - 每个云主机的核心数量 + memory (number) - 每个云主机的内存容量(字节) + disks (array[number],fixed-type) - [系统磁盘容量, 数据磁盘n的容量...] + auto_start (boolean) - 云主机是否随宿主机开机启动 + from_image (string, optional) - 克隆的源镜像ID,未指定则创建空白云主机 + template (string) - 系统模板ID + modules (array[string], optional) - 云主机预装的模块清单,"qemu"/"cloud-init" + cloud_init (CloudInit, optional) - Cloud-Init配置参数 + qos (QoS, optional) - QoS配置信息 + 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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 批处理任务ID + Body { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ### 查询批量创建任务状态 [GET] 查询批量创建任务的状态 + Parameters + id (string) - 任务ID + Request 查询批量创建任务状态 + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + name(string) - 云主机名 + id(string) - 创建中的云主机ID + progress(number,optional) - 创建进度,从0到100 + error(string,optional) - 创建失败时的错误信息 + status(enum[string]) - 任务状态 + 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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + name(string) - 云主机名 + id(string) - 创建中的云主机ID + error(string,optional) - 创建失败时的错误信息 + status(enum[string]) - 任务状态 + 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/delete_guest/{id}] 管理批量删除云主机任务 ### 启动批量删除 [POST /batch/delete_guest/] 同时删除多个云主机,返回任务ID用于查询状态 + Request 启动批量删除 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + guest (array[string],fixed-type) - 需要删除的云主机ID清单 + force (boolean, optional) - 是否强行终止运行中的云主机 + Body { "guest": [ "0123456789-abcdef-1", "0123456789-abcdef-2", "0123456789-abcdef-3" ], "force": false } + Response 202 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 批处理任务ID + Body [ { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ] ### 查询批量删除任务状态 [GET] 查询批量删除任务状态 + Parameters + id (string) - 批处理任务ID + Request 查询批量删除任务状态 + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + id(string) - 目标云主机ID + error(string,optional) - 删除失败时的错误信息 + status(enum[string]) - 任务状态 + 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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + id(string) - 目标云主机ID + error(string,optional) - 删除失败时的错误信息 + status(enum[string]) - 任务状态 + 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/stop_guest/{id}] 管理批量停止云主机任务 ### 启动批量停机 [POST /batch/stop_guest/] 同时停止多个云主机,返回任务ID用于查询状态 + Request 启动批量停机 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + guest (array[string],fixed-type) - 目标云主机ID清单 + Body { "guests": [ "0123456789-abcdef-1", "0123456789-abcdef-2", "0123456789-abcdef-3" ] } + Response 202 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + id (string) - 批量任务ID + Body [ { "error_code": 0, "message": "", "data":{ "id": "dsfds8979847r3dsf-3r67", } } ] ### 查询批量停机任务状态 [GET] 查询批量停机任务状态 + Parameters + id (string) - 批处理任务ID + Request 查询批量停机任务状态 + Headers Nano-session: 1234567890-abcdef + Response 202 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + id(string) - 目标云主机ID + error(string,optional) - 停机失败时的错误信息 + status(enum[string]) - 任务执行状态 + 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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + id(string) - 目标云主机ID + error(string,optional) - 停机失败时的错误信息 + status(enum[string]) - 任务执行状态 + Members + `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 资源搜索 资源搜索统一接口 ## 搜索安全策略组 [/search/security_policy_groups/{?enabled_only,global_only,owner,group}] 根据条件查询系统中的安全策略组 + Parameters + owner (string, optional) - 返回指定用户创建的安全组 + group (string, optional) - 返回指定用户组所属的安全组 + enabled_only (boolean, optional) - 仅返回启用中的安全组 + global_only (boolean, optional) - 仅返回全局可见的安全组 ### 查询安全策略组 [GET] 使用当前登录用户/所属组查询安全策略组 + Request 查询安全策略组 (application/json) + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[SecurityPolicyGroupStatus],fixed-type) - 安全策略组清单 + 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/] 按照指定条件搜索云主机,支持分页和模糊匹配 ### 搜索云主机 [POST] 使用已登录用户信息搜索云主机,关键词模糊匹配云主机名、IP或者承载资源节点 + Request 搜索云主机 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + limit (number) - 最大返回结果集数量 + offset (number,optional) - 返回结果集偏移地址 + pool(string,optional) - 承载计算资源池 + cell(string,optional) - 承载计算节点 + keyword(string,optional) - 搜索关键字,模糊匹配云主机名、IP,资源节点名称、IP + Body { "limit": 10, "offset": 20, "keyword": "example" } + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + result(array[InstanceStatus],fixed-type) - 云主机状态清单 + total(number) - 总结果集数量 + limit (number) - 最大返回结果集数量 + offset (number) - 返回结果集偏移地址 + 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管理接口 用于管理FrontEnd模块的统一API接口,包含用户权限管理、会话鉴权、操作日志等功能,FrontEnd使用RBAC模型管理用户权限。 ## 角色管理 [/roles/{role_name}] 管理系统管理员角色,角色允许关联多个菜单权限,每个用户组允许关联多个角色从而获得不同权限 ### 查询所有角色 [GET /roles/] 返回系统中所有用户角色 + Request 查询所有角色 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[string],optional) - 角色清单 + Body [ { "error_code": 0, "message": "", "data":[ "maintainer", "auditor", "user" ] } ] ### 查询角色配置信息 [GET] 获取指定角色目前拥有的权限状态 + Parameters + role_name (string) - 角色名称 + Request 查询角色配置信息 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + menu(array[string],optional) - 拥有的菜单权限标签清单 + Body [ { "error_code": 0, "message": "", "data":{ "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"] } } ] ### 添加角色 [POST] 新增系统角色 + Parameters + role_name (string) - 角色名称 + Request 添加角色 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + menu (array[string],fixed-type) - 角色拥有的菜单权限清单 + Body { "menu": ["dashboard", "compute_pool", "address_pool", "instance"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 修改角色权限 [PUT] 修改指定角色拥有的权限 + Parameters + role_name (string) - 角色名称 + Request Modify Role (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + menu (array[string],fixed-type) - 角色拥有的菜单权限清单 + Body { "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 删除角色 [DELETE] 从系统中删除指定角色,只能删除未关联任何用户的角色 + Parameters + role_name (string) - 角色名称 + Request Remove Role + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 用户组管理 [/user_groups/{group_name}] 用户组包含多个用户,每个用户组能够拥有多个角色,从而获得对应角色关联的权限集合 ### 查询所有用户组 [GET /user_groups/] 查询系统中所有的用户组 + Request 查询所有用户组 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array) + (object) + name(string) - 用户组名称 + display(string) - 用户组显示名称 + member(number) - 组内成员数量 + 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] 获取指定用户组详细信息 + Parameters + group_name (string) - 用户组名 + Request 查询用户组详情 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + name(string) - 用户组名称 + display(string) - 用户组显示名称 + role(array[string],fixed-type) - 关联的角色清单 + member(array[string],fixed-type) - 组成员清单 + Body [ { "error_code": 0, "message": "", "data":{ "name": "manager_group", "display": "Group of Manager", "role": ["manager", "user"], "member": [ "admin", "nano", "akumas" ] } } ] ### 添加用户组 [POST] 添加用户组 + Parameters + group_name (string) - 用户组名称 + Request 添加用户组 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + display (string) - 用户组显示名称 + role (array[string], optional) - 关联的角色清单 + Body { "display": "Group of Manager", "role": ["manager", "user"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 修改用户组 [PUT] 修改用户组关联权限 + Parameters + group_name (string) - 用户组名称 + Request 修改用户组 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + display (string) - 用户组显示名称 + role (array[string], optional) - 关联角色清单 + Body { "display": "Group of Manager", "role": ["manager", "user"] } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 删除用户组 [DELETE] 从系统中删除用户组 + Parameters + group_name (string) - 用户组名称 + Request 删除用户组 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 用户组成员 [/user_groups/{group_name}/members/{user_name}] 管理用户组成员 + Parameters + group_name (string) - 用户组名称 ### 查询用户组成员 [GET /user_groups/{group_name}/members/] 查询指定用户组的所有成员清单 + Request 查询用户组成员 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[string],fixed-type) - 成员名称清单 + Body [ { "error_code": 0, "message": "", "data":[ "admin", "nano", "akumas" ] } ] ### 添加用户组成员 [POST] 将新成员添加到用户组 + Parameters + user_name (string) - 用户名称 + Request 添加用户组成员 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 移除用户组成员 [DELETE] 从用户组中移除成员 + Parameters + user_name (string) - 用户名称 + Request 移除用户组成员 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 系统管理员 [/users/{user_name}] 管理系统管理员 ### 查询所有系统管理员 [GET /users/] 查询系统中所有用户清单 + Request 查询所有系统管理员 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[string],fixed-type) - 管理员清单 + Body [ { "error_code": 0, "message": "", "data":[ "admin", "nano", "akumas" ] } ] ### 获取管理员信息 [GET] 获取管理员信息 + Parameters + user_name (string) - 管理员名称 + Request 获取管理员信息 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + nick(string) - 昵称 + mail(string) - 邮件地址 + Body [ { "error_code": 0, "message": "", "data":{ "nick": "AK", "mail": "a@b.com" } } ] ### 新建管理员 [POST] 新建系统管理员 + Parameters + user_name (string) - 管理员名称 + Request Create New User (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + nick (string, optional) - 显示用昵称 + mail (string, optional) - 用户邮箱 + password (string) - 用户密码 + Body { "nick": "AK", "mail": "a@b.com", "password": "abcdefg" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 修改管理员信息 [PUT] 修改管理员信息 + Parameters + user_name (string) - 管理员名称 + Request 修改管理员信息 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + nick (string, optional) - 显示昵称 + mail (string, optional) - 用户邮箱 + Body { "nick": "AK", "mail": "a@b.com" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 删除系统管理员 [DELETE] 删除系统管理员 + Parameters + user_name (string) - 管理员名称 + Request 删除系统管理员 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 管理员密码 [/users/{user_name}/password/] 配置管理员密码 + Parameters + user_name (string) - 管理员名称 ### 修改管理员密码 [PUT] 校验并更新管理员密码 + Request Modify Password (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + old (string) - 验证用旧密码 + new (string) - 新密码 + Body { "old": "123456", "new": "abcdef" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 用户搜索接口 [/user_search/{?group}] 用户搜索接口 ### 搜索用户 [GET] 按组返回用户 + Parameters + group (string, optional) - 用户组 + Request Search Users + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data(array[string],fixed-type) - 管理员清单 + Body [ { "error_code": 0, "message": "", "data":[ "nano", "alex", "sam" ] } ] ## 会话管理 [/sessions/{session_id}] 会话鉴权、管理 ### 创建新会话 [POST /sessions/] 使用账号密码校验并分配新会话,将会话ID设置到HTTP头字段'Nano-Session'中,用于请求鉴权 + Request 创建新会话 (application/json) + Attributes + user (string) - 鉴权账号名 + password (string) - 鉴权密码 + nonce (string) - 加密用随机字符串 + Body { "user": "alex", "password": "abcdef", "nonce": "1234567890" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + session(string) - 分配的会话ID + timeout(number) - 会话超时时间(秒) + Body [ { "error_code": 0, "message": "", "data":{ "session": "bsu6384js3=", "timeout": 120 } } ] ### 更新会话 [PUT] 更新会话,使其保持会话处于活动状态 + Parameters + session_id (string) - 会话ID + Request 会话保活 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 获取已校验会话信息 [GET] 查询已校验会话的关联绑定信息 + Parameters + session_id (string) - 会话ID + Request 获取已校验会话信息 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + user(string) - 已认证用户名 + group(string) - 已认证用户组 + address(string) - 请求会话的客户端IP + menu(array[string],optional) - 授权的菜单权限清单 + resource(array[string],optional) - 已分配资源清单 + Body [ { "error_code": 0, "message": "", "data":{ "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"], "resource": [], "user": "nano", "group": "admin", "address": "192.168.1.100" } } ] ## 资源可见性 [/resource_visibilities/] 管理已登录用户相关的资源可见性配置 ### 查询资源可见性 [GET] 获取当前用户的资源可见性配置 + Request 查询资源可见性 + 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 } } ] ### 设置资源可见性 [PUT] 修改当前登录用户关联的资源可见性配置 + Request 设置资源可见性 (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) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ## 操作日志 [/logs/{?limit,start,after,before}] 平台操作日志管理接口 ### 查询日志清单 [GET] 根据条件查询系统操作日志 + Parameters + limit (number) - 最大返回日志数量 + start (number, optional) - 日志查询偏移 + after (string, optional) - 查询本日期之后的日志 + before (string, optional) - 查询本日期之前的日志 + Request 查询日志清单 + Headers Nano-session: 1234567890-abcdef + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + data + logs(array) + (object) + id(string) - 日志ID + time(string) - 日志时间戳,格式:`YYYY-MM-DD HH:MI:SS` + content(string) - 日志内容 + total(number) - 总日志数量 + 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 } } ] ### 添加操作日志 [POST] 添加单条操作日志 + Request 添加操作日志 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + format (string, optional) - 日志格式 + content (string) - 日志内容 + Body { "format": "string", "content": "here is a new log for somebody creating a new instance" } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ] ### 删除操作日志 [DELETE] 删除操作日志 + Request 删除操作日志 (application/json) + Headers Nano-session: 1234567890-abcdef + Attributes + entries (array[string],fixed-type) - 需要删除的日志ID清单 + Body { "entries": [ "201812011457390001", "201812031427190001" ] } + Response 200 (application/json) + Attributes (object) + error_code (number) - 错误编码,0为成功 + message (string,optional) - 错误信息,成功时为空 + Body [ { "error_code": 0, "message": "" } ]