Back to top

FrontEnd API (Project Nano)

本文档定义由Nano的FrontEnd模块提供的RESTful API接口,API服务默认监听端口为5870。

本文档内容对应版本1.3.1

调用文中绝大部分接口前,需要通过会话管理接口,首先分配一个授权会话,并将会话ID设置在HTTP请求头的’Nano-Session’字段,用于请求鉴权。

资源池

管理资源池接口

计算资源池

管理计算资源池

获取所有计算资源池
GET/compute_pools/

查询当前域内所有计算资源池

Example URI

GET http://nanos.cloud/api/v1/compute_pools/
Request  获取所有计算资源池
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
    }
]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "storage": {
            "type": "string",
            "description": "使用的存储池名称,不指定则使用本地存储(默认)"
          },
          "network": {
            "type": "string",
            "description": "使用的地址池名称,不指定则使用桥接模式(默认,云主机通过物理网络获取IP地址)"
          },
          "failover": {
            "type": "boolean",
            "description": "是否启用故障切换(需要共享存储,默认关闭)"
          },
          "name": {
            "type": "string",
            "description": "资源池名称"
          },
          "enabled": {
            "type": "boolean",
            "description": "是否启用"
          },
          "cells": {
            "type": "number",
            "description": "已经添加到的资源节点数量"
          }
        }
      },
      "description": "资源池状态清单"
    }
  }
}

获取计算资源池状态
GET/compute_pools/{pool}

获取单个计算资源池状态

Example URI

GET http://nanos.cloud/api/v1/compute_pools/pool
URI Parameters
HideShow
pool
string (required) 

资源池名称

Request  获取计算资源池状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data": {
    "name": "default",
    "enabled": true,
    "cells": 10,
    "storage": "some_cluster",
    "network": "address_pool1",
    "failover": true
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "storage": {
          "type": "string",
          "description": "使用的存储池名称,不指定则使用本地存储(默认)"
        },
        "network": {
          "type": "string",
          "description": "使用的地址池名称,不指定则使用桥接模式(默认,云主机通过物理网络获取IP地址)"
        },
        "failover": {
          "type": "boolean",
          "description": "是否启用故障切换(需要共享存储,默认关闭)"
        },
        "name": {
          "type": "string",
          "description": "资源池名称"
        },
        "enabled": {
          "type": "boolean",
          "description": "是否启用"
        },
        "cells": {
          "type": "number",
          "description": "已经添加到的资源节点数量"
        }
      },
      "description": "计算资源池状态"
    }
  }
}

创建新计算资源池
POST/compute_pools/{pool}

创建一个新的计算资源池

Example URI

POST http://nanos.cloud/api/v1/compute_pools/pool
URI Parameters
HideShow
pool
string (required) 

资源池名称

Request  创建新计算资源池
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
[
  {
    "storage": "some_cephcluster",
    "network": "address_pool1",
    "failover": true
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "storage": {
      "type": "string",
      "description": "使用的存储池名称,不指定则使用本地存储(默认)"
    },
    "network": {
      "type": "string",
      "description": "使用的地址池名称,不指定则使用桥接模式(默认,云主机通过物理网络获取IP地址)"
    },
    "failover": {
      "type": "boolean",
      "description": "是否启用故障切换(需要共享存储,默认关闭)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除计算资源池
DELETE/compute_pools/{pool}

删除一个空的计算资源池

Example URI

DELETE http://nanos.cloud/api/v1/compute_pools/pool
URI Parameters
HideShow
pool
string (required) 

资源池名称

Request  删除计算资源池
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改计算资源池
PUT/compute_pools/{pool}

修改计算资源池配置

Example URI

PUT http://nanos.cloud/api/v1/compute_pools/pool
URI Parameters
HideShow
pool
string (required) 

计算资源池名称

Request  修改计算资源池
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
[
  {
    "failover": true,
    "storage": "nfs-poo1"
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "storage": {
      "type": "string",
      "description": "使用的存储池名称,不指定则使用本地存储(默认)"
    },
    "network": {
      "type": "string",
      "description": "使用的地址池名称,不指定则使用桥接模式(默认,云主机通过物理网络获取IP地址)"
    },
    "failover": {
      "type": "boolean",
      "description": "是否启用故障切换(需要共享存储,默认关闭)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

计算资源节点

管理资源池中节点

查询未分配节点
GET/compute_pool_cells/

查询尚未加入计算资源池的资源节点

Example URI

GET http://nanos.cloud/api/v1/compute_pool_cells/
Request  查询未分配节点
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "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}

查询已经绑定资源池的所有资源节点

Example URI

GET http://nanos.cloud/api/v1/compute_pool_cells/pool
URI Parameters
HideShow
pool
string (required) 

计算资源池名称

Request  查询池内资源节点
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "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}

将新资源节点添加到计算资源池

Example URI

POST http://nanos.cloud/api/v1/compute_pool_cells/pool/cell
URI Parameters
HideShow
pool
string (required) 

资源池名称

cell
string (required) 

资源节点名称

Request  添加资源节点
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

移除资源节点
DELETE/compute_pool_cells/{pool}/{cell}

将一个资源节点从计算资源池中移除,仅能移除未分配云主机的资源节点

Example URI

DELETE http://nanos.cloud/api/v1/compute_pool_cells/pool/cell
URI Parameters
HideShow
pool
string (required) 

资源池名称

cell
string (required) 

资源节点名称

Request  移除资源节点
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改资源节点
PUT/compute_pool_cells/{pool}/{cell}

变更资源节点状态

Example URI

PUT http://nanos.cloud/api/v1/compute_pool_cells/pool/cell
URI Parameters
HideShow
pool
string (required) 

资源池名称

cell
string (required) 

资源节点名称

Request  修改资源节点
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "enable": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "enable": {
      "type": "boolean",
      "description": "启用节点,禁用节点不会分配新的云主机"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

获取资源节点状态
GET/compute_pool_cells/{pool}/{cell}

获取资源节点当前状态

Example URI

GET http://nanos.cloud/api/v1/compute_pool_cells/pool/cell
URI Parameters
HideShow
pool
string (required) 

资源池名称

cell
string (required) 

资源节点名称

Request  获取资源节点状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "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"
        }
      ]
    }
  }
]

存储资源池

管理存储资源池

查询所有存储资源池
GET/storage_pools/

查询所有存储资源池的配置

Example URI

GET http://nanos.cloud/api/v1/storage_pools/
Request  查询所有存储资源池
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "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}

获取单个存储资源池的配置信息

Example URI

GET http://nanos.cloud/api/v1/storage_pools/pool
URI Parameters
HideShow
pool
string (required) 

存储资源池名称

Request  获取存储资源池配置
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "type": "nfs",
      "host": "nfs.nano.com",
      "target": "/var/nano/pool1"
    }
  }
]

新建存储资源池
POST/storage_pools/{pool}

新建一个存储资源池

Example URI

POST http://nanos.cloud/api/v1/storage_pools/pool
URI Parameters
HideShow
pool
string (required) 

存储资源池名称

Request  新建存储资源池
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "type": "nfs",
  "host": "nfs.nano.com",
  "target": "/var/nano/pool1"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "nfs"
      ],
      "default": "nfs",
      "description": "后端存储类型"
    },
    "host": {
      "type": "string",
      "description": "存储主机的IP或者域名"
    },
    "target": {
      "type": "string",
      "description": "存储主机的路径"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改存储资源池
PUT/storage_pools/{pool}

修改存储资源池配置,仅用于未承载云主机数据的空存储池

Example URI

PUT http://nanos.cloud/api/v1/storage_pools/pool
URI Parameters
HideShow
pool
string (required) 

存储资源池名称

Request  修改存储资源池
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "type": "nfs",
  "host": "another_nfs.nano.com",
  "target": "/var/nano/new_location"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "nfs"
      ],
      "default": "nfs",
      "description": "后端存储类型"
    },
    "host": {
      "type": "string",
      "description": "存储主机的IP或者域名"
    },
    "target": {
      "type": "string",
      "description": "存储主机的路径"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除存储资源池
DELETE/storage_pools/{pool}

删除存储资源池,仅用于未承载云主机数据的空存储池

Example URI

DELETE http://nanos.cloud/api/v1/storage_pools/pool
URI Parameters
HideShow
pool
string (required) 

存储资源池名称

Request  Delete Storage Pool
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

计算域状态

采集域内所有资源用量和运行状态

查询域状态
GET/compute_zone_status/

查询全域最新状态

Example URI

GET http://nanos.cloud/api/v1/compute_zone_status/
Request  查询域状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
}
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "数据源名称"
        },
        "cpu_usage": {
          "type": "number",
          "description": "总使用核心数"
        },
        "max_cpu": {
          "type": "number",
          "description": "总核心数"
        },
        "available_memory": {
          "type": "number",
          "description": "总可用内存数量(字节)"
        },
        "max_memory": {
          "type": "number",
          "description": "总内存数量(字节)"
        },
        "available_disk": {
          "type": "number",
          "description": "总可用磁盘数量(字节)"
        },
        "max_disk": {
          "type": "number",
          "description": "总磁盘数量(字节)"
        },
        "read_speed": {
          "type": "number",
          "description": "磁盘读取速度(字节/秒)"
        },
        "write_speed": {
          "type": "number",
          "description": "磁盘写入速度(字节/秒)"
        },
        "receive_speed": {
          "type": "number",
          "description": "网络接收速度(字节/秒)"
        },
        "send_speed": {
          "type": "number",
          "description": "网络发送速度(字节/秒)"
        },
        "pools": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[禁用资源池数量, 启用资源池数量]"
        },
        "cells": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[离线节点数量, 在线节点数量]"
        },
        "instances": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[停止实例数量, 运行实例数量, 实例实例数量, 迁移实例数量]"
        },
        "start_time": {
          "type": "string",
          "description": "系统启动时间,格式:'YYYY-MM-DD HH:MI:SS'"
        }
      },
      "description": "统计状态"
    }
  }
}

计算资源池状态

采集计算资源池状态

查询所有计算资源池状态
GET/compute_pool_status/

查询统计域内所有计算资源池状态和用量

Example URI

GET http://nanos.cloud/api/v1/compute_pool_status/
Request  查询所有计算资源池状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
  }]
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "数据源名称"
          },
          "cpu_usage": {
            "type": "number",
            "description": "总使用核心数"
          },
          "max_cpu": {
            "type": "number",
            "description": "总核心数"
          },
          "available_memory": {
            "type": "number",
            "description": "总可用内存数量(字节)"
          },
          "max_memory": {
            "type": "number",
            "description": "总内存数量(字节)"
          },
          "available_disk": {
            "type": "number",
            "description": "总可用磁盘数量(字节)"
          },
          "max_disk": {
            "type": "number",
            "description": "总磁盘数量(字节)"
          },
          "read_speed": {
            "type": "number",
            "description": "磁盘读取速度(字节/秒)"
          },
          "write_speed": {
            "type": "number",
            "description": "磁盘写入速度(字节/秒)"
          },
          "receive_speed": {
            "type": "number",
            "description": "网络接收速度(字节/秒)"
          },
          "send_speed": {
            "type": "number",
            "description": "网络发送速度(字节/秒)"
          },
          "enabled": {
            "type": "boolean",
            "description": "资源池是否启用"
          },
          "cells": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[离线节点数量, 在线节点数量]"
          },
          "instances": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[停止实例数量, 运行实例数量, 实例实例数量, 迁移实例数量]"
          }
        }
      },
      "description": "统计状态清单"
    }
  }
}

获取单个计算资源池状态
GET/compute_pool_status/{pool}

采集和统计某个计算资源池的状态和资源用量

Example URI

GET http://nanos.cloud/api/v1/compute_pool_status/pool
URI Parameters
HideShow
pool
string (required) 

计算资源池名称

Request  获取单个计算资源池状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "数据源名称"
        },
        "cpu_usage": {
          "type": "number",
          "description": "总使用核心数"
        },
        "max_cpu": {
          "type": "number",
          "description": "总核心数"
        },
        "available_memory": {
          "type": "number",
          "description": "总可用内存数量(字节)"
        },
        "max_memory": {
          "type": "number",
          "description": "总内存数量(字节)"
        },
        "available_disk": {
          "type": "number",
          "description": "总可用磁盘数量(字节)"
        },
        "max_disk": {
          "type": "number",
          "description": "总磁盘数量(字节)"
        },
        "read_speed": {
          "type": "number",
          "description": "磁盘读取速度(字节/秒)"
        },
        "write_speed": {
          "type": "number",
          "description": "磁盘写入速度(字节/秒)"
        },
        "receive_speed": {
          "type": "number",
          "description": "网络接收速度(字节/秒)"
        },
        "send_speed": {
          "type": "number",
          "description": "网络发送速度(字节/秒)"
        },
        "enabled": {
          "type": "boolean",
          "description": "资源池是否启用"
        },
        "cells": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[离线节点数量, 在线节点数量]"
        },
        "instances": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[停止实例数量, 运行实例数量, 实例实例数量, 迁移实例数量]"
        }
      },
      "description": "统计状态"
    }
  }
}

计算资源节点状态

获取和采集计算资源节点的状态和用量

查询池内资源节点状态
GET/compute_cell_status/{pool}/

采集某个资源池内所有资源节点的状态和资源用量

Example URI

GET http://nanos.cloud/api/v1/compute_cell_status/pool/
URI Parameters
HideShow
pool
string (required) 

目标节点名称

Request  查询池内资源节点状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
    }
  ]
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "数据源名称"
          },
          "cpu_usage": {
            "type": "number",
            "description": "总使用核心数"
          },
          "max_cpu": {
            "type": "number",
            "description": "总核心数"
          },
          "available_memory": {
            "type": "number",
            "description": "总可用内存数量(字节)"
          },
          "max_memory": {
            "type": "number",
            "description": "总内存数量(字节)"
          },
          "available_disk": {
            "type": "number",
            "description": "总可用磁盘数量(字节)"
          },
          "max_disk": {
            "type": "number",
            "description": "总磁盘数量(字节)"
          },
          "read_speed": {
            "type": "number",
            "description": "磁盘读取速度(字节/秒)"
          },
          "write_speed": {
            "type": "number",
            "description": "磁盘写入速度(字节/秒)"
          },
          "receive_speed": {
            "type": "number",
            "description": "网络接收速度(字节/秒)"
          },
          "send_speed": {
            "type": "number",
            "description": "网络发送速度(字节/秒)"
          },
          "address": {
            "type": "string",
            "description": "资源节点地址"
          },
          "enabled": {
            "type": "boolean",
            "description": "节点是否启用"
          },
          "alive": {
            "type": "boolean",
            "description": "节点是否在线"
          }
        }
      },
      "description": "统计状态清单"
    }
  }
}

获取单个资源节点状态
GET/compute_cell_status/{cell}

采集某个资源节点的状态和资源用量

Example URI

GET http://nanos.cloud/api/v1/compute_cell_status/cell
URI Parameters
HideShow
cell
string (required) 

目标节点名称

Request  获取单个资源节点状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "数据源名称"
        },
        "cpu_usage": {
          "type": "number",
          "description": "总使用核心数"
        },
        "max_cpu": {
          "type": "number",
          "description": "总核心数"
        },
        "available_memory": {
          "type": "number",
          "description": "总可用内存数量(字节)"
        },
        "max_memory": {
          "type": "number",
          "description": "总内存数量(字节)"
        },
        "available_disk": {
          "type": "number",
          "description": "总可用磁盘数量(字节)"
        },
        "max_disk": {
          "type": "number",
          "description": "总磁盘数量(字节)"
        },
        "read_speed": {
          "type": "number",
          "description": "磁盘读取速度(字节/秒)"
        },
        "write_speed": {
          "type": "number",
          "description": "磁盘写入速度(字节/秒)"
        },
        "receive_speed": {
          "type": "number",
          "description": "网络接收速度(字节/秒)"
        },
        "send_speed": {
          "type": "number",
          "description": "网络发送速度(字节/秒)"
        },
        "address": {
          "type": "string",
          "description": "资源节点地址"
        },
        "enabled": {
          "type": "boolean",
          "description": "节点是否启用"
        },
        "alive": {
          "type": "boolean",
          "description": "节点是否在线"
        }
      },
      "description": "统计状态"
    }
  }
}

