disks api doc

This commit is contained in:
wanyaoqi
2019-07-27 12:47:30 +08:00
parent 04548e8156
commit f7731626be
16 changed files with 647 additions and 2 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ swagger文档,https://swagger.io/docs/specification/2-0/basic-structure/
1. 首先启动swagger-ui
sudo docker pull swaggerapi/swagger-ui
sudo docker run -p 80:8080 swaggerapi/swagger-ui
sudo docker run -d -p 80:8080 swaggerapi/swagger-ui
2. 用python启动本地的http server,这是允许CORS的SimpleHTTPServer,监听在8000端口
+16
View File
@@ -0,0 +1,16 @@
post:
summary: 磁盘创建快照
parameters:
- $ref: '../parameters/disk.yaml#/diskId'
- in: body
name: server
required: true
schema:
$ref: '../schemas/disk.yaml#/DiskCreateSanpshot'
responses:
200:
description: 磁盘信息
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
+39
View File
@@ -0,0 +1,39 @@
get:
summary: 获取指定磁盘详情信息
parameters:
- $ref: '../parameters/disk.yaml#/diskId'
responses:
200:
description: 磁盘信息
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
put:
summary: 更新磁盘信息
parameters:
- $ref: '../parameters/disk.yaml#/diskId'
- in: body
name: server
required: true
schema:
$ref: '../schemas/disk.yaml#/DiskUpdate'
responses:
200:
description: 磁盘信息
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
delete:
summary: 删除指定磁盘
parameters:
- $ref: '../parameters/disk.yaml#/diskId'
- $ref: '../parameters/common.yaml#/override_pending_delete'
responses:
200:
description: 被删除磁盘的信息,删除前确保已解除删除保护,第一次删除时会先进入回收站(可恢复),第二次删除会真正释放资源
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
+37
View File
@@ -0,0 +1,37 @@
get:
summary: 按指定条件列出磁盘
parameters:
- $ref: '../parameters/common.yaml#/offset'
- $ref: '../parameters/common.yaml#/limit'
- $ref: '../parameters/common.yaml#/pending_delete'
- $ref: '../parameters/common.yaml#/provider'
- $ref: '../parameters/common.yaml#/billing_type'
- $ref: '../parameters/disk.yaml#/unused'
- $ref: '../parameters/disk.yaml#/share'
- $ref: '../parameters/disk.yaml#/local'
- $ref: '../parameters/disk.yaml#/guest'
- $ref: '../parameters/disk.yaml#/storage'
- $ref: '../parameters/disk.yaml#/type'
- $ref: '../parameters/disk.yaml#/cloud_type'
responses:
200:
description: 磁盘列表信息
schema:
$ref: "../schemas/disk.yaml#/DiskListResponse"
tags:
- disk
post:
summary: 创建磁盘
parameters:
- in: body
name: disk
required: true
schema:
$ref: '../schemas/disk.yaml#/DiskCreate'
responses:
200:
description: 新建磁盘信息
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
+12
View File
@@ -0,0 +1,12 @@
post:
summary: 取消磁盘共享
parameters:
- $ref: "../parameters/disk.yaml#/diskId"
responses:
200:
description: 磁盘信息
schema:
$ref: "../schemas/disk.yaml#DiskResponse"
tags:
- disk
+12
View File
@@ -0,0 +1,12 @@
post:
summary: 磁盘共享
parameters:
- $ref: "../parameters/disk.yaml#/diskId"
responses:
200:
description: 磁盘信息
schema:
$ref: "../schemas/disk.yaml#DiskResponse"
tags:
- disk
+12
View File
@@ -0,0 +1,12 @@
post:
summary: 清除磁盘数据库记录
parameters:
- $ref: "../parameters/disk.yaml#/diskId"
responses:
200:
description: 磁盘信息
schema:
$ref: "../schemas/disk.yaml#DiskResponse"
tags:
- disk
+17
View File
@@ -0,0 +1,17 @@
post:
summary: 回滚磁盘到指定快照
parameters:
- $ref: "../parameters/disk.yaml#/diskId"
- in: body
name: disk
required: true
schema:
$ref: '../schemas/disk.yaml#/DiskReset'
responses:
200:
description: 磁盘信息
schema:
$ref: "../schemas/disk.yaml#DiskResponse"
tags:
- disk
+16
View File
@@ -0,0 +1,16 @@
post:
summary: 扩容磁盘
parameters:
- $ref: '../parameters/disk.yaml#/diskId'
- in: body
name: server
required: true
schema:
$ref: '../schemas/disk.yaml#/DiskResize'
responses:
200:
description: 磁盘信息
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
+16
View File
@@ -0,0 +1,16 @@
post:
summary: 磁盘保存镜像
parameters:
- $ref: '../parameters/disk.yaml#/diskId'
- in: body
name: server
required: true
schema:
$ref: '../schemas/disk.yaml#/DiskSave'
responses:
200:
description: 磁盘信息
schema:
$ref: '../schemas/disk.yaml#/DiskResponse'
tags:
- disk
+40
View File
@@ -0,0 +1,40 @@
get:
summary: 获取指定宿主机详情信息
parameters:
- $ref: '../parameters/host.yaml#/hostId'
- $ref: '../parameters/common.yaml#/pending_delete'
responses:
200:
description: 宿主机信息
schema:
$ref: '../schemas/host.yaml#/HostResponse'
tags:
- host
put:
summary: 更新宿主机信息
parameters:
- $ref: '../parameters/host.yaml#/hostId'
- in: body
name: host
required: true
schema:
$ref: '../schemas/host.yaml#/HostUpdate'
responses:
200:
description: 宿主机信息
schema:
$ref: '../schemas/host.yaml#/HostResponse'
tags:
- host
delete:
summary: 删除指定宿主机
parameters:
- $ref: '../parameters/host.yaml#/hostId'
- $ref: '../parameters/common.yaml#/override_pending_delete'
responses:
200:
description: 被删除宿主机的信息,删除前确保已解除删除保护
schema:
$ref: '../schemas/host.yaml#/HostResponse'
tags:
- host
+44
View File
@@ -0,0 +1,44 @@
get:
summary: 按指定条件列出宿主机
parameters:
- $ref: '../parameters/common.yaml#/limit'
- $ref: '../parameters/common.yaml#/offset'
- $ref: '../parameters/common.yaml#/provider'
- $ref: '../parameters/common.yaml#/zone'
- $ref: '../parameters/common.yaml#/wire'
- $ref: '../parameters/common.yaml#/vpc'
- $ref: '../parameters/common.yaml#/region'
- $ref: '../parameters/host.yaml#/enable'
- $ref: '../parameters/host.yaml#/disable'
- $ref: '../parameters/host.yaml#/host_type'
- $ref: '../parameters/host.yaml#/is_empty'
- $ref: '../parameters/host.yaml#/sotrage'
- $ref: '../parameters/host.yaml#/usable'
- $ref: '../parameters/host.yaml#/hypervisor'
- $ref: '../parameters/host.yaml#/any_mac'
- $ref: '../parameters/host.yaml#/cachedimage'
- $ref: '../parameters/host.yaml#/is_baremetal'
- $ref: '../parameters/host.yaml#/resource_type'
- $ref: '../parameters/host.yaml#/storage_not_attached'
responses:
200:
description: 宿主机列表信息
schema:
$ref: '../schemas/host.yaml#/HostListResponse'
tags:
- host
post:
summary: 创建宿主机
parameters:
- in: body
name: host
required: true
schema:
$ref: '../schemas/host.yaml#/HostCreate'
responses:
200:
description: 新创建的宿主机信息
schema:
$ref: '../schemas/host.yaml#/HostResponse'
tags:
- host
+74
View File
@@ -49,6 +49,80 @@ paths:
/storages/{storageId}/offline:
$ref: "./storage/storage.yaml#/offline"
/disks:
$ref: "./disk/disks.yaml"
/disks/{diskId}:
$ref: "./disk/disk.yaml"
/disks/{diskId}/resize:
$ref: "./disk/resize.yaml"
/disks/{diskId}/save:
$ref: "./disk/save.yaml"
/disks/{diskId}/private:
$ref: "./disk/private.yaml"
/disks/{diskId}/public:
$ref: "./disk/public.yaml"
/disks/{diskId}/purge:
$ref: "./disk/purge.yaml"
/disks/{diskId}/reset:
$ref: "./disk/reset.yaml"
/disks/{diskId}/create-snapshot:
$ref: "./disk/create-snapshot.yaml"
/hosts:
$ref: "./host/hosts.yaml"
/hosts/{hostId}:
$ref: "./host/hosts.yaml"
/hosts/{hostId}/ping:
$ref: "./host/ping.yaml"
/hosts/{hostId}/enable:
$ref: "./host/enable.yaml"
/hosts/{hostId}/disable:
$ref: "./host/disable.yaml"
/hosts/{hostId}/syncstatus:
$ref: "./host/syncstatus.yaml"
/hosts/{hostId}/prepare:
$ref: "./host/prepare.yaml"
/hosts/{hostId}/ipmi:
$ref: "./host/ipmi.yaml"
/hosts/{hostId}/logininfo:
$ref: "./host/logininfo.yaml"
/hosts/{hostId}/vnc:
$ref: "./host/vnc.yaml"
/hosts/{hostId}/convert-hypervisor:
$ref: "./host/convert-hypervisor.yaml"
/hosts/{hostId}/undo-convert:
$ref: "./host/undo-convert.yaml"
/hosts/{hostId}/maintenance:
$ref: "./host/maintenance.yaml"
/hosts/{hostId}/unmaintenance:
$ref: "./host/unmaintenance.yaml"
/hosts/{hostId}/stop:
$ref: "./host/stop.yaml"
/hosts/{hostId}/start:
$ref: "./host/start.yaml"
/hosts/{hostId}/reset:
$ref: "./host/reset.yaml"
/hosts/{hostId}/add-netif:
$ref: "./host/add-netif.yaml"
/hosts/{hostId}/remove-netif:
$ref: "./host/remove-netif.yaml"
/hosts/{hostId}/enable-netif:
$ref: "./host/enable-netif.yaml"
/hosts/{hostId}/disable-netif:
$ref: "./host/disable-netif.yaml"
/hosts/{hostId}/remove-all-netifs:
$ref: "./host/remove-all-netifs.yaml"
/hosts/{hostId}/cache-image:
$ref: "./host/cache-image.yaml"
/hosts/{hostId}/uncache-image:
$ref: "./host/uncache-image.yaml"
/hosts/{hostId}/undo-prepaid-recycle:
$ref: "./host/undo-prepaid-recycle.yaml"
/hosts/{hostId}/renew-prepaid-recycle:
$ref: "./host/renew-prepaid-recycle.yaml"
/hosts/{hostId}/spec:
$ref: "./host/spec.yaml"
/hoststorages:
$ref: "./hoststorage/hoststorage.yaml"
/hosts/{hostId}/storages/{storageId}:
+51
View File
@@ -0,0 +1,51 @@
diskId:
name: diskId
required: true
in: path
type: string
description: 磁盘名称或ID
unused:
name: unused
required: false
in: query
type: boolean
description: 列出未挂载磁盘
share:
name: share
required: false
in: query
type: boolean
description: 列出共享磁盘
local:
name: local
required: false
in: query
type: boolean
description: 列出本地磁盘
guest:
name: guest
required: false
in: query
type: string
description: 列出改虚拟机的磁盘
storage:
name: storage
required: false
in: query
type: string
description: 列出改存储的磁盘
type:
name: type
required: false
in: query
type: string
enum: [sys,data,swap,volume]
description: 列出改类型的磁盘
cloud_type:
name: cloud_type
required: false
in: query
type: string
enum: [Public,Private]
description: 列出公有云或私有云的磁盘
+257
View File
@@ -0,0 +1,257 @@
Disk:
type: object
description: 磁盘
properties:
id:
type: string
example: ea27c0ce-5870-49f3-8d57-f53e63f40361
description: 磁盘uuid
readOnly: true
name:
type: string
description: 磁盘名称
example: disk-r4hilqks
readOnly: true
billing_type:
type: string
description: 计费类型
example: postpaid
readOnly: true
account:
type: string
example: office-qcloud
description: 所属云账号名称
account_id:
type: string
description: 所属云账号ID
brand:
type: string
example: DStack
description: 虚拟化品牌
created_at:
type: string
example: 2019-05-30T02:25:38.000000Z
description: 资源创建时间
external_id:
type: string
example: disk-r4hilqks
description: 磁盘外部ID,对应的纳管云磁盘ID
pending_deleted:
type: boolean
example: false
description: 是否在回收站
provider:
type: string
example: Qcloud
description: 纳管云平台
region:
type: string
example: 腾讯云 华南地区(广州)
description: 区域名称
region_id:
type: string
example: 13947bd8-569e-4094-8b03-4339c2a8e45b
description: 区域ID
status:
type: string
example: ready
description: 资源状态
tenant:
type: string
example: system
description: 归属项目名称
tenant_id:
type: string
example: 29541006ae9148b9bf002fc294218022
description: 归属项目ID
update_version:
type: integer
example: 2
description: 资源被更新的次数
updated_at:
type: string
example: 2019-05-30T06:36:39.000000Z
description: 资源最近一次更新时间
zone:
type: string
example: 腾讯云 广州三区
description: 可用区名称
zone_ext_id:
type: string
example: ap-guangzhou-3
description: 可用区外部ID,对应纳管云可用区ID
zone_id:
type: string
example: a16d3e0b-3fd6-45ec-8b2d-e51a51fa0efc
description: 可用区ID
disk_format:
type: string
example: qcow2
description: 磁盘类型qcow2, vmdk vhd等
disk_size:
type: integer
example: 10240
description: 磁盘大小,单位MB
access_path:
type: string
example: /opt/cloud/workspace/disks/a16d3e0b-3fd6-45ec-8b2d-e51a51fa0eff
description: 磁盘存储的路径
template_id:
type: string
example: a16d3e0b-3fd6-45ec-8b2d-e51a51fa0edd
description: 磁盘所用镜像ID
snapshot_id:
type: string
example: a16d3e0b-3fd6-45ec-8b2d-e51a51faccdd
description: 磁盘所用快照ID
fs_format:
type: string
example: ext3
description: 磁盘分区类型
disk_type:
type: string
example: system
description: 磁盘类型,系统盘,数据盘和交换分区
DiskResponse:
type: object
properties:
disk:
type: object
$ref: '#/Disk'
DiskListResponse:
type: object
properties:
limit:
type: integer
example: 20
disks:
type: array
items:
$ref: '#/Disk'
total:
type: integer
example: 124
DiskUpdate:
type: object
properties:
name:
type: string
example: other-name
desc:
type: string
description: desc of this disk
auto_delete:
type: string
enum: [enable, disable]
disk_type:
type: string
enum: [data, volume]
DiskResize:
type: object
properties:
size:
type: integer
example: 20G
description: 扩容后磁盘大小
DiskSave:
type: object
properties:
name:
type: string
example: centos
description: 镜像名称
public:
type: boolean
example: true
description: 是否共享
format:
type: string
example: qcow2
enum: [vmdk, qocw2]
description: 镜像格式
notes:
type: string
description: notes about the image
os_type:
type: object
$ref: "#/OsType"
OsType:
type: object
properties:
properties:
type: string
enum: [Linux,Windows,VMware]
description: 镜像操作系统类型
DiskReset:
type: object
required: [snapshot_id]
properties:
auto_start:
type: boolean
description: 回滚磁盘后自动启动虚拟机
snapshot_id:
type: string
description: 要回滚的快照Id
DiskCreate:
type: object
properties:
prefer_region:
type: string
example: Default
description: 区域名称或ID(指定调度区域,若此区域资源不足会导致磁盘创建失败)
prefer_zone:
type: string
example: Zone-1
description: 可用区名称或ID(指定调度可用区,若此可用区资源不足会导致磁盘创建失败,此优先级高于prefer_region)
prefer_host:
type: string
example: e621b7c6-cb38-48a3-81bd-1f3a9cc07161
description: 宿主机名称或ID(指定调度宿主机,若宿主机上资源不足会导致磁盘创建失败,此优先级高于prefer_zone)
prefix_wire:
type: string
example: 572f250d-5a68-4471-8c1a-02568c7920fb
description: 二层网络名称或ID(指定关联的二层网络,优先级高于prefer_zone)
name:
type: string
example: test-disk
description: 磁盘名称
hypervisor:
type: string
example: qcloud
enum: [kvm,esxi,baremetal,container,aliyun,azure,qcloud,aws,huawei,openstack,ucloud,zstack]
description: 指定创建磁盘平台
size:
type: integer
example: 10240
description: disk size 单位MB
fs:
type: string
example: ext4
description: 磁盘分区格式
format:
type: string
example: qcow2
description: 磁盘格式
driver:
type: string
example: scsi
description: 磁盘驱动类型
backend:
type: string
example: local
description: 存储格式
DiskCreateSanpshot:
type: object
properties:
name:
type: string
description: snapshot name
+3 -1
View File
@@ -3,10 +3,12 @@
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
BaseHTTPServer.test(CORSRequestHandler, BaseHTTPServer.HTTPServer)