资源节点存储配置

管理资源节点的本地存储配置

查询资源节点存储信息
GET/compute_cell_status/{pool}/{cell}/storages/

获取某个资源节点的存储路径配置

Example URI

GET http://nanos.cloud/api/v1/compute_cell_status/pool/cell/storages/
URI Parameters
HideShow
pool
string (required) 

计算资源池名称

cell
string (required) 

计算节点名称

Request  查询资源节点存储信息
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data":{
    "mode": "local",
    "system": [
        "/var/lib/libvirt/images/"
    ],
    "data": [
        "/var/lib/libvirt/images/"
    ],
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "local",
            "nfs",
            "ceph"
          ],
          "default": "local",
          "description": "Cell存储模式"
        },
        "system": {
          "type": "array",
          "description": "云主机的系统磁盘文件存储路径,仅用于本地存储模式"
        },
        "data": {
          "type": "array",
          "description": "云主机的数据磁盘文件存储路径,仅用于本地存储模式"
        }
      },
      "description": "存储配置"
    }
  }
}

修改资源节点存储路径
PUT/compute_cell_status/{pool}/{cell}/storages/

修改资源节点存储路径

Example URI

PUT http://nanos.cloud/api/v1/compute_cell_status/pool/cell/storages/
URI Parameters
HideShow
pool
string (required) 

计算资源池名称

cell
string (required) 

计算节点名称

Request  修改资源节点存储路径
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "default": "/var/lib/libvirt/images/"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "default": {
      "type": "string",
      "description": "默认存储路径"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

实例状态

查询云主机实例状态

资源池内实例状态
GET/instance_status/{pool}/

查询资源池内所有的云主机实例状态

Example URI

GET http://nanos.cloud/api/v1/instance_status/pool/
URI Parameters
HideShow
pool
string (required) 

name of target pool

Request  查询资源池内云主机实例状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "云主机名"
          },
          "owner": {
            "type": "string",
            "description": "用户ID"
          },
          "group": {
            "type": "string",
            "description": "用户组"
          },
          "pool": {
            "type": "string",
            "description": "计算资源池名称"
          },
          "cores": {
            "type": "number",
            "description": "核心数量"
          },
          "memory": {
            "type": "number",
            "description": "内存容量(字节)"
          },
          "disks": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
          },
          "auto_start": {
            "type": "boolean",
            "description": "云主机实例是否随宿主机开机启动"
          },
          "system": {
            "type": "string",
            "description": "云主机系统ID"
          },
          "network_address": {
            "type": "string",
            "description": "指定云主机IP(可选),尚未支持"
          },
          "ethernet_address": {
            "type": "string",
            "description": "指定云主机MAC地址(可选),尚未支持"
          },
          "from_image": {
            "type": "string",
            "description": "克隆时使用的源磁盘镜像ID"
          },
          "ports": {
            "type": "array",
            "description": "需要开放的映射端口清单,尚未支持"
          },
          "template": {
            "type": "string",
            "description": "系统模板ID"
          },
          "modules": {
            "type": "array",
            "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
          },
          "cloud_init": {
            "type": "object",
            "properties": {
              "root_enabled": {
                "type": "boolean",
                "description": "允许root用户通过SSH远程登录,默认启用"
              },
              "admin_name": {
                "type": "string",
                "description": "指定超级管理员用户名,不指定则使用'root'"
              },
              "admin_secret": {
                "type": "string",
                "description": "超级管理员明码,不指定则由nano生成安全密码"
              },
              "data_path": {
                "type": "string",
                "description": "数据磁盘挂载路径,默认为`/opt/data`"
              }
            },
            "description": "Cloud-Init参数"
          },
          "qos": {
            "type": "object",
            "properties": {
              "cpu_priority": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ],
                "default": "medium",
                "description": "CPU优先级"
              },
              "write_speed": {
                "type": "number",
                "description": "磁盘写入限速(字节/每秒),0 = 无限制"
              },
              "write_iops": {
                "type": "number",
                "description": "磁盘写入限速(操作/每秒),0 = 无限制"
              },
              "read_speed": {
                "type": "number",
                "description": "磁盘读取限速(字节/每秒),0 = 无限制"
              },
              "read_iops": {
                "type": "number",
                "description": "磁盘读取限速(操作/每秒),0 = 无限制"
              },
              "receive_speed": {
                "type": "number",
                "description": "网络接收限速(字节/每秒),0 = 无限制"
              },
              "send_speed": {
                "type": "number",
                "description": "网络发送限速(字节/每秒),0 = 无限制"
              }
            },
            "description": "QoS配置"
          },
          "security_policy_group": {
            "type": "string",
            "description": "使用的安全策略组ID"
          },
          "id": {
            "type": "string",
            "description": "云主机ID"
          },
          "created": {
            "type": "boolean",
            "description": "是否已创建"
          },
          "running": {
            "type": "boolean",
            "description": "是否运行中"
          },
          "cell": {
            "type": "string",
            "description": "承载资源节点名"
          },
          "host": {
            "type": "string",
            "description": "承载资源节点地址"
          },
          "lost": {
            "type": "boolean",
            "description": "云主机是否失联"
          },
          "monitor_secret": {
            "type": "string",
            "description": "监控密码"
          },
          "display_protocol": {
            "type": "string",
            "description": "监控协议"
          },
          "total_disk": {
            "type": "number",
            "description": "总磁盘容量,以字节计算"
          },
          "progress": {
            "type": "number",
            "description": "创建进度,0~100"
          },
          "create_time": {
            "type": "string",
            "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
          },
          "internal": {
            "type": "object",
            "properties": {
              "network_address": {
                "type": "string",
                "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
              },
              "display_address": {
                "type": "string",
                "description": "云主机监控地址,格式为'主机:端口'"
              },
              "allocated_address": {
                "type": "string",
                "description": "系统通过管理地址池为云主机分配的地址"
              }
            },
            "description": "内部网口状态"
          },
          "external": {
            "type": "object",
            "properties": {
              "network_address": {
                "type": "string",
                "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
              },
              "display_address": {
                "type": "string",
                "description": "云主机监控地址,格式为'主机:端口'"
              },
              "allocated_address": {
                "type": "string",
                "description": "系统通过管理地址池为云主机分配的地址"
              }
            },
            "description": "外部网口状态"
          },
          "cpu_usage": {
            "type": "number",
            "description": "总CPU使用率,0.00 ~ 100.00"
          },
          "memory_available": {
            "type": "number",
            "description": "可用内存容量(字节)"
          },
          "disk_available": {
            "type": "number",
            "description": "可用磁盘容量(字节)"
          },
          "bytes_read": {
            "type": "number",
            "description": "总磁盘读取字节数"
          },
          "bytes_written": {
            "type": "number",
            "description": "总磁盘写入字节数"
          },
          "bytes_received": {
            "type": "number",
            "description": "总网络接收字节数"
          },
          "bytes_sent": {
            "type": "number",
            "description": "总网络发送字节数"
          },
          "media_attached": {
            "type": "boolean",
            "description": "是否已挂载光盘镜像"
          },
          "media_source": {
            "type": "string",
            "description": "挂载光盘镜像ID"
          }
        }
      },
      "description": "状态清单"
    }
  }
}

节点内实例状态
GET/instance_status/{cell}/

查询指定资源节点承载的云主机实例状态

Example URI

GET http://nanos.cloud/api/v1/instance_status/cell/
URI Parameters
HideShow
cell
string (required) 

目标节点名称

Request  查询节点内实例状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "云主机名"
          },
          "owner": {
            "type": "string",
            "description": "用户ID"
          },
          "group": {
            "type": "string",
            "description": "用户组"
          },
          "pool": {
            "type": "string",
            "description": "计算资源池名称"
          },
          "cores": {
            "type": "number",
            "description": "核心数量"
          },
          "memory": {
            "type": "number",
            "description": "内存容量(字节)"
          },
          "disks": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
          },
          "auto_start": {
            "type": "boolean",
            "description": "云主机实例是否随宿主机开机启动"
          },
          "system": {
            "type": "string",
            "description": "云主机系统ID"
          },
          "network_address": {
            "type": "string",
            "description": "指定云主机IP(可选),尚未支持"
          },
          "ethernet_address": {
            "type": "string",
            "description": "指定云主机MAC地址(可选),尚未支持"
          },
          "from_image": {
            "type": "string",
            "description": "克隆时使用的源磁盘镜像ID"
          },
          "ports": {
            "type": "array",
            "description": "需要开放的映射端口清单,尚未支持"
          },
          "template": {
            "type": "string",
            "description": "系统模板ID"
          },
          "modules": {
            "type": "array",
            "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
          },
          "cloud_init": {
            "type": "object",
            "properties": {
              "root_enabled": {
                "type": "boolean",
                "description": "允许root用户通过SSH远程登录,默认启用"
              },
              "admin_name": {
                "type": "string",
                "description": "指定超级管理员用户名,不指定则使用'root'"
              },
              "admin_secret": {
                "type": "string",
                "description": "超级管理员明码,不指定则由nano生成安全密码"
              },
              "data_path": {
                "type": "string",
                "description": "数据磁盘挂载路径,默认为`/opt/data`"
              }
            },
            "description": "Cloud-Init参数"
          },
          "qos": {
            "type": "object",
            "properties": {
              "cpu_priority": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ],
                "default": "medium",
                "description": "CPU优先级"
              },
              "write_speed": {
                "type": "number",
                "description": "磁盘写入限速(字节/每秒),0 = 无限制"
              },
              "write_iops": {
                "type": "number",
                "description": "磁盘写入限速(操作/每秒),0 = 无限制"
              },
              "read_speed": {
                "type": "number",
                "description": "磁盘读取限速(字节/每秒),0 = 无限制"
              },
              "read_iops": {
                "type": "number",
                "description": "磁盘读取限速(操作/每秒),0 = 无限制"
              },
              "receive_speed": {
                "type": "number",
                "description": "网络接收限速(字节/每秒),0 = 无限制"
              },
              "send_speed": {
                "type": "number",
                "description": "网络发送限速(字节/每秒),0 = 无限制"
              }
            },
            "description": "QoS配置"
          },
          "security_policy_group": {
            "type": "string",
            "description": "使用的安全策略组ID"
          },
          "id": {
            "type": "string",
            "description": "云主机ID"
          },
          "created": {
            "type": "boolean",
            "description": "是否已创建"
          },
          "running": {
            "type": "boolean",
            "description": "是否运行中"
          },
          "cell": {
            "type": "string",
            "description": "承载资源节点名"
          },
          "host": {
            "type": "string",
            "description": "承载资源节点地址"
          },
          "lost": {
            "type": "boolean",
            "description": "云主机是否失联"
          },
          "monitor_secret": {
            "type": "string",
            "description": "监控密码"
          },
          "display_protocol": {
            "type": "string",
            "description": "监控协议"
          },
          "total_disk": {
            "type": "number",
            "description": "总磁盘容量,以字节计算"
          },
          "progress": {
            "type": "number",
            "description": "创建进度,0~100"
          },
          "create_time": {
            "type": "string",
            "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
          },
          "internal": {
            "type": "object",
            "properties": {
              "network_address": {
                "type": "string",
                "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
              },
              "display_address": {
                "type": "string",
                "description": "云主机监控地址,格式为'主机:端口'"
              },
              "allocated_address": {
                "type": "string",
                "description": "系统通过管理地址池为云主机分配的地址"
              }
            },
            "description": "内部网口状态"
          },
          "external": {
            "type": "object",
            "properties": {
              "network_address": {
                "type": "string",
                "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
              },
              "display_address": {
                "type": "string",
                "description": "云主机监控地址,格式为'主机:端口'"
              },
              "allocated_address": {
                "type": "string",
                "description": "系统通过管理地址池为云主机分配的地址"
              }
            },
            "description": "外部网口状态"
          },
          "cpu_usage": {
            "type": "number",
            "description": "总CPU使用率,0.00 ~ 100.00"
          },
          "memory_available": {
            "type": "number",
            "description": "可用内存容量(字节)"
          },
          "disk_available": {
            "type": "number",
            "description": "可用磁盘容量(字节)"
          },
          "bytes_read": {
            "type": "number",
            "description": "总磁盘读取字节数"
          },
          "bytes_written": {
            "type": "number",
            "description": "总磁盘写入字节数"
          },
          "bytes_received": {
            "type": "number",
            "description": "总网络接收字节数"
          },
          "bytes_sent": {
            "type": "number",
            "description": "总网络发送字节数"
          },
          "media_attached": {
            "type": "boolean",
            "description": "是否已挂载光盘镜像"
          },
          "media_source": {
            "type": "string",
            "description": "挂载光盘镜像ID"
          }
        }
      },
      "description": "状态清单"
    }
  }
}

地址资源池

配置可用地址资源,分配给云主机

地址资源池清单
GET/address_pools/

查询系统内所有地址池资源池

Example URI

GET http://nanos.cloud/api/v1/address_pools/
Request  查询系统内所有地址池资源池
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "地址池名称"
          },
          "gateway": {
            "type": "string",
            "description": "网关地址"
          },
          "provider": {
            "type": "string",
            "enum": [
              "dhcp",
              "cloudinit"
            ],
            "default": "dhcp",
            "description": "地址配置方式"
          },
          "mode": {
            "type": "string",
            "enum": [
              "internal",
              "external",
              "both"
            ],
            "default": "internal",
            "description": "网口模式"
          },
          "addresses": {
            "type": "number",
            "description": "总地址数量"
          },
          "allocated": {
            "type": "number",
            "description": "已分配地址数量"
          }
        }
      },
      "description": "地址池清单"
    }
  }
}

获取地址池状态
GET/address_pools/{name}

获取地址池状态

Example URI

GET http://nanos.cloud/api/v1/address_pools/name
URI Parameters
HideShow
name
string (required) 

地址池名称

Request  获取地址池状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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",
      }
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "地址池名称"
        },
        "gateway": {
          "type": "string",
          "description": "网关地址"
        },
        "provider": {
          "type": "string",
          "enum": [
            "dhcp",
            "cloudinit"
          ],
          "default": "dhcp",
          "description": "地址配置方式"
        },
        "mode": {
          "type": "string",
          "enum": [
            "internal",
            "external",
            "both"
          ],
          "default": "internal",
          "description": "网口模式"
        },
        "ranges": {
          "type": "array",
          "description": "地址范围清单"
        },
        "allocated": {
          "type": "array",
          "description": "已分配地址清单"
        }
      },
      "description": "状态信息"
    }
  }
}

创建新地址池
POST/address_pools/{name}

创建新地址池,用于云主机分配地址

Example URI

POST http://nanos.cloud/api/v1/address_pools/name
URI Parameters
HideShow
name
string (required) 

地址池名称

Request  创建新地址池
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "gateway": "172.16.3.254",
  "dns": [
    "8.8.8.8",
    "10.10.10.10"
  ],
  "provider": "cloudinit",
  "mode": "external"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "地址池名称"
    },
    "gateway": {
      "type": "string",
      "description": "网关地址"
    },
    "provider": {
      "type": "string",
      "enum": [
        "dhcp",
        "cloudinit"
      ],
      "default": "dhcp",
      "description": "地址配置方式"
    },
    "mode": {
      "type": "string",
      "enum": [
        "internal",
        "external",
        "both"
      ],
      "default": "internal",
      "description": "网口模式"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改地址池
PUT/address_pools/{name}

修改地址池配置信息

Example URI

PUT http://nanos.cloud/api/v1/address_pools/name
URI Parameters
HideShow
name
string (required) 

地址池信息

Request  修改地址池配置
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "gateway": "172.16.3.254",
  "dns": [
    "8.8.8.8",
    "10.10.10.10"
  ],
  "provider": "dhcp",
  "mode": "both"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "地址池名称"
    },
    "gateway": {
      "type": "string",
      "description": "网关地址"
    },
    "provider": {
      "type": "string",
      "enum": [
        "dhcp",
        "cloudinit"
      ],
      "default": "dhcp",
      "description": "地址配置方式"
    },
    "mode": {
      "type": "string",
      "enum": [
        "internal",
        "external",
        "both"
      ],
      "default": "internal",
      "description": "网口模式"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除地址池
DELETE/address_pools/{name}

删除一个地址池,仅适用于未分配地址的地址池

Example URI

DELETE http://nanos.cloud/api/v1/address_pools/name
URI Parameters
HideShow
name
string (required) 

地址池名称

Request  删除地址池
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

地址段

管理地址段,用于给地址池添加可分配的地址资源

查询地址段
GET/address_pools/{name}/{type}/ranges/

查询地址池内所有可用地址段

Example URI

GET http://nanos.cloud/api/v1/address_pools/name/type/ranges/
URI Parameters
HideShow
name
string (required) 

地址池名称

type
string (optional) Default: internal 

地址段类型

Choices: internal external

Request  查询地址段
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "description": "范围起始地址"
          },
          "end": {
            "type": "string",
            "description": "范围结束地址"
          },
          "netmask": {
            "type": "string",
            "description": "范围地址掩码"
          },
          "type": {
            "type": "string",
            "enum": [
              "internal",
              "external"
            ],
            "default": "internal",
            "description": "地址类型"
          }
        }
      },
      "description": "地址段清单"
    }
  }
}

获取地址段状态
GET/address_pools/ranges/{start}

获取地址段状态和地址分配情况

Example URI

GET http://nanos.cloud/api/v1/address_pools/ranges/start
URI Parameters
HideShow
start
string (required) 

段起始地址

Request  获取地址段状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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",
        }
      ]
    }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "start": {
          "type": "string",
          "description": "地址段起始IP"
        },
        "end": {
          "type": "string",
          "description": "地址段结束IP"
        },
        "netmask": {
          "type": "string",
          "description": "地址段掩码"
        },
        "allocated": {
          "type": "array",
          "description": "已分配地址清单"
        }
      }
    }
  }
}

新增地址段
POST/address_pools/ranges/{start}

添加地址段到地址池中备用

Example URI

POST http://nanos.cloud/api/v1/address_pools/ranges/start
URI Parameters
HideShow
start
string (required) 

地址段起始IP

Request  新增地址段
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "end": "172.16.3.18",
  "netmask": "255.255.255.0"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "end": {
      "type": "string",
      "description": "地址段结束IP"
    },
    "netmask": {
      "type": "string",
      "description": "地址段掩码"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除地址段
DELETE/address_pools/ranges/{start}

从地址池中移除地址段,仅限于未分配地址段

Example URI

DELETE http://nanos.cloud/api/v1/address_pools/ranges/start
URI Parameters
HideShow
start
string (required) 

地址段起始IP

Request  Remove Range
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

云主机

管理云主机配置及运行实例

云主机查询

查询指定资源池或者节点内云主机状态

Query Guests With Conditions
GET/guest_search/{?pool,cell,status,created}

Example URI

GET http://nanos.cloud/api/v1/guest_search/?pool=&cell=&status=&created=
URI Parameters
HideShow
pool
string (required) 

目标资源池名称

cell
string (optional) 

目标节点名称

status
number (optional) 

运行状态标识

created
boolean (optional) 

是否仅查询已创建云主机

Request  Query Guests
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
        }
      }
  ]
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "云主机名"
          },
          "owner": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "用户ID"
          },
          "group": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "用户组"
          },
          "pool": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "计算资源池名称"
          },
          "cores": {
            "type": "number",
            "enum": [
              0
            ],
            "description": "核心数量"
          },
          "memory": {
            "type": "number",
            "enum": [
              0
            ],
            "description": "内存容量(字节)"
          },
          "disks": {
            "type": "array",
            "items": {
              "type": "number",
              "enum": [
                0
              ]
            },
            "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
          },
          "auto_start": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "云主机实例是否随宿主机开机启动"
          },
          "system": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "云主机系统ID"
          },
          "network_address": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "指定云主机IP(可选),尚未支持"
          },
          "ethernet_address": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "指定云主机MAC地址(可选),尚未支持"
          },
          "from_image": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "克隆时使用的源磁盘镜像ID"
          },
          "ports": {
            "type": "array",
            "items": {
              "type": "number",
              "enum": [
                0
              ]
            },
            "description": "需要开放的映射端口清单,尚未支持"
          },
          "template": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "系统模板ID"
          },
          "modules": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                ""
              ]
            },
            "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
          },
          "cloud_init": {
            "type": "object",
            "properties": {
              "root_enabled": {
                "type": "boolean",
                "enum": [
                  true
                ],
                "description": "允许root用户通过SSH远程登录,默认启用"
              },
              "admin_name": {
                "type": "string",
                "enum": [
                  "nano"
                ],
                "description": "指定超级管理员用户名,不指定则使用'root'"
              },
              "admin_secret": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "超级管理员明码,不指定则由nano生成安全密码"
              },
              "data_path": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "数据磁盘挂载路径,默认为`/opt/data`"
              }
            },
            "additionalProperties": false,
            "description": "Cloud-Init参数"
          },
          "qos": {
            "type": "object",
            "properties": {
              "cpu_priority": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low"
                ],
                "default": "medium",
                "description": "CPU优先级"
              },
              "write_speed": {
                "type": "number",
                "enum": [
                  10485760
                ],
                "description": "磁盘写入限速(字节/每秒),0 = 无限制"
              },
              "write_iops": {
                "type": "number",
                "enum": [
                  100
                ],
                "description": "磁盘写入限速(操作/每秒),0 = 无限制"
              },
              "read_speed": {
                "type": "number",
                "enum": [
                  10485760
                ],
                "description": "磁盘读取限速(字节/每秒),0 = 无限制"
              },
              "read_iops": {
                "type": "number",
                "enum": [
                  100
                ],
                "description": "磁盘读取限速(操作/每秒),0 = 无限制"
              },
              "receive_speed": {
                "type": "number",
                "enum": [
                  10485760
                ],
                "description": "网络接收限速(字节/每秒),0 = 无限制"
              },
              "send_speed": {
                "type": "number",
                "enum": [
                  10485760
                ],
                "description": "网络发送限速(字节/每秒),0 = 无限制"
              }
            },
            "additionalProperties": false,
            "description": "QoS配置"
          },
          "security_policy_group": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "使用的安全策略组ID"
          },
          "id": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "云主机ID"
          },
          "created": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "是否已创建"
          },
          "running": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "是否运行中"
          },
          "cell": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "承载资源节点名"
          },
          "host": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "承载资源节点地址"
          },
          "lost": {
            "type": "boolean",
            "enum": [
              false
            ],
            "description": "云主机是否失联"
          },
          "monitor_secret": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "监控密码"
          },
          "display_protocol": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "监控协议"
          },
          "total_disk": {
            "type": "number",
            "enum": [
              0
            ],
            "description": "总磁盘容量,以字节计算"
          },
          "progress": {
            "type": "number",
            "enum": [
              0
            ],
            "description": "创建进度,0~100"
          },
          "create_time": {
            "type": "string",
            "enum": [
              ""
            ],
            "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
          },
          "internal": {
            "type": "object",
            "properties": {
              "network_address": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
              },
              "display_address": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "云主机监控地址,格式为'主机:端口'"
              },
              "allocated_address": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "系统通过管理地址池为云主机分配的地址"
              }
            },
            "required": [
              "network_address",
              "display_address"
            ],
            "additionalProperties": false,
            "description": "内部网口状态"
          },
          "external": {
            "type": "object",
            "properties": {
              "network_address": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
              },
              "display_address": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "云主机监控地址,格式为'主机:端口'"
              },
              "allocated_address": {
                "type": "string",
                "enum": [
                  ""
                ],
                "description": "系统通过管理地址池为云主机分配的地址"
              }
            },
            "required": [
              "network_address",
              "display_address"
            ],
            "additionalProperties": false,
            "description": "外部网口状态"
          }
        },
        "required": [
          "name",
          "owner",
          "group",
          "pool",
          "cores",
          "memory",
          "disks",
          "auto_start",
          "template",
          "id",
          "created",
          "running",
          "total_disk"
        ],
        "additionalProperties": false
      },
      "description": "实例清单"
    }
  },
  "required": [
    "data"
  ]
}

云主机配置

管理云主机配置

查询云主机状态
GET/guests/{id}

通过创建时生成的云主机ID查询当前状态,201为创建中,200为已创建

Example URI

GET http://nanos.cloud/api/v1/guests/id
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  查询云主机状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  201
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "name": "test01",
      "created": false,
      "progress": 57
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "云主机ID"
        },
        "created": {
          "type": "boolean",
          "description": "是否创建完成"
        },
        "progress": {
          "type": "number",
          "description": "构建进度,范围0~100"
        }
      }
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
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
      }
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "云主机名"
        },
        "owner": {
          "type": "string",
          "description": "用户ID"
        },
        "group": {
          "type": "string",
          "description": "用户组"
        },
        "pool": {
          "type": "string",
          "description": "计算资源池名称"
        },
        "cores": {
          "type": "number",
          "description": "核心数量"
        },
        "memory": {
          "type": "number",
          "description": "内存容量(字节)"
        },
        "disks": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
        },
        "auto_start": {
          "type": "boolean",
          "description": "云主机实例是否随宿主机开机启动"
        },
        "system": {
          "type": "string",
          "description": "云主机系统ID"
        },
        "network_address": {
          "type": "string",
          "description": "指定云主机IP(可选),尚未支持"
        },
        "ethernet_address": {
          "type": "string",
          "description": "指定云主机MAC地址(可选),尚未支持"
        },
        "from_image": {
          "type": "string",
          "description": "克隆时使用的源磁盘镜像ID"
        },
        "ports": {
          "type": "array",
          "description": "需要开放的映射端口清单,尚未支持"
        },
        "template": {
          "type": "string",
          "description": "系统模板ID"
        },
        "modules": {
          "type": "array",
          "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
        },
        "cloud_init": {
          "type": "object",
          "properties": {
            "root_enabled": {
              "type": "boolean",
              "description": "允许root用户通过SSH远程登录,默认启用"
            },
            "admin_name": {
              "type": "string",
              "description": "指定超级管理员用户名,不指定则使用'root'"
            },
            "admin_secret": {
              "type": "string",
              "description": "超级管理员明码,不指定则由nano生成安全密码"
            },
            "data_path": {
              "type": "string",
              "description": "数据磁盘挂载路径,默认为`/opt/data`"
            }
          },
          "description": "Cloud-Init参数"
        },
        "qos": {
          "type": "object",
          "properties": {
            "cpu_priority": {
              "type": "string",
              "enum": [
                "high",
                "medium",
                "low"
              ],
              "default": "medium",
              "description": "CPU优先级"
            },
            "write_speed": {
              "type": "number",
              "description": "磁盘写入限速(字节/每秒),0 = 无限制"
            },
            "write_iops": {
              "type": "number",
              "description": "磁盘写入限速(操作/每秒),0 = 无限制"
            },
            "read_speed": {
              "type": "number",
              "description": "磁盘读取限速(字节/每秒),0 = 无限制"
            },
            "read_iops": {
              "type": "number",
              "description": "磁盘读取限速(操作/每秒),0 = 无限制"
            },
            "receive_speed": {
              "type": "number",
              "description": "网络接收限速(字节/每秒),0 = 无限制"
            },
            "send_speed": {
              "type": "number",
              "description": "网络发送限速(字节/每秒),0 = 无限制"
            }
          },
          "description": "QoS配置"
        },
        "security_policy_group": {
          "type": "string",
          "description": "使用的安全策略组ID"
        },
        "id": {
          "type": "string",
          "description": "云主机ID"
        },
        "created": {
          "type": "boolean",
          "description": "是否已创建"
        },
        "running": {
          "type": "boolean",
          "description": "是否运行中"
        },
        "cell": {
          "type": "string",
          "description": "承载资源节点名"
        },
        "host": {
          "type": "string",
          "description": "承载资源节点地址"
        },
        "lost": {
          "type": "boolean",
          "description": "云主机是否失联"
        },
        "monitor_secret": {
          "type": "string",
          "description": "监控密码"
        },
        "display_protocol": {
          "type": "string",
          "description": "监控协议"
        },
        "total_disk": {
          "type": "number",
          "description": "总磁盘容量,以字节计算"
        },
        "progress": {
          "type": "number",
          "description": "创建进度,0~100"
        },
        "create_time": {
          "type": "string",
          "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
        },
        "internal": {
          "type": "object",
          "properties": {
            "network_address": {
              "type": "string",
              "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
            },
            "display_address": {
              "type": "string",
              "description": "云主机监控地址,格式为'主机:端口'"
            },
            "allocated_address": {
              "type": "string",
              "description": "系统通过管理地址池为云主机分配的地址"
            }
          },
          "description": "内部网口状态"
        },
        "external": {
          "type": "object",
          "properties": {
            "network_address": {
              "type": "string",
              "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
            },
            "display_address": {
              "type": "string",
              "description": "云主机监控地址,格式为'主机:端口'"
            },
            "allocated_address": {
              "type": "string",
              "description": "系统通过管理地址池为云主机分配的地址"
            }
          },
          "description": "外部网口状态"
        }
      },
      "description": "当前实例状态"
    }
  }
}

创建云主机
POST/guests/

创建云主机,返回ID用于后续查询

Example URI

POST http://nanos.cloud/api/v1/guests/
Request  创建新主机
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
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"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "云主机名"
    },
    "owner": {
      "type": "string",
      "description": "用户ID"
    },
    "group": {
      "type": "string",
      "description": "用户组"
    },
    "pool": {
      "type": "string",
      "description": "计算资源池名称"
    },
    "cores": {
      "type": "number",
      "description": "核心数量"
    },
    "memory": {
      "type": "number",
      "description": "内存容量(字节)"
    },
    "disks": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
    },
    "auto_start": {
      "type": "boolean",
      "description": "云主机实例是否随宿主机开机启动"
    },
    "system": {
      "type": "string",
      "description": "云主机系统ID"
    },
    "network_address": {
      "type": "string",
      "description": "指定云主机IP(可选),尚未支持"
    },
    "ethernet_address": {
      "type": "string",
      "description": "指定云主机MAC地址(可选),尚未支持"
    },
    "from_image": {
      "type": "string",
      "description": "克隆时使用的源磁盘镜像ID"
    },
    "ports": {
      "type": "array",
      "description": "需要开放的映射端口清单,尚未支持"
    },
    "template": {
      "type": "string",
      "description": "系统模板ID"
    },
    "modules": {
      "type": "array",
      "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
    },
    "cloud_init": {
      "type": "object",
      "properties": {
        "root_enabled": {
          "type": "boolean",
          "description": "允许root用户通过SSH远程登录,默认启用"
        },
        "admin_name": {
          "type": "string",
          "description": "指定超级管理员用户名,不指定则使用'root'"
        },
        "admin_secret": {
          "type": "string",
          "description": "超级管理员明码,不指定则由nano生成安全密码"
        },
        "data_path": {
          "type": "string",
          "description": "数据磁盘挂载路径,默认为`/opt/data`"
        }
      },
      "description": "Cloud-Init参数"
    },
    "qos": {
      "type": "object",
      "properties": {
        "cpu_priority": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low"
          ],
          "default": "medium",
          "description": "CPU优先级"
        },
        "write_speed": {
          "type": "number",
          "description": "磁盘写入限速(字节/每秒),0 = 无限制"
        },
        "write_iops": {
          "type": "number",
          "description": "磁盘写入限速(操作/每秒),0 = 无限制"
        },
        "read_speed": {
          "type": "number",
          "description": "磁盘读取限速(字节/每秒),0 = 无限制"
        },
        "read_iops": {
          "type": "number",
          "description": "磁盘读取限速(操作/每秒),0 = 无限制"
        },
        "receive_speed": {
          "type": "number",
          "description": "网络接收限速(字节/每秒),0 = 无限制"
        },
        "send_speed": {
          "type": "number",
          "description": "网络发送限速(字节/每秒),0 = 无限制"
        }
      },
      "description": "QoS配置"
    },
    "security_policy_group": {
      "type": "string",
      "description": "使用的安全策略组ID"
    },
    "id": {
      "type": "string",
      "description": "云主机ID"
    },
    "created": {
      "type": "boolean",
      "description": "是否已创建"
    },
    "running": {
      "type": "boolean",
      "description": "是否运行中"
    },
    "cell": {
      "type": "string",
      "description": "承载资源节点名"
    },
    "host": {
      "type": "string",
      "description": "承载资源节点地址"
    },
    "lost": {
      "type": "boolean",
      "description": "云主机是否失联"
    },
    "monitor_secret": {
      "type": "string",
      "description": "监控密码"
    },
    "display_protocol": {
      "type": "string",
      "description": "监控协议"
    },
    "total_disk": {
      "type": "number",
      "description": "总磁盘容量,以字节计算"
    },
    "progress": {
      "type": "number",
      "description": "创建进度,0~100"
    },
    "create_time": {
      "type": "string",
      "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
    },
    "internal": {
      "type": "object",
      "properties": {
        "network_address": {
          "type": "string",
          "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
        },
        "display_address": {
          "type": "string",
          "description": "云主机监控地址,格式为'主机:端口'"
        },
        "allocated_address": {
          "type": "string",
          "description": "系统通过管理地址池为云主机分配的地址"
        }
      },
      "description": "内部网口状态"
    },
    "external": {
      "type": "object",
      "properties": {
        "network_address": {
          "type": "string",
          "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
        },
        "display_address": {
          "type": "string",
          "description": "云主机监控地址,格式为'主机:端口'"
        },
        "allocated_address": {
          "type": "string",
          "description": "系统通过管理地址池为云主机分配的地址"
        }
      },
      "description": "外部网口状态"
    }
  }
}
Response  202
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data":{
    "id": "dsfds8979847r3dsf-3r67",
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "创建的云主机ID"
        }
      }
    }
  }
}

删除云主机
DELETE/guests/{id}

删除云主机,释放所有分配资源

Example URI

DELETE http://nanos.cloud/api/v1/guests/id
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  delete guest
HideShow
Headers
Content-Type: application/json
Body
{
  "force": true
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

开机启动

启用或者停用云主机随宿主机开机启动

修改开机启动选项
PUT/guests/{id}/auto_start

修改开机启动选项

Example URI

PUT http://nanos.cloud/api/v1/guests/id/auto_start
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  修改开机启动选项
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "enable": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "enable": {
      "type": "boolean",
      "description": "是否启用开机启动"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

核心数量

管理云主机核心数量

修改云主机核心数量
PUT/guests/{id}/cores

修改云主机核心数量,仅支持停机操作

Example URI

PUT http://nanos.cloud/api/v1/guests/id/cores
URI Parameters
HideShow
id
string (required) 

guest ID

Request  修改云主机核心数量
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "cores": 4,
  "immediate": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "cores": {
      "type": "number",
      "description": "核心数量"
    },
    "immediate": {
      "type": "boolean",
      "description": "是否运行时生效(尚不支持)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

内存容量

管理云主机内存容量

修改内存容量
PUT/guests/{id}/memory

修改云主机内存容量,仅支持离线云主机

Example URI

PUT http://nanos.cloud/api/v1/guests/id/memory
URI Parameters
HideShow
id
string (required) 

guest ID

Request  修改内存容量
HideShow
Headers
Content-Type: application/json
Body
{
  "memory": 4294967296,
  "immediate": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "memory": {
      "type": "number",
      "description": "内存容量(字节)"
    },
    "immediate": {
      "type": "boolean",
      "description": "运行时是否实时生效(尚不支持)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

调整磁盘容量

管理云主机磁盘容量

扩展磁盘容量
PUT/guests/{id}/disks/resize/{disk}

扩充云主机磁盘容量,仅支持离线云主机

Example URI

PUT http://nanos.cloud/api/v1/guests/id/disks/resize/disk
URI Parameters
HideShow
id
string (required) 

云主机ID

disk
number (required) 

目标磁盘索引,系统盘=0,数据盘1=1,数据盘2=2,以此类推

Request  扩展磁盘容量
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "size": 42949672960,
  "immediate": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "size": {
      "type": "number",
      "description": "新的磁盘容量(字节)"
    },
    "immediate": {
      "type": "boolean",
      "description": "运行时是否立即生效(尚不支持)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

压缩磁盘容量

压缩云主机磁盘容量

压缩磁盘文件
PUT/guests/{id}/disks/shrink/{disk}

将云主机磁盘文件压缩到最小,通常用于构建云主机镜像,仅支持离线云主机

Example URI

PUT http://nanos.cloud/api/v1/guests/id/disks/shrink/disk
URI Parameters
HideShow
id
string (required) 

云主机ID

disk
number (required) 

目标磁盘索引,系统盘=0,数据盘1=1,数据盘2=2,以此类推

Request  压缩磁盘文件
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "immediate": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "immediate": {
      "type": "boolean",
      "description": "运行时是否直接生效(尚未支持)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

操作系统

管理云主机操作系统

重置云主机操作系统
PUT/guests/{id}/system/

从磁盘镜像重刷云主机操作系统,放弃所有原有数据

Example URI

PUT http://nanos.cloud/api/v1/guests/id/system/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  重置云主机操作系统
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "from_image": "0123456789-abcdef"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "from_image": {
      "type": "string",
      "description": "源镜像ID"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

管理员密码

管理云主机管理员密码

重置管理员密码
PUT/guests/{id}/auth

为云主机重置新管理员密码

Example URI

PUT http://nanos.cloud/api/v1/guests/id/auth
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  重置管理员密码
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "password": "asdb12356",
  "user": "root"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "password": {
      "type": "string",
      "description": "新密码,未指定则由系统生成安全密码"
    },
    "user": {
      "type": "number",
      "description": "管理员用户名,未指定则根据系统类型自动选择"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "password": "1235656756",
      "user": "root"
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "password": {
      "type": "string",
      "description": "管理员密码"
    },
    "user": {
      "type": "number",
      "description": "管理员用户名"
    }
  }
}

获取管理员密码
GET/guests/{id}/auth

获取当前云主机的管理员密码和用户名

Example URI

GET http://nanos.cloud/api/v1/guests/id/auth
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  获取管理员密码
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "password": "1235656756",
      "user": "root"
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "password": {
      "type": "string",
      "description": "管理员密码"
    },
    "user": {
      "type": "number",
      "description": "管理员用户名"
    }
  }
}

云主机名称

管理云主机名称

修改云主机名称
PUT/guests/{id}/name/

修改云主机名称

Example URI

PUT http://nanos.cloud/api/v1/guests/id/name/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  修改云主机名称
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "some_instance",
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "云主机名称"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

CPU优先级

管理云主机CPU优先级,高优先级云主机容易获得更多CPU资源,用于处理自己业务

修改CPU优先级
PUT/guests/{id}/qos/cpu/

修改CPU优先级

Example URI

PUT http://nanos.cloud/api/v1/guests/id/qos/cpu/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  修改CPU优先级
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "priority": "high",
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "priority": {
      "type": "string",
      "enum": [
        "high",
        "medium",
        "low"
      ],
      "description": "CPU优先级"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

磁盘QoS

管理磁盘QoS,优化云主机磁盘IO性能

修改磁盘QoS配置
PUT/guests/{id}/qos/disk/

调整云主机磁盘QoS配置,优化云主机磁盘性能和响应速度

Example URI

PUT http://nanos.cloud/api/v1/guests/id/qos/disk/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  修改磁盘QoS配置
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "write_speed": 1048576,
  "write_iops": 100,
  "read_speed": 1048576,
  "read_iops": 100
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "write_speed": {
      "type": "number",
      "description": "磁盘写入速度限制(字节/秒),0为不限制"
    },
    "write_iops": {
      "type": "number",
      "description": "磁盘写入操作限制(写入/秒),0为不限制"
    },
    "read_speed": {
      "type": "number",
      "description": "磁盘读取速度限制(字节/秒),0为不限制"
    },
    "read_iops": {
      "type": "number",
      "description": "磁盘读取操作限制(读取/秒),0为不限制"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

网络QoS

管理云主机的网络QoS配置参数,优化网络IO性能

修改云主机网络QoS参数
PUT/guests/{id}/qos/network/

修改云主机网络QoS参数,优化网络IO性能

Example URI

PUT http://nanos.cloud/api/v1/guests/id/qos/network/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  修改云主机网络QoS参数
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "receive_speed": 10485760,
  "send_speed": 10485760
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "receive_speed": {
      "type": "number",
      "description": "网络接收速度限制(字节/秒),0为不限制"
    },
    "send_speed": {
      "type": "number",
      "description": "网络发送速度限制(字节/秒),0为不限制"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

云主机安全策略

管理云主机安全策略

获取安全策略配置
GET/guests/{id}/security_policy/

获取云主机当前的安全策略配置

Example URI

GET http://nanos.cloud/api/v1/guests/id/security_policy/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  获取安全策略配置
HideShow
Headers
Nano-session: 1234567890-abcdef
Accept: text/plain
Response  200
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "default_action": {
          "type": "string",
          "enum": [
            "accept",
            "reject"
          ],
          "default": "accept",
          "description": "报文默认处理规则"
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "accept",
                  "reject"
                ],
                "default": "accept",
                "description": "处理动作"
              },
              "to_port": {
                "type": "number",
                "description": "目标端口"
              },
              "protocol": {
                "type": "string",
                "enum": [
                  "all",
                  "tcp",
                  "udp",
                  "icmp"
                ],
                "default": "all",
                "description": "匹配协议"
              },
              "from_address": {
                "type": "string",
                "description": "来源地址"
              },
              "interface": {
                "type": "number",
                "description": "匹配接口索引,0=全部接口, 1=第一个接口,以此类推"
              }
            }
          },
          "description": "处理规则清单"
        }
      }
    }
  }
}

默认处理规则

管理云主机安全策略的默认规则,当接收报文不匹配任何已知规则时,按照默认规则处理

修改默认处理动作
PUT/guests/{id}/security_policy/default_action

设置当报文不匹配任何规则时的处理动作

Example URI

PUT http://nanos.cloud/api/v1/guests/id/security_policy/default_action
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  修改默认处理动作
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "action": "accept"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "报文匹配规则失败时的默认处理"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

云主机安全策略规则

管理云主机安全策略规则

追加安全策略规则
POST/guests/{id}/security_policy/rules/

为云主机添加新的安全策略规则

Example URI

POST http://nanos.cloud/api/v1/guests/id/security_policy/rules/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  追加安全策略规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "action": "accept",
  "to_port": 8088,
  "protocol": "tcp",
  "from_address": "127.0.0.1",
  "interface": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "处理动作"
    },
    "to_port": {
      "type": "number",
      "description": "目标端口"
    },
    "protocol": {
      "type": "string",
      "enum": [
        "all",
        "tcp",
        "udp",
        "icmp"
      ],
      "default": "all",
      "description": "匹配协议"
    },
    "from_address": {
      "type": "string",
      "description": "来源地址"
    },
    "interface": {
      "type": "number",
      "description": "匹配接口索引,0=全部接口, 1=第一个接口,以此类推"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改安全策略规则
PUT/guests/security_policy/rules/{index}

修改安全策略规则

Example URI

PUT http://nanos.cloud/api/v1/guests/security_policy/rules/index
URI Parameters
HideShow
index
number (required) 

规则索引,从0开始

Request  修改安全策略规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "action": "accept",
  "to_port": 8088,
  "protocol": "tcp",
  "from_address": "127.0.0.1",
  "interface": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "处理动作"
    },
    "to_port": {
      "type": "number",
      "description": "目标端口"
    },
    "protocol": {
      "type": "string",
      "enum": [
        "all",
        "tcp",
        "udp",
        "icmp"
      ],
      "default": "all",
      "description": "匹配协议"
    },
    "from_address": {
      "type": "string",
      "description": "来源地址"
    },
    "interface": {
      "type": "number",
      "description": "匹配接口索引,0=全部接口, 1=第一个接口,以此类推"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

调整规则顺序
PUT/guests/security_policy/rules/{index}/order

调整安全策略顺序规则

Example URI

PUT http://nanos.cloud/api/v1/guests/security_policy/rules/index/order
URI Parameters
HideShow
index
number (required) 

规则索引,从0开始

Request  调整规则顺序
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "direction": "up"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "direction": {
      "type": "string",
      "enum": [
        "up",
        "down"
      ],
      "description": "规则移动方向"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除安全策略规则
DELETE/guests/security_policy/rules/{index}

删除安全策略规则

Example URI

DELETE http://nanos.cloud/api/v1/guests/security_policy/rules/index
URI Parameters
HideShow
index
number (required) 

规则索引,从0开始

Request  删除安全策略规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

云主机实例

管理云主机实例

获取实例运行状态
GET/instances/{id}

获取当前云主机实例运行状态

Example URI

GET http://nanos.cloud/api/v1/instances/id
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  获取实例运行状态
HideShow
Headers
Nano-Session: 12345678-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "云主机名"
        },
        "owner": {
          "type": "string",
          "description": "用户ID"
        },
        "group": {
          "type": "string",
          "description": "用户组"
        },
        "pool": {
          "type": "string",
          "description": "计算资源池名称"
        },
        "cores": {
          "type": "number",
          "description": "核心数量"
        },
        "memory": {
          "type": "number",
          "description": "内存容量(字节)"
        },
        "disks": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
        },
        "auto_start": {
          "type": "boolean",
          "description": "云主机实例是否随宿主机开机启动"
        },
        "system": {
          "type": "string",
          "description": "云主机系统ID"
        },
        "network_address": {
          "type": "string",
          "description": "指定云主机IP(可选),尚未支持"
        },
        "ethernet_address": {
          "type": "string",
          "description": "指定云主机MAC地址(可选),尚未支持"
        },
        "from_image": {
          "type": "string",
          "description": "克隆时使用的源磁盘镜像ID"
        },
        "ports": {
          "type": "array",
          "description": "需要开放的映射端口清单,尚未支持"
        },
        "template": {
          "type": "string",
          "description": "系统模板ID"
        },
        "modules": {
          "type": "array",
          "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
        },
        "cloud_init": {
          "type": "object",
          "properties": {
            "root_enabled": {
              "type": "boolean",
              "description": "允许root用户通过SSH远程登录,默认启用"
            },
            "admin_name": {
              "type": "string",
              "description": "指定超级管理员用户名,不指定则使用'root'"
            },
            "admin_secret": {
              "type": "string",
              "description": "超级管理员明码,不指定则由nano生成安全密码"
            },
            "data_path": {
              "type": "string",
              "description": "数据磁盘挂载路径,默认为`/opt/data`"
            }
          },
          "description": "Cloud-Init参数"
        },
        "qos": {
          "type": "object",
          "properties": {
            "cpu_priority": {
              "type": "string",
              "enum": [
                "high",
                "medium",
                "low"
              ],
              "default": "medium",
              "description": "CPU优先级"
            },
            "write_speed": {
              "type": "number",
              "description": "磁盘写入限速(字节/每秒),0 = 无限制"
            },
            "write_iops": {
              "type": "number",
              "description": "磁盘写入限速(操作/每秒),0 = 无限制"
            },
            "read_speed": {
              "type": "number",
              "description": "磁盘读取限速(字节/每秒),0 = 无限制"
            },
            "read_iops": {
              "type": "number",
              "description": "磁盘读取限速(操作/每秒),0 = 无限制"
            },
            "receive_speed": {
              "type": "number",
              "description": "网络接收限速(字节/每秒),0 = 无限制"
            },
            "send_speed": {
              "type": "number",
              "description": "网络发送限速(字节/每秒),0 = 无限制"
            }
          },
          "description": "QoS配置"
        },
        "security_policy_group": {
          "type": "string",
          "description": "使用的安全策略组ID"
        },
        "id": {
          "type": "string",
          "description": "云主机ID"
        },
        "created": {
          "type": "boolean",
          "description": "是否已创建"
        },
        "running": {
          "type": "boolean",
          "description": "是否运行中"
        },
        "cell": {
          "type": "string",
          "description": "承载资源节点名"
        },
        "host": {
          "type": "string",
          "description": "承载资源节点地址"
        },
        "lost": {
          "type": "boolean",
          "description": "云主机是否失联"
        },
        "monitor_secret": {
          "type": "string",
          "description": "监控密码"
        },
        "display_protocol": {
          "type": "string",
          "description": "监控协议"
        },
        "total_disk": {
          "type": "number",
          "description": "总磁盘容量,以字节计算"
        },
        "progress": {
          "type": "number",
          "description": "创建进度,0~100"
        },
        "create_time": {
          "type": "string",
          "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
        },
        "internal": {
          "type": "object",
          "properties": {
            "network_address": {
              "type": "string",
              "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
            },
            "display_address": {
              "type": "string",
              "description": "云主机监控地址,格式为'主机:端口'"
            },
            "allocated_address": {
              "type": "string",
              "description": "系统通过管理地址池为云主机分配的地址"
            }
          },
          "description": "内部网口状态"
        },
        "external": {
          "type": "object",
          "properties": {
            "network_address": {
              "type": "string",
              "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
            },
            "display_address": {
              "type": "string",
              "description": "云主机监控地址,格式为'主机:端口'"
            },
            "allocated_address": {
              "type": "string",
              "description": "系统通过管理地址池为云主机分配的地址"
            }
          },
          "description": "外部网口状态"
        },
        "cpu_usage": {
          "type": "number",
          "description": "总CPU使用率,0.00 ~ 100.00"
        },
        "memory_available": {
          "type": "number",
          "description": "可用内存容量(字节)"
        },
        "disk_available": {
          "type": "number",
          "description": "可用磁盘容量(字节)"
        },
        "bytes_read": {
          "type": "number",
          "description": "总磁盘读取字节数"
        },
        "bytes_written": {
          "type": "number",
          "description": "总磁盘写入字节数"
        },
        "bytes_received": {
          "type": "number",
          "description": "总网络接收字节数"
        },
        "bytes_sent": {
          "type": "number",
          "description": "总网络发送字节数"
        },
        "media_attached": {
          "type": "boolean",
          "description": "是否已挂载光盘镜像"
        },
        "media_source": {
          "type": "string",
          "description": "挂载光盘镜像ID"
        }
      },
      "description": "当前状态"
    }
  }
}

启动云主机实例
POST/instances/{id}

启动云主机实例

Example URI

POST http://nanos.cloud/api/v1/instances/id
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  启动云主机实例
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "from_media": true,
  "source": "bd0fe127-a8db-4c89-98ea-9a5070b08aae"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "from_media": {
      "type": "boolean",
      "description": "从光盘镜像启动"
    },
    "from_network": {
      "type": "boolean",
      "description": "从网络源启动(尚未支持)"
    },
    "source": {
      "type": "string",
      "description": "源镜像ID或者地址"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

停止云主机实例
DELETE/instances/{id}

停止云主机运行

Example URI

DELETE http://nanos.cloud/api/v1/instances/id
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  停止云主机实例
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "reboot": false,
  "force": true
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "reboot": {
      "type": "boolean",
      "description": "重启或者关机,默认为重启"
    },
    "force": {
      "type": "boolean",
      "description": "是否强制执行"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

媒体镜像

管理云主机实例加载的媒体镜像

插入媒体镜像
POST/instances/{id}/media

运行云主机实例中插入媒体镜像,需要先把ISO光盘镜像上传系统后使用

Example URI

POST http://nanos.cloud/api/v1/instances/id/media
URI Parameters
HideShow
id
string (required) 

guest ID

Request  插入媒体镜像
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "source": "bd0fe127-a8db-4c89-98ea-9a5070b08aae",
  "type": 0
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "source": {
      "type": "string",
      "description": "镜像ID"
    },
    "type": {
      "type": "number",
      "description": "媒体类型,0=媒体镜像(默认)"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

弹出媒体镜像
DELETE/instances/{id}/media

在运行的云主机实例中弹出已经加载的媒体镜像

Example URI

DELETE http://nanos.cloud/api/v1/instances/id/media
URI Parameters
HideShow
id
string (required) 

guest ID

Request  弹出媒体镜像
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

云主机快照

管理云主机快照

查询云主机快照清单
GET/instances/{id}/snapshots/

查询某云主机用的全部快照清单

Example URI

GET http://nanos.cloud/api/v1/instances/id/snapshots/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  查询云主机快照清单
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "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/instances/{id}/snapshots/

为云主机创建新快照,仅云主机停止时可用

Example URI

POST http://nanos.cloud/api/v1/instances/id/snapshots/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  创建新快照
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "snapshot1",
  "description": "this is a snapshot example"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "快照名称"
    },
    "description": {
      "type": "string",
      "description": "快照描述"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

恢复快照
PUT/instances/{id}/snapshots/

将系统还原到快照创建时刻,仅对停止云主机可用

Example URI

PUT http://nanos.cloud/api/v1/instances/id/snapshots/
URI Parameters
HideShow
id
string (required) 

云主机ID

Request  恢复快照
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "target": "snapshot1"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "target": {
      "type": "string",
      "description": "快照名称"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

快照配置

配置指定的云主机快照

获取快照信息
GET/instances/{id}/snapshots/{name}

查询指定快照信息

Example URI

GET http://nanos.cloud/api/v1/instances/id/snapshots/name
URI Parameters
HideShow
id
string (required) 

云主机ID

name
string (required) 

快照名称

Request  获取快照信息
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "running": false,
      "description": "this is snapshot before installing cloud-init",
      "create_time": "2018-08-21 12:34:56"
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "running": {
      "type": "boolean",
      "description": "是否运行中的快照"
    },
    "create_time": {
      "type": "string",
      "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
    },
    "description": {
      "type": "string",
      "description": "快照描述"
    }
  }
}

删除快照
DELETE/instances/{id}/snapshots/{name}

删除云主机快照

Example URI

DELETE http://nanos.cloud/api/v1/instances/id/snapshots/name
URI Parameters
HideShow
id
string (required) 

云主机ID

name
string (required) 

快照名称

Request  删除快照
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

监控通道

为了保障云主机访问安全,统一管理外部连接,Nano建立一个临时的安全监控通道用于管理和控制云主机。

使用创建接口分配通道后,可以通过Websocket地址ws://host/monitor_channels/{channel_id}使用VNC协议进行访问,支持noNVC或者其他标准客户端。

如果通道分配后未及时建立连接,则通道会自动释放。

创建新监控通道
POST/monitor_channels/

建立连接指定云主机的监控通道

Example URI

POST http://nanos.cloud/api/v1/monitor_channels/
Request  创建新监控通道
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "guest": "some_guest_id",
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "guest": {
      "type": "string",
      "description": "需要监控的云主机ID"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":{
      "id": "channel-id-123",
      "protocol": "vnc",
      "username": "",
      "password": "some_secret",
    }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "监控通道ID"
        },
        "protocol": {
          "type": "string",
          "description": "监控协议"
        },
        "username": {
          "type": "string",
          "description": "连接用户名"
        },
        "password": {
          "type": "string",
          "description": "连接密码"
        }
      }
    }
  }
}

镜像管理

管理磁盘镜像和光盘镜像

媒体镜像搜索

搜索媒体镜像

搜索媒体镜像
GET/media_image_search/

使用已登录用户权限搜索可访问的媒体镜像菜单

Example URI

GET http://nanos.cloud/api/v1/media_image_search/
Request  搜索媒体镜像
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
      ]
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "镜像名"
          },
          "owner": {
            "type": "string",
            "description": "镜像所属用户"
          },
          "group": {
            "type": "string",
            "description": "镜像所属组"
          },
          "description": {
            "type": "string",
            "description": "镜像描述"
          },
          "tags": {
            "type": "array",
            "description": "镜像标签"
          },
          "id": {
            "type": "string",
            "description": "镜像ID"
          },
          "created": {
            "type": "boolean",
            "description": "是否创建完成"
          },
          "progress": {
            "type": "number",
            "description": "构建进度,0~100"
          },
          "create_time": {
            "type": "string",
            "description": "创建时间,格式:YYYY-MM-DD HH:MI:SS"
          },
          "modify_time": {
            "type": "string",
            "description": "修改时间,格式:YYYY-MM-DD HH:MI:SS"
          },
          "size": {
            "type": "number",
            "description": "镜像尺寸(字节)"
          }
        }
      },
      "description": "可用镜像清单"
    }
  }
}

媒体镜像

管理媒体镜像

同步本地媒体镜像文件
PATCH/media_images/

从Core模块的本地镜像文件存储路径读取并同步媒体镜像数据

Example URI

PATCH http://nanos.cloud/api/v1/media_images/
Request  同步本地媒体镜像文件
HideShow
Headers
Nano-session: 1234567890-abcdef
Body
{
  "owner": "admin",
  "group": "manager",
}
Schema
{
  "type": "object",
  "properties": {
    "owner": {
      "type": "string",
      "description": "指定同步镜像的创建者"
    },
    "group": {
      "type": "string",
      "description": "指定同步镜像的所属用户组"
    }
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

查询所有媒体镜像
GET/media_images/

查询所有媒体镜像

Example URI

GET http://nanos.cloud/api/v1/media_images/
Request  查询所有媒体镜像
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
      ]
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "镜像名"
          },
          "owner": {
            "type": "string",
            "description": "镜像所属用户"
          },
          "group": {
            "type": "string",
            "description": "镜像所属组"
          },
          "description": {
            "type": "string",
            "description": "镜像描述"
          },
          "tags": {
            "type": "array",
            "description": "镜像标签"
          },
          "id": {
            "type": "string",
            "description": "镜像ID"
          },
          "created": {
            "type": "boolean",
            "description": "是否创建完成"
          },
          "progress": {
            "type": "number",
            "description": "构建进度,0~100"
          },
          "create_time": {
            "type": "string",
            "description": "创建时间,格式:YYYY-MM-DD HH:MI:SS"
          },
          "modify_time": {
            "type": "string",
            "description": "修改时间,格式:YYYY-MM-DD HH:MI:SS"
          },
          "size": {
            "type": "number",
            "description": "镜像尺寸(字节)"
          }
        }
      },
      "description": "镜像清单"
    }
  }
}

获取媒体镜像状态
GET/media_images/{id}

获取媒体镜像信息

Example URI

GET http://nanos.cloud/api/v1/media_images/id
URI Parameters
HideShow
id
string (required) 

媒体镜像ID

Request  获取媒体镜像状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "镜像名"
        },
        "owner": {
          "type": "string",
          "description": "镜像所属用户"
        },
        "group": {
          "type": "string",
          "description": "镜像所属组"
        },
        "description": {
          "type": "string",
          "description": "镜像描述"
        },
        "tags": {
          "type": "array",
          "description": "镜像标签"
        },
        "id": {
          "type": "string",
          "description": "镜像ID"
        },
        "created": {
          "type": "boolean",
          "description": "是否创建完成"
        },
        "progress": {
          "type": "number",
          "description": "构建进度,0~100"
        },
        "create_time": {
          "type": "string",
          "description": "创建时间,格式:YYYY-MM-DD HH:MI:SS"
        },
        "modify_time": {
          "type": "string",
          "description": "修改时间,格式:YYYY-MM-DD HH:MI:SS"
        },
        "size": {
          "type": "number",
          "description": "镜像尺寸(字节)"
        }
      },
      "description": "镜像状态"
    }
  }
}

创建媒体镜像
POST/media_images/

创建空白媒体镜像,用于上传和更新媒体镜像数据,需要配合后续接口工作

Example URI

POST http://nanos.cloud/api/v1/media_images/
Request  创建新媒体镜像
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "centos7_64_minimal",
  "owner": "admin",
  "group": "manager",
  "description": "some desc",
  "tags": [
    "linux",
    "64bit",
    "centos"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "镜像名"
    },
    "owner": {
      "type": "string",
      "description": "镜像所属用户"
    },
    "group": {
      "type": "string",
      "description": "镜像所属组"
    },
    "description": {
      "type": "string",
      "description": "镜像描述"
    },
    "tags": {
      "type": "array",
      "description": "镜像标签"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data":[
    {
      "id": "sdf83kjfe-23r4wedf",
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "镜像ID"
        }
      }
    }
  }
}

修改媒体镜像信息
PUT/media_images/{id}

修改媒体镜像信息

Example URI

PUT http://nanos.cloud/api/v1/media_images/id
URI Parameters
HideShow
id
string (required) 

镜像ID

Request  修改媒体镜像信息
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "centos7_64_minimal",
  "owner": "admin",
  "group": "manager",
  "description": "some desc",
  "tags": [
    "linux",
    "64bit",
    "centos"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "镜像名"
    },
    "owner": {
      "type": "string",
      "description": "镜像所属用户"
    },
    "group": {
      "type": "string",
      "description": "镜像所属组"
    },
    "description": {
      "type": "string",
      "description": "镜像描述"
    },
    "tags": {
      "type": "array",
      "description": "镜像标签"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除媒体镜像
DELETE/media_images/{id}

删除媒体镜像,清除关联文件数据

Example URI

DELETE http://nanos.cloud/api/v1/media_images/id
URI Parameters
HideShow
id
string (required) 

镜像ID

Request  删除媒体镜像
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

媒体镜像文件

管理媒体镜像文件

下载媒体镜像文件
GET/media_image_files/{id}

下载二进制媒体镜像文件

Example URI

GET http://nanos.cloud/api/v1/media_image_files/id
URI Parameters
HideShow
id
string (required) 

镜像ID

Response  200
HideShow
Headers
Content-Type: application/octet-stream

上传媒体镜像文件
POST/media_image_files/{id}

上传ISO文件数据

Example URI

POST http://nanos.cloud/api/v1/media_image_files/id
URI Parameters
HideShow
id
string (required) 

镜像ID

Request  上传媒体镜像文件
HideShow
Headers
Content-Type: multipart/form-data
Body
-----BOUNDARY
Content-Disposition: form-data; name="image"; filename="image.iso"

-----BOUNDARY
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
    "error_code": 0,
    "message": "",
}
]

磁盘镜像搜索

搜索磁盘镜像

搜索磁盘镜像
GET/disk_image_search/{?tags}

按照条件搜索磁盘镜像

Example URI

GET http://nanos.cloud/api/v1/disk_image_search/?tags=
URI Parameters
HideShow
tags
array[string] (optional) 

镜像标签

Request  搜索磁盘镜像
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
      ]
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "镜像名"
          },
          "owner": {
            "type": "string",
            "description": "镜像所属用户"
          },
          "group": {
            "type": "string",
            "description": "镜像所属组"
          },
          "description": {
            "type": "string",
            "description": "镜像描述"
          },
          "tags": {
            "type": "array",
            "description": "镜像标签"
          },
          "id": {
            "type": "string",
            "description": "镜像ID"
          },
          "created": {
            "type": "boolean",
            "description": "是否创建完成"
          },
          "progress": {
            "type": "number",
            "description": "构建进度,0~100"
          },
          "create_time": {
            "type": "string",
            "description": "创建时间,格式:YYYY-MM-DD HH:MI:SS"
          },
          "modify_time": {
            "type": "string",
            "description": "修改时间,格式:YYYY-MM-DD HH:MI:SS"
          },
          "size": {
            "type": "number",
            "description": "镜像尺寸(字节)"
          }
        }
      },
      "description": "镜像清单"
    }
  }
}

磁盘镜像

管理磁盘镜像和文件

同步本地磁盘镜像文件
PATCH/disk_images/

从Core模块的本地镜像文件存储路径读取并同步磁盘镜像数据

Example URI

PATCH http://nanos.cloud/api/v1/disk_images/
Request  同步本地磁盘镜像文件
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

获取磁盘镜像状态
GET/disk_images/{id}

获取磁盘镜像状态

Example URI

GET http://nanos.cloud/api/v1/disk_images/id
URI Parameters
HideShow
id
string (required) 

镜像ID

Request  获取磁盘镜像状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  202
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data": {
    "name": "centos7_64_minimal",
    "created": false,
    "progress": 46,
    "description": "some desc",
    "tags": [
      "linux",
      "64bit",
      "centos"
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "镜像名"
        },
        "owner": {
          "type": "string",
          "description": "镜像所属用户"
        },
        "group": {
          "type": "string",
          "description": "镜像所属组"
        },
        "description": {
          "type": "string",
          "description": "镜像描述"
        },
        "tags": {
          "type": "array",
          "description": "镜像标签"
        },
        "id": {
          "type": "string",
          "description": "镜像ID"
        },
        "created": {
          "type": "boolean",
          "description": "是否创建完成"
        },
        "progress": {
          "type": "number",
          "description": "构建进度,0~100"
        },
        "create_time": {
          "type": "string",
          "description": "创建时间,格式:YYYY-MM-DD HH:MI:SS"
        },
        "modify_time": {
          "type": "string",
          "description": "修改时间,格式:YYYY-MM-DD HH:MI:SS"
        },
        "size": {
          "type": "number",
          "description": "镜像尺寸(字节)"
        }
      },
      "description": "镜像状态"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
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"
    ]
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "镜像名"
        },
        "owner": {
          "type": "string",
          "description": "镜像所属用户"
        },
        "group": {
          "type": "string",
          "description": "镜像所属组"
        },
        "description": {
          "type": "string",
          "description": "镜像描述"
        },
        "tags": {
          "type": "array",
          "description": "镜像标签"
        },
        "id": {
          "type": "string",
          "description": "镜像ID"
        },
        "created": {
          "type": "boolean",
          "description": "是否创建完成"
        },
        "progress": {
          "type": "number",
          "description": "构建进度,0~100"
        },
        "create_time": {
          "type": "string",
          "description": "创建时间,格式:YYYY-MM-DD HH:MI:SS"
        },
        "modify_time": {
          "type": "string",
          "description": "修改时间,格式:YYYY-MM-DD HH:MI:SS"
        },
        "size": {
          "type": "number",
          "description": "镜像尺寸(字节)"
        }
      },
      "description": "镜像状态"
    }
  }
}

创建磁盘镜像
POST/disk_images/

从源云主机系统磁盘克隆生成新镜像,如果没有指定云主机,则创建空白镜像用于后续上传

Example URI

POST http://nanos.cloud/api/v1/disk_images/
Request  创建磁盘镜像
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "centos7_64_minimal",
  "guest": "dir723rgfyu-rre67grg-efw",
  "owner": "admin",
  "group": "manager",
  "description": "some desc",
  "tags": [
    "linux",
    "64bit",
    "centos"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "镜像名"
    },
    "owner": {
      "type": "string",
      "description": "镜像所属用户"
    },
    "group": {
      "type": "string",
      "description": "镜像所属组"
    },
    "description": {
      "type": "string",
      "description": "镜像描述"
    },
    "tags": {
      "type": "array",
      "description": "镜像标签"
    },
    "guest": {
      "type": "string",
      "description": "来源云主机ID,未指定则创建空白镜像"
    }
  }
}
Response  202
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data":[
    {
      "id": "sdf83kjfe-23r4wedf",
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "镜像ID"
        }
      }
    }
  }
}

修改磁盘镜像
PUT/disk_images/{id}

修改磁盘镜像信息

Example URI

PUT http://nanos.cloud/api/v1/disk_images/id
URI Parameters
HideShow
id
string (required) 

磁盘镜像ID

Request  修改磁盘镜像
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "centos7_64_minimal",
  "owner": "admin",
  "group": "manager",
  "description": "some desc",
  "tags": [
    "linux",
    "64bit",
    "centos"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "镜像名"
    },
    "owner": {
      "type": "string",
      "description": "镜像所属用户"
    },
    "group": {
      "type": "string",
      "description": "镜像所属组"
    },
    "description": {
      "type": "string",
      "description": "镜像描述"
    },
    "tags": {
      "type": "array",
      "description": "镜像标签"
    },
    "guest": {
      "type": "string",
      "description": "来源云主机ID,未指定则创建空白镜像"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除磁盘镜像
DELETE/disk_images/{id}

删除镜像信息及磁盘文件

Example URI

DELETE http://nanos.cloud/api/v1/disk_images/id
URI Parameters
HideShow
id
string (required) 

磁盘镜像ID

Request  删除磁盘镜像
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

磁盘镜像文件

管理磁盘镜像及文件

上传磁盘镜像文件
POST/disk_image_files/{id}

上传二进制磁盘镜像文件数据,仅支持qcow2格式

Example URI

POST http://nanos.cloud/api/v1/disk_image_files/id
URI Parameters
HideShow
id
string (required) 

镜像ID

Request  上传磁盘镜像文件
HideShow
Headers
Content-Type: multipart/form-data
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
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

系统维护

系统维护管理接口

系统模板

系统模板是用于选择云主机虚拟的一组硬件驱动和配置组合,便于管理员批量构建适合自己业务的硬件模板。

本接口提供系统模板管理和配置功能。

查询系统模板
GET/templates/

查询所有可用系统模板

Example URI

GET http://nanos.cloud/api/v1/templates/
Request  查询系统模板
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "系统模板ID"
          },
          "name": {
            "type": "string",
            "description": "系统模板名"
          },
          "operating_system": {
            "type": "string",
            "enum": [
              "linux",
              "windows"
            ],
            "default": "linux",
            "description": "操作系统"
          },
          "created_time": {
            "type": "string",
            "description": "模板创建时间,格式`YYYY-MM-DD HH:MI:SS`"
          },
          "modified_time": {
            "type": "string",
            "description": "模板修改时间,格式`YYYY-MM-DD HH:MI:SS`"
          }
        }
      },
      "description": "模板清单"
    }
  }
}

获取模板配置详情
GET/templates/{id}

获取模板配置详情

Example URI

GET http://nanos.cloud/api/v1/templates/id
URI Parameters
HideShow
id
string (required) 

模板ID

Request  获取模板配置详情
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "系统模板名"
        },
        "admin": {
          "type": "string",
          "description": "默认管理员用户名"
        },
        "operating_system": {
          "type": "string",
          "enum": [
            "linux",
            "windows"
          ],
          "default": "linux",
          "description": "操作系统"
        },
        "disk": {
          "type": "string",
          "enum": [
            "scsi",
            "sata",
            "ide"
          ],
          "default": "scsi",
          "description": "磁盘驱动类型"
        },
        "network": {
          "type": "string",
          "enum": [
            "virtio",
            "e1000",
            "rtl8139"
          ],
          "default": "virtio",
          "description": "网卡型号"
        },
        "display": {
          "type": "string",
          "enum": [
            "vga",
            "cirrus"
          ],
          "default": "vga",
          "description": "显卡驱动"
        },
        "control": {
          "type": "string",
          "enum": [
            "vnc",
            "spice"
          ],
          "default": "vnc",
          "description": "远程控制"
        },
        "usb": {
          "type": "string",
          "enum": [
            "``",
            "nec-xhci"
          ],
          "default": "``",
          "description": "USB接口型号"
        },
        "tablet": {
          "type": "string",
          "enum": [
            "``",
            "usb"
          ],
          "default": "``",
          "description": "平板接口型号"
        },
        "id": {
          "type": "string",
          "description": "系统模板ID"
        },
        "created_time": {
          "type": "string",
          "description": "模板创建时间,格式`YYYY-MM-DD HH:MI:SS`"
        },
        "modified_time": {
          "type": "string",
          "description": "模板修改时间,格式`YYYY-MM-DD HH:MI:SS`"
        }
      },
      "description": "模板配置状态"
    }
  }
}

新建系统模板
POST/templates/

新建系统模板

Example URI

POST http://nanos.cloud/api/v1/templates/
Request  新建系统模板
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "CentOS 7",
  "admin": "root",
  "operating_system": "linux",
  "disk": "scsi",
  "network": "virtio",
  "display": "vga",
  "control": "vnc",
  "usb": "",
  "tablet": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "系统模板名"
    },
    "admin": {
      "type": "string",
      "description": "默认管理员用户名"
    },
    "operating_system": {
      "type": "string",
      "enum": [
        "linux",
        "windows"
      ],
      "default": "linux",
      "description": "操作系统"
    },
    "disk": {
      "type": "string",
      "enum": [
        "scsi",
        "sata",
        "ide"
      ],
      "default": "scsi",
      "description": "磁盘驱动类型"
    },
    "network": {
      "type": "string",
      "enum": [
        "virtio",
        "e1000",
        "rtl8139"
      ],
      "default": "virtio",
      "description": "网卡型号"
    },
    "display": {
      "type": "string",
      "enum": [
        "vga",
        "cirrus"
      ],
      "default": "vga",
      "description": "显卡驱动"
    },
    "control": {
      "type": "string",
      "enum": [
        "vnc",
        "spice"
      ],
      "default": "vnc",
      "description": "远程控制"
    },
    "usb": {
      "type": "string",
      "enum": [
        "``",
        "nec-xhci"
      ],
      "default": "``",
      "description": "USB接口型号"
    },
    "tablet": {
      "type": "string",
      "enum": [
        "``",
        "usb"
      ],
      "default": "``",
      "description": "平板接口型号"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data": {
    "id": "1234-abcdef"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "模板ID"
        }
      }
    }
  }
}

修改系统模板配置
PUT/templates/{id}

修改指定的系统模板配置

Example URI

PUT http://nanos.cloud/api/v1/templates/id
URI Parameters
HideShow
id
string (required) 

模板ID

Request  修改系统模板配置
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "CentOS 7",
  "admin": "root",
  "operating_system": "linux",
  "disk": "scsi",
  "network": "virtio",
  "display": "vga",
  "control": "vnc",
  "usb": "",
  "tablet": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "系统模板名"
    },
    "admin": {
      "type": "string",
      "description": "默认管理员用户名"
    },
    "operating_system": {
      "type": "string",
      "enum": [
        "linux",
        "windows"
      ],
      "default": "linux",
      "description": "操作系统"
    },
    "disk": {
      "type": "string",
      "enum": [
        "scsi",
        "sata",
        "ide"
      ],
      "default": "scsi",
      "description": "磁盘驱动类型"
    },
    "network": {
      "type": "string",
      "enum": [
        "virtio",
        "e1000",
        "rtl8139"
      ],
      "default": "virtio",
      "description": "网卡型号"
    },
    "display": {
      "type": "string",
      "enum": [
        "vga",
        "cirrus"
      ],
      "default": "vga",
      "description": "显卡驱动"
    },
    "control": {
      "type": "string",
      "enum": [
        "vnc",
        "spice"
      ],
      "default": "vnc",
      "description": "远程控制"
    },
    "usb": {
      "type": "string",
      "enum": [
        "``",
        "nec-xhci"
      ],
      "default": "``",
      "description": "USB接口型号"
    },
    "tablet": {
      "type": "string",
      "enum": [
        "``",
        "usb"
      ],
      "default": "``",
      "description": "平板接口型号"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除系统模板
DELETE/templates/{id}

删除系统模板

Example URI

DELETE http://nanos.cloud/api/v1/templates/id
URI Parameters
HideShow
id
string (required) 

模板ID

Request  删除系统模板
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

安全策略组

多个安全策略规则组成一个安全策略组,创建云主机时选择对应策略组能够快速初始化安全策略

获取安全策略组状态
GET/security_policy_groups/{id}

返回指定安全策略组的基本状态信息

Example URI

GET http://nanos.cloud/api/v1/security_policy_groups/id
URI Parameters
HideShow
id
string (required) 

策略组ID

Request  获取安全策略组状态
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "安全组名"
        },
        "description": {
          "type": "string",
          "description": "安全组描述"
        },
        "user": {
          "type": "string",
          "description": "创建者ID"
        },
        "group": {
          "type": "string",
          "description": "创建者组名"
        },
        "enabled": {
          "type": "boolean",
          "description": "是否启用"
        },
        "global": {
          "type": "boolean",
          "description": "是否全局可见"
        },
        "default_action": {
          "type": "string",
          "enum": [
            "accept",
            "reject"
          ],
          "default": "accept",
          "description": "默认处理动作,未匹配规则时触发default action when no rule matched"
        },
        "id": {
          "type": "string",
          "description": "安全组ID"
        }
      },
      "description": "策略组状态"
    }
  }
}

新建安全策略组
POST/security_policy_groups/

新建安全策略组

Example URI

POST http://nanos.cloud/api/v1/security_policy_groups/
Request  新建安全策略组
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "linux_1",
  "description": "Some Group for Linux",
  "user": "nano",
  "group": "super",
  "enabled": false,
  "global": false,
  "default_action": "accept"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "安全组名"
    },
    "description": {
      "type": "string",
      "description": "安全组描述"
    },
    "user": {
      "type": "string",
      "description": "创建者ID"
    },
    "group": {
      "type": "string",
      "description": "创建者组名"
    },
    "enabled": {
      "type": "boolean",
      "description": "是否启用"
    },
    "global": {
      "type": "boolean",
      "description": "是否全局可见"
    },
    "default_action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "默认处理动作,未匹配规则时触发default action when no rule matched"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data": {
    "id": "1234-abcdef"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "安全策略组ID"
        }
      }
    }
  }
}

修改安全策略组
PUT/security_policy_groups/{id}

修改策略组基本配置参数,使用该组创建的云主机不受影响

Example URI

PUT http://nanos.cloud/api/v1/security_policy_groups/id
URI Parameters
HideShow
id
string (required) 

策略组ID

Request  修改安全策略组
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "name": "linux_2",
  "description": "Some Group for Linux",
  "user": "nano",
  "group": "super",
  "enabled": false,
  "global": false,
  "default_action": "accept"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "安全组名"
    },
    "description": {
      "type": "string",
      "description": "安全组描述"
    },
    "user": {
      "type": "string",
      "description": "创建者ID"
    },
    "group": {
      "type": "string",
      "description": "创建者组名"
    },
    "enabled": {
      "type": "boolean",
      "description": "是否启用"
    },
    "global": {
      "type": "boolean",
      "description": "是否全局可见"
    },
    "default_action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "默认处理动作,未匹配规则时触发default action when no rule matched"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除安全策略组
DELETE/security_policy_groups/{id}

删除安全策略组,使用该组创建的云主机不受影响

Example URI

DELETE http://nanos.cloud/api/v1/security_policy_groups/id
URI Parameters
HideShow
id
string (required) 

策略组ID

Request  删除安全策略组
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

查询策略组规则
GET/security_policy_groups/{id}/rules/

返回某策略组包含的详细规则清单

Example URI

GET http://nanos.cloud/api/v1/security_policy_groups/id/rules/
URI Parameters
HideShow
id
string (required) 

策略组ID

Request  查询策略组规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "accept",
              "reject"
            ],
            "default": "accept",
            "description": "处理动作"
          },
          "to_port": {
            "type": "number",
            "description": "目标端口"
          },
          "protocol": {
            "type": "string",
            "enum": [
              "all",
              "tcp",
              "udp",
              "icmp"
            ],
            "default": "all",
            "description": "匹配协议"
          },
          "from_address": {
            "type": "string",
            "description": "来源地址"
          },
          "interface": {
            "type": "number",
            "description": "匹配接口索引,0=全部接口, 1=第一个接口,以此类推"
          }
        }
      },
      "description": "规则清单"
    }
  }
}

添加策略组规则
POST/security_policy_groups/{id}/rules/

添加处理规则到指定策略组

Example URI

POST http://nanos.cloud/api/v1/security_policy_groups/id/rules/
URI Parameters
HideShow
id
string (required) 

策略组ID

Request  添加策略组规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "action": "accept",
  "to_port": 8088,
  "protocol": "tcp",
  "from_address": "127.0.0.1",
  "interface": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "处理动作"
    },
    "to_port": {
      "type": "number",
      "description": "目标端口"
    },
    "protocol": {
      "type": "string",
      "enum": [
        "all",
        "tcp",
        "udp",
        "icmp"
      ],
      "default": "all",
      "description": "匹配协议"
    },
    "from_address": {
      "type": "string",
      "description": "来源地址"
    },
    "interface": {
      "type": "number",
      "description": "匹配接口索引,0=全部接口, 1=第一个接口,以此类推"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改策略组规则
PUT/security_policy_groups/{id}/rules/{index}

修改指定规则

Example URI

PUT http://nanos.cloud/api/v1/security_policy_groups/id/rules/index
URI Parameters
HideShow
id
string (required) 

策略组ID

index
number (required) 

规则索引,从0开始

Request  修改策略组规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "action": "accept",
  "to_port": 8088,
  "protocol": "tcp",
  "from_address": "127.0.0.1",
  "interface": 1
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "accept",
        "reject"
      ],
      "default": "accept",
      "description": "处理动作"
    },
    "to_port": {
      "type": "number",
      "description": "目标端口"
    },
    "protocol": {
      "type": "string",
      "enum": [
        "all",
        "tcp",
        "udp",
        "icmp"
      ],
      "default": "all",
      "description": "匹配协议"
    },
    "from_address": {
      "type": "string",
      "description": "来源地址"
    },
    "interface": {
      "type": "number",
      "description": "匹配接口索引,0=全部接口, 1=第一个接口,以此类推"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

调整规则顺序
PUT/security_policy_groups/{id}/rules/{index}/order

安全规则从上往下匹配(从0开始),本接口调整指定规则的排列顺序,改变处理优先级

Example URI

PUT http://nanos.cloud/api/v1/security_policy_groups/id/rules/index/order
URI Parameters
HideShow
id
string (required) 

策略组ID

index
number (required) 

规则索引,从0开始

Request  调整规则顺序
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "direction": "up"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "direction": {
      "type": "string",
      "enum": [
        "up",
        "down"
      ],
      "description": "移动方向"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除策略组规则
DELETE/security_policy_groups/{id}/rules/{index}

将指定规则从策略组中移除

Example URI

DELETE http://nanos.cloud/api/v1/security_policy_groups/id/rules/index
URI Parameters
HideShow
id
string (required) 

策略组ID

index
number (required) 

规则索引,从0开始

Request  删除策略组规则
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": ""
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

云主机迁移

主动迁移云主机,目前仅支持在同一资源池内的节点中迁移,需要后端存储支持

启动迁移
POST/migrations/

指定迁移云主机和迁移目标,启动迁移任务

Example URI

POST http://nanos.cloud/api/v1/migrations/
Request  启动迁移
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "source_pool": "default",
  "source_cell": "cell1",
  "target_pool": "another-pool",
  "target_cell": "new-cell",
  "instances": [
    "jhfguf85-34uyf-4t4tghjh",
    "dfjui-euy37-dyuy3t5qn"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "source_pool": {
      "type": "string",
      "description": "需要迁移的云主机所在资源池"
    },
    "source_cell": {
      "type": "string",
      "description": "需要迁移的云主机所在资源节点"
    },
    "target_pool": {
      "type": "string",
      "description": "需要迁移的目标资源池(尚未支持)"
    },
    "target_cell": {
      "type": "string",
      "description": "需要迁移的目标节点,未指定则均衡分配到池内各节点"
    },
    "instances": {
      "type": "array",
      "description": "需要迁移的云主机ID清单,未指定则迁移该节点所有云主机"
    }
  }
}
Response  202
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": [
      {
        "id": "abcdef-1234567890"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "迁移任务ID"
        }
      }
    }
  }
}

查询迁移任务状态
GET/migrations/{id}

查询指定迁移任务的当前状态

Example URI

GET http://nanos.cloud/api/v1/migrations/id
URI Parameters
HideShow
id
string (required) 

迁移任务ID

Request  查询迁移任务状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  201
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":{
    "finished": false,
    "progress": 57 //limit to 100
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "finished": {
          "type": "boolean",
          "description": "迁移是否完成"
        },
        "progress": {
          "type": "number",
          "description": "迁移进度,0~100"
        }
      }
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "finished": true
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "finished": {
          "type": "boolean",
          "description": "迁移是否完成"
        }
      }
    }
  }
}

查询所有处理中的迁移任务
GET/migrations/

查询所有处理中的迁移任务

Example URI

GET http://nanos.cloud/api/v1/migrations/
Request  查询所有处理中的迁移任务
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":[
    {
        "id": "1234567890-abcdef",
        "finished": false,
        "progress": 57 //limit to 100
    },
    {
        "id": "1234567890-abcdef",
        "finished": true
    }
  ]
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}

批量创建云主机

管理批量创建云主机任务

启动批量创建
POST/batch/create_guest/

批量创建云主机,返回任务ID用于查询创建状态

Example URI

POST http://nanos.cloud/api/v1/batch/create_guest/
Request  启动批量创建
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
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"
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name_rule": {
      "type": "string",
      "enum": [
        "order",
        "MAC",
        "address"
      ],
      "description": "批量生成云主机名称的规则"
    },
    "name_prefix": {
      "type": "string",
      "description": "云主机名称前缀"
    },
    "owner": {
      "type": "string",
      "description": "创建用户ID"
    },
    "group": {
      "type": "string",
      "description": "创建用户组"
    },
    "pool": {
      "type": "string",
      "description": "承载的计算资源池名称"
    },
    "count": {
      "type": "number",
      "description": "批量创建的云主机数量"
    },
    "cores": {
      "type": "number",
      "description": "每个云主机的核心数量"
    },
    "memory": {
      "type": "number",
      "description": "每个云主机的内存容量(字节)"
    },
    "disks": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "description": "[系统磁盘容量, 数据磁盘n的容量...]"
    },
    "auto_start": {
      "type": "boolean",
      "description": "云主机是否随宿主机开机启动"
    },
    "from_image": {
      "type": "string",
      "description": "克隆的源镜像ID,未指定则创建空白云主机"
    },
    "template": {
      "type": "string",
      "description": "系统模板ID"
    },
    "modules": {
      "type": "array",
      "description": "云主机预装的模块清单,\"qemu\"/\"cloud-init\""
    },
    "cloud_init": {
      "type": "object",
      "properties": {
        "root_enabled": {
          "type": "boolean",
          "description": "允许root用户通过SSH远程登录,默认启用"
        },
        "admin_name": {
          "type": "string",
          "description": "指定超级管理员用户名,不指定则使用'root'"
        },
        "admin_secret": {
          "type": "string",
          "description": "超级管理员明码,不指定则由nano生成安全密码"
        },
        "data_path": {
          "type": "string",
          "description": "数据磁盘挂载路径,默认为`/opt/data`"
        }
      },
      "description": "Cloud-Init配置参数"
    },
    "qos": {
      "type": "object",
      "properties": {
        "cpu_priority": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low"
          ],
          "default": "medium",
          "description": "CPU优先级"
        },
        "write_speed": {
          "type": "number",
          "description": "磁盘写入限速(字节/每秒),0 = 无限制"
        },
        "write_iops": {
          "type": "number",
          "description": "磁盘写入限速(操作/每秒),0 = 无限制"
        },
        "read_speed": {
          "type": "number",
          "description": "磁盘读取限速(字节/每秒),0 = 无限制"
        },
        "read_iops": {
          "type": "number",
          "description": "磁盘读取限速(操作/每秒),0 = 无限制"
        },
        "receive_speed": {
          "type": "number",
          "description": "网络接收限速(字节/每秒),0 = 无限制"
        },
        "send_speed": {
          "type": "number",
          "description": "网络发送限速(字节/每秒),0 = 无限制"
        }
      },
      "description": "QoS配置信息"
    }
  }
}
Response  202
HideShow
Headers
Content-Type: application/json
Body
{
  "error_code": 0,
  "message": "",
  "data":{
    "id": "dsfds8979847r3dsf-3r67",
  }
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "批处理任务ID"
        }
      }
    }
  }
}

查询批量创建任务状态
GET/batch/create_guest/{id}

查询批量创建任务的状态

Example URI

GET http://nanos.cloud/api/v1/batch/create_guest/id
URI Parameters
HideShow
id
string (required) 

任务ID

Request  查询批量创建任务状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  202
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}

批量删除任务

管理批量删除云主机任务

启动批量删除
POST/batch/delete_guest/

同时删除多个云主机,返回任务ID用于查询状态

Example URI

POST http://nanos.cloud/api/v1/batch/delete_guest/
Request  启动批量删除
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "guest": [
    "0123456789-abcdef-1",
    "0123456789-abcdef-2",
    "0123456789-abcdef-3"
  ],
  "force": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "guest": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "需要删除的云主机ID清单"
    },
    "force": {
      "type": "boolean",
      "description": "是否强行终止运行中的云主机"
    }
  }
}
Response  202
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":{
    "id": "dsfds8979847r3dsf-3r67",
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "批处理任务ID"
        }
      }
    }
  }
}

查询批量删除任务状态
GET/batch/delete_guest/{id}

查询批量删除任务状态

Example URI

GET http://nanos.cloud/api/v1/batch/delete_guest/id
URI Parameters
HideShow
id
string (required) 

批处理任务ID

Request  查询批量删除任务状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  202
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}

批量停止云主机

管理批量停止云主机任务

启动批量停机
POST/batch/stop_guest/

同时停止多个云主机,返回任务ID用于查询状态

Example URI

POST http://nanos.cloud/api/v1/batch/stop_guest/
Request  启动批量停机
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "guests": [
    "0123456789-abcdef-1",
    "0123456789-abcdef-2",
    "0123456789-abcdef-3"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "guest": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "目标云主机ID清单"
    }
  }
}
Response  202
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":{
    "id": "dsfds8979847r3dsf-3r67",
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "批量任务ID"
        }
      }
    }
  }
}

查询批量停机任务状态
GET/batch/stop_guest/{id}

查询批量停机任务状态

Example URI

GET http://nanos.cloud/api/v1/batch/stop_guest/id
URI Parameters
HideShow
id
string (required) 

批处理任务ID

Request  查询批量停机任务状态
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  202
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
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"
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}

资源搜索

资源搜索统一接口

搜索安全策略组

根据条件查询系统中的安全策略组

查询安全策略组
GET/search/security_policy_groups/{?enabled_only,global_only,owner,group}

使用当前登录用户/所属组查询安全策略组

Example URI

GET http://nanos.cloud/api/v1/search/security_policy_groups/?enabled_only=&global_only=&owner=&group=
URI Parameters
HideShow
owner
string (optional) 

返回指定用户创建的安全组

group
string (optional) 

返回指定用户组所属的安全组

enabled_only
boolean (optional) 

仅返回启用中的安全组

global_only
boolean (optional) 

仅返回全局可见的安全组

Request  查询安全策略组
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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"
    }
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "安全组名"
          },
          "description": {
            "type": "string",
            "description": "安全组描述"
          },
          "user": {
            "type": "string",
            "description": "创建者ID"
          },
          "group": {
            "type": "string",
            "description": "创建者组名"
          },
          "enabled": {
            "type": "boolean",
            "description": "是否启用"
          },
          "global": {
            "type": "boolean",
            "description": "是否全局可见"
          },
          "default_action": {
            "type": "string",
            "enum": [
              "accept",
              "reject"
            ],
            "default": "accept",
            "description": "默认处理动作,未匹配规则时触发default action when no rule matched"
          },
          "id": {
            "type": "string",
            "description": "安全组ID"
          }
        }
      },
      "description": "安全策略组清单"
    }
  }
}

搜索云主机

按照指定条件搜索云主机,支持分页和模糊匹配

搜索云主机
POST/search/guests/

使用已登录用户信息搜索云主机,关键词模糊匹配云主机名、IP或者承载资源节点

Example URI

POST http://nanos.cloud/api/v1/search/guests/
Request  搜索云主机
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "limit": 10,
  "offset": 20,
  "keyword": "example"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "limit": {
      "type": "number",
      "description": "最大返回结果集数量"
    },
    "offset": {
      "type": "number",
      "description": "返回结果集偏移地址"
    },
    "pool": {
      "type": "string",
      "description": "承载计算资源池"
    },
    "cell": {
      "type": "string",
      "description": "承载计算节点"
    },
    "keyword": {
      "type": "string",
      "description": "搜索关键字,模糊匹配云主机名、IP,资源节点名称、IP"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
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
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "result": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "云主机名"
              },
              "owner": {
                "type": "string",
                "description": "用户ID"
              },
              "group": {
                "type": "string",
                "description": "用户组"
              },
              "pool": {
                "type": "string",
                "description": "计算资源池名称"
              },
              "cores": {
                "type": "number",
                "description": "核心数量"
              },
              "memory": {
                "type": "number",
                "description": "内存容量(字节)"
              },
              "disks": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "description": "[系统盘大小, 数据盘n大小...], 以字节计算"
              },
              "auto_start": {
                "type": "boolean",
                "description": "云主机实例是否随宿主机开机启动"
              },
              "system": {
                "type": "string",
                "description": "云主机系统ID"
              },
              "network_address": {
                "type": "string",
                "description": "指定云主机IP(可选),尚未支持"
              },
              "ethernet_address": {
                "type": "string",
                "description": "指定云主机MAC地址(可选),尚未支持"
              },
              "from_image": {
                "type": "string",
                "description": "克隆时使用的源磁盘镜像ID"
              },
              "ports": {
                "type": "array",
                "description": "需要开放的映射端口清单,尚未支持"
              },
              "template": {
                "type": "string",
                "description": "系统模板ID"
              },
              "modules": {
                "type": "array",
                "description": "云主机系统里已安装的模块,如\"qemu\"/\"cloud-init\""
              },
              "cloud_init": {
                "type": "object",
                "properties": {
                  "root_enabled": {
                    "type": "boolean",
                    "description": "允许root用户通过SSH远程登录,默认启用"
                  },
                  "admin_name": {
                    "type": "string",
                    "description": "指定超级管理员用户名,不指定则使用'root'"
                  },
                  "admin_secret": {
                    "type": "string",
                    "description": "超级管理员明码,不指定则由nano生成安全密码"
                  },
                  "data_path": {
                    "type": "string",
                    "description": "数据磁盘挂载路径,默认为`/opt/data`"
                  }
                },
                "description": "Cloud-Init参数"
              },
              "qos": {
                "type": "object",
                "properties": {
                  "cpu_priority": {
                    "type": "string",
                    "enum": [
                      "high",
                      "medium",
                      "low"
                    ],
                    "default": "medium",
                    "description": "CPU优先级"
                  },
                  "write_speed": {
                    "type": "number",
                    "description": "磁盘写入限速(字节/每秒),0 = 无限制"
                  },
                  "write_iops": {
                    "type": "number",
                    "description": "磁盘写入限速(操作/每秒),0 = 无限制"
                  },
                  "read_speed": {
                    "type": "number",
                    "description": "磁盘读取限速(字节/每秒),0 = 无限制"
                  },
                  "read_iops": {
                    "type": "number",
                    "description": "磁盘读取限速(操作/每秒),0 = 无限制"
                  },
                  "receive_speed": {
                    "type": "number",
                    "description": "网络接收限速(字节/每秒),0 = 无限制"
                  },
                  "send_speed": {
                    "type": "number",
                    "description": "网络发送限速(字节/每秒),0 = 无限制"
                  }
                },
                "description": "QoS配置"
              },
              "security_policy_group": {
                "type": "string",
                "description": "使用的安全策略组ID"
              },
              "id": {
                "type": "string",
                "description": "云主机ID"
              },
              "created": {
                "type": "boolean",
                "description": "是否已创建"
              },
              "running": {
                "type": "boolean",
                "description": "是否运行中"
              },
              "cell": {
                "type": "string",
                "description": "承载资源节点名"
              },
              "host": {
                "type": "string",
                "description": "承载资源节点地址"
              },
              "lost": {
                "type": "boolean",
                "description": "云主机是否失联"
              },
              "monitor_secret": {
                "type": "string",
                "description": "监控密码"
              },
              "display_protocol": {
                "type": "string",
                "description": "监控协议"
              },
              "total_disk": {
                "type": "number",
                "description": "总磁盘容量,以字节计算"
              },
              "progress": {
                "type": "number",
                "description": "创建进度,0~100"
              },
              "create_time": {
                "type": "string",
                "description": "创建时间,格式:'YYYY-MM-DD HH:MI:SS'"
              },
              "internal": {
                "type": "object",
                "properties": {
                  "network_address": {
                    "type": "string",
                    "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
                  },
                  "display_address": {
                    "type": "string",
                    "description": "云主机监控地址,格式为'主机:端口'"
                  },
                  "allocated_address": {
                    "type": "string",
                    "description": "系统通过管理地址池为云主机分配的地址"
                  }
                },
                "description": "内部网口状态"
              },
              "external": {
                "type": "object",
                "properties": {
                  "network_address": {
                    "type": "string",
                    "description": "网卡地址,IPv4格式,比如: '172.10.6.8'"
                  },
                  "display_address": {
                    "type": "string",
                    "description": "云主机监控地址,格式为'主机:端口'"
                  },
                  "allocated_address": {
                    "type": "string",
                    "description": "系统通过管理地址池为云主机分配的地址"
                  }
                },
                "description": "外部网口状态"
              },
              "cpu_usage": {
                "type": "number",
                "description": "总CPU使用率,0.00 ~ 100.00"
              },
              "memory_available": {
                "type": "number",
                "description": "可用内存容量(字节)"
              },
              "disk_available": {
                "type": "number",
                "description": "可用磁盘容量(字节)"
              },
              "bytes_read": {
                "type": "number",
                "description": "总磁盘读取字节数"
              },
              "bytes_written": {
                "type": "number",
                "description": "总磁盘写入字节数"
              },
              "bytes_received": {
                "type": "number",
                "description": "总网络接收字节数"
              },
              "bytes_sent": {
                "type": "number",
                "description": "总网络发送字节数"
              },
              "media_attached": {
                "type": "boolean",
                "description": "是否已挂载光盘镜像"
              },
              "media_source": {
                "type": "string",
                "description": "挂载光盘镜像ID"
              }
            }
          },
          "description": "云主机状态清单"
        },
        "total": {
          "type": "number",
          "description": "总结果集数量"
        },
        "limit": {
          "type": "number",
          "description": "最大返回结果集数量"
        },
        "offset": {
          "type": "number",
          "description": "返回结果集偏移地址"
        }
      }
    }
  }
}

FrontEnd管理接口

用于管理FrontEnd模块的统一API接口,包含用户权限管理、会话鉴权、操作日志等功能,FrontEnd使用RBAC模型管理用户权限。

角色管理

管理系统管理员角色,角色允许关联多个菜单权限,每个用户组允许关联多个角色从而获得不同权限

查询所有角色
GET/roles/

返回系统中所有用户角色

Example URI

GET http://nanos.cloud/api/v1/roles/
Request  查询所有角色
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": [
      "maintainer",
      "auditor",
      "user"
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "description": "角色清单"
    }
  }
}

查询角色配置信息
GET/roles/{role_name}

获取指定角色目前拥有的权限状态

Example URI

GET http://nanos.cloud/api/v1/roles/role_name
URI Parameters
HideShow
role_name
string (required) 

角色名称

Request  查询角色配置信息
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":{
    "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"]
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "menu": {
          "type": "array",
          "description": "拥有的菜单权限标签清单"
        }
      }
    }
  }
}

添加角色
POST/roles/{role_name}

新增系统角色

Example URI

POST http://nanos.cloud/api/v1/roles/role_name
URI Parameters
HideShow
role_name
string (required) 

角色名称

Request  添加角色
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "menu": [
    "dashboard",
    "compute_pool",
    "address_pool",
    "instance"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "menu": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "角色拥有的菜单权限清单"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改角色权限
PUT/roles/{role_name}

修改指定角色拥有的权限

Example URI

PUT http://nanos.cloud/api/v1/roles/role_name
URI Parameters
HideShow
role_name
string (required) 

角色名称

Request  Modify Role
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "menu": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "角色拥有的菜单权限清单"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除角色
DELETE/roles/{role_name}

从系统中删除指定角色,只能删除未关联任何用户的角色

Example URI

DELETE http://nanos.cloud/api/v1/roles/role_name
URI Parameters
HideShow
role_name
string (required) 

角色名称

Request  Remove Role
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

用户组管理

用户组包含多个用户,每个用户组能够拥有多个角色,从而获得对应角色关联的权限集合

查询所有用户组
GET/user_groups/

查询系统中所有的用户组

Example URI

GET http://nanos.cloud/api/v1/user_groups/
Request  查询所有用户组
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
      }
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array"
    }
  }
}

查询用户组详情
GET/user_groups/{group_name}

获取指定用户组详细信息

Example URI

GET http://nanos.cloud/api/v1/user_groups/group_name
URI Parameters
HideShow
group_name
string (required) 

用户组名

Request  查询用户组详情
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "name": "manager_group",
      "display": "Group of Manager",
      "role": [
        "manager",
        "user"
      ],
      "member": [
        "admin",
        "nano",
        "akumas"
      ]
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "用户组名称"
        },
        "display": {
          "type": "string",
          "description": "用户组显示名称"
        },
        "role": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "关联的角色清单"
        },
        "member": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "组成员清单"
        }
      }
    }
  }
}

添加用户组
POST/user_groups/{group_name}

添加用户组

Example URI

POST http://nanos.cloud/api/v1/user_groups/group_name
URI Parameters
HideShow
group_name
string (required) 

用户组名称

Request  添加用户组
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "display": "Group of Manager",
  "role": [
    "manager",
    "user"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "display": {
      "type": "string",
      "description": "用户组显示名称"
    },
    "role": {
      "type": "array",
      "description": "关联的角色清单"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改用户组
PUT/user_groups/{group_name}

修改用户组关联权限

Example URI

PUT http://nanos.cloud/api/v1/user_groups/group_name
URI Parameters
HideShow
group_name
string (required) 

用户组名称

Request  修改用户组
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "display": "Group of Manager",
  "role": [
    "manager",
    "user"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "display": {
      "type": "string",
      "description": "用户组显示名称"
    },
    "role": {
      "type": "array",
      "description": "关联角色清单"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除用户组
DELETE/user_groups/{group_name}

从系统中删除用户组

Example URI

DELETE http://nanos.cloud/api/v1/user_groups/group_name
URI Parameters
HideShow
group_name
string (required) 

用户组名称

Request  删除用户组
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

用户组成员

管理用户组成员

查询用户组成员
GET/user_groups/members/

查询指定用户组的所有成员清单

Example URI

GET http://nanos.cloud/api/v1/user_groups/members/
Request  查询用户组成员
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": [
      "admin",
      "nano",
      "akumas"
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "成员名称清单"
    }
  }
}

添加用户组成员
POST/user_groups/{group_name}/members/{user_name}

将新成员添加到用户组

Example URI

POST http://nanos.cloud/api/v1/user_groups/group_name/members/user_name
URI Parameters
HideShow
group_name
string (required) 

用户组名称

user_name
string (required) 

用户名称

Request  添加用户组成员
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

移除用户组成员
DELETE/user_groups/{group_name}/members/{user_name}

从用户组中移除成员

Example URI

DELETE http://nanos.cloud/api/v1/user_groups/group_name/members/user_name
URI Parameters
HideShow
group_name
string (required) 

用户组名称

user_name
string (required) 

用户名称

Request  移除用户组成员
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

系统管理员

管理系统管理员

查询所有系统管理员
GET/users/

查询系统中所有用户清单

Example URI

GET http://nanos.cloud/api/v1/users/
Request  查询所有系统管理员
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": [
      "admin",
      "nano",
      "akumas"
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "管理员清单"
    }
  }
}

获取管理员信息
GET/users/{user_name}

获取管理员信息

Example URI

GET http://nanos.cloud/api/v1/users/user_name
URI Parameters
HideShow
user_name
string (required) 

管理员名称

Request  获取管理员信息
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "nick": "AK",
      "mail": "a@b.com"
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "nick": {
          "type": "string",
          "description": "昵称"
        },
        "mail": {
          "type": "string",
          "description": "邮件地址"
        }
      }
    }
  }
}

新建管理员
POST/users/{user_name}

新建系统管理员

Example URI

POST http://nanos.cloud/api/v1/users/user_name
URI Parameters
HideShow
user_name
string (required) 

管理员名称

Request  Create New User
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "nick": "AK",
  "mail": "a@b.com",
  "password": "abcdefg"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "nick": {
      "type": "string",
      "description": "显示用昵称"
    },
    "mail": {
      "type": "string",
      "description": "用户邮箱"
    },
    "password": {
      "type": "string",
      "description": "用户密码"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

修改管理员信息
PUT/users/{user_name}

修改管理员信息

Example URI

PUT http://nanos.cloud/api/v1/users/user_name
URI Parameters
HideShow
user_name
string (required) 

管理员名称

Request  修改管理员信息
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "nick": "AK",
  "mail": "a@b.com"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "nick": {
      "type": "string",
      "description": "显示昵称"
    },
    "mail": {
      "type": "string",
      "description": "用户邮箱"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除系统管理员
DELETE/users/{user_name}

删除系统管理员

Example URI

DELETE http://nanos.cloud/api/v1/users/user_name
URI Parameters
HideShow
user_name
string (required) 

管理员名称

Request  删除系统管理员
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

管理员密码

配置管理员密码

修改管理员密码
PUT/users/{user_name}/password/

校验并更新管理员密码

Example URI

PUT http://nanos.cloud/api/v1/users/user_name/password/
URI Parameters
HideShow
user_name
string (required) 

管理员名称

Request  Modify Password
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "old": "123456",
  "new": "abcdef"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "old": {
      "type": "string",
      "description": "验证用旧密码"
    },
    "new": {
      "type": "string",
      "description": "新密码"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

用户搜索接口

用户搜索接口

搜索用户
GET/user_search/{?group}

按组返回用户

Example URI

GET http://nanos.cloud/api/v1/user_search/?group=
URI Parameters
HideShow
group
string (optional) 

用户组

Request  Search Users
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": [
      "nano",
      "alex",
      "sam"
    ]
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "管理员清单"
    }
  }
}

会话管理

会话鉴权、管理

创建新会话
POST/sessions/

使用账号密码校验并分配新会话,将会话ID设置到HTTP头字段’Nano-Session’中,用于请求鉴权

Example URI

POST http://nanos.cloud/api/v1/sessions/
Request  创建新会话
HideShow
Headers
Content-Type: application/json
Body
{
  "user": "alex",
  "password": "abcdef",
  "nonce": "1234567890"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "user": {
      "type": "string",
      "description": "鉴权账号名"
    },
    "password": {
      "type": "string",
      "description": "鉴权密码"
    },
    "nonce": {
      "type": "string",
      "description": "加密用随机字符串"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "session": "bsu6384js3=",
      "timeout": 120
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "session": {
          "type": "string",
          "description": "分配的会话ID"
        },
        "timeout": {
          "type": "number",
          "description": "会话超时时间(秒)"
        }
      }
    }
  }
}

更新会话
PUT/sessions/{session_id}

更新会话,使其保持会话处于活动状态

Example URI

PUT http://nanos.cloud/api/v1/sessions/session_id
URI Parameters
HideShow
session_id
string (required) 

会话ID

Request  会话保活
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

获取已校验会话信息
GET/sessions/{session_id}

查询已校验会话的关联绑定信息

Example URI

GET http://nanos.cloud/api/v1/sessions/session_id
URI Parameters
HideShow
session_id
string (required) 

会话ID

Request  获取已校验会话信息
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
{
  "error_code": 0,
  "message": "",
  "data":{
    "menu": ["dashboard", "compute\_pool", "address\_pool", "instance"],
    "resource": [],
    "user": "nano",
    "group": "admin",
    "address": "192.168.1.100"
  }
}
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "user": {
          "type": "string",
          "description": "已认证用户名"
        },
        "group": {
          "type": "string",
          "description": "已认证用户组"
        },
        "address": {
          "type": "string",
          "description": "请求会话的客户端IP"
        },
        "menu": {
          "type": "array",
          "description": "授权的菜单权限清单"
        },
        "resource": {
          "type": "array",
          "description": "已分配资源清单"
        }
      }
    }
  }
}

资源可见性

管理已登录用户相关的资源可见性配置

查询资源可见性
GET/resource_visibilities/

获取当前用户的资源可见性配置

Example URI

GET http://nanos.cloud/api/v1/resource_visibilities/
Request  查询资源可见性
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": "",
    "data": {
      "instance_visible": true,
      "media_image_visible": true,
      "disk_image_visible": false
    }
  }
]

设置资源可见性
PUT/resource_visibilities/

修改当前登录用户关联的资源可见性配置

Example URI

PUT http://nanos.cloud/api/v1/resource_visibilities/
Request  设置资源可见性
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "instance_visible": true,
  "media_image_visible": true,
  "disk_image_visible": false
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "instance_visible": {
      "type": "boolean",
      "description": "是否允许访问同组云主机实例"
    },
    "media_image_visible": {
      "type": "boolean",
      "description": "是否允许访问同组光盘镜像"
    },
    "disk_image_visible": {
      "type": "boolean",
      "description": "是否允许访问同组磁盘镜像"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

操作日志

平台操作日志管理接口

查询日志清单
GET/logs/{?limit,start,after,before}

根据条件查询系统操作日志

Example URI

GET http://nanos.cloud/api/v1/logs/?limit=&start=&after=&before=
URI Parameters
HideShow
limit
number (required) 

最大返回日志数量

start
number (optional) 

日志查询偏移

after
string (optional) 

查询本日期之后的日志

before
string (optional) 

查询本日期之前的日志

Request  查询日志清单
HideShow
Headers
Nano-session: 1234567890-abcdef
Response  200
HideShow
Headers
Content-Type: application/json
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
    }
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    },
    "data": {
      "type": "object",
      "properties": {
        "logs": {
          "type": "array"
        },
        "total": {
          "type": "number",
          "description": "总日志数量"
        }
      }
    }
  }
}

添加操作日志
POST/logs/

添加单条操作日志

Example URI

POST http://nanos.cloud/api/v1/logs/
Request  添加操作日志
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "format": "string",
  "content": "here is a new log for somebody creating a new instance"
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "description": "日志格式"
    },
    "content": {
      "type": "string",
      "description": "日志内容"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

删除操作日志
DELETE/logs/

删除操作日志

Example URI

DELETE http://nanos.cloud/api/v1/logs/
Request  删除操作日志
HideShow
Headers
Content-Type: application/json
Nano-session: 1234567890-abcdef
Body
{
  "entries": [
    "201812011457390001",
    "201812031427190001"
  ]
}
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "entries": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "需要删除的日志ID清单"
    }
  }
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "error_code": 0,
    "message": ""
  }
]
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "error_code": {
      "type": "number",
      "description": "错误编码,0为成功"
    },
    "message": {
      "type": "string",
      "description": "错误信息,成功时为空"
    }
  }
}

Generated by aglio on 10 Feb 2021