5.0.0 • Published 6 years ago

multi-cloud-vdc-service v5.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

multi-cloud-vdc-service

Start

npm install

#develop environment
npm run dev 

#production environment
npm start

#build es7 code to es5.
npm run build

API

current version = v1

header

创建VDC

post: /multi-cloud-vdc-service/:version/vdcs

body:

{
  "name": "test-vdc",
  "description": "description",
  "projects": [
    {
      "id": "33"
    }
  ]
}

response:

{
  "created_at": 1492760487000,
  "updated_at": 1492760487000,
  "id": 13,
  "name": "testvdc",
  "description": "description"
}

修改VDC

put: /multi-cloud-vdc-service/:version/vdcs/:vdcId

body:

{
  "name": "test",
  "description": "test"
}

response:

{
  "created_at": 1492531290000,
  "updated_at": 1492763771000,
  "id": 9,
  "name": "feng",
  "description": "test"
}

获取VDC列表

get: /multi-cloud-vdc-service/:version/vdcs

params:

KeyValue
pageIndex
pagesize
all
userId

response:

{
  "pageSize": 15,
  "pageIndex": 1,
  "totalCount": 11,
  "list": [
    {
      "created_at": 1492530539000,
      "updated_at": 1492530539000,
      "id": 2,
      "name": "test-vdc",
      "description": "description"
    },
    /* ignore */
  ]
}

获取VDC详情

get: /multi-cloud-vdc-service/:version/vdcs/:vdcId

response:

{
  "created_at": 1492531290000,
  "updated_at": 1492531290000,
  "id": 9,
  "name": "test-vdc",
  "description": "description",
  "projects": [
    {
      "id": 1,
      "openstackProjectId": "31eaaf30-2410-11e7-a6c5-2f821f4426e9",
      "name": "test-1",
      "description": "test-1",
      "vdcId": 9,
      "cloudId": 1
    },
    /* ignore */
  ],
  "users": [
    {
      "id": 2,
      "vdcId": 9,
      "userId": "31eaaf30-2410-11e7-a6c5-2f821f4426e9"
    },
    /* ignore */
  ],
  "quota": [
    {
      "id": 1,
      "vdcId": 9,
      "typeId": 1,
      "limitSize": -1,
      "usedSize": 0,
      "version": 0
    },
    /* ignore */
  ]
}

获取关联VDC用户列表

get: multi-cloud-service/:version/vdcs/:vdcId/users

params:

KeyValue
pageIndex
pageSize

response:

{
  "created_at": 1492531290000,
  "updated_at": 1492531290000,
  "id": 9,
  "name": "test-vd3cf2f",
  "description": "description",
  "users": [
    {
      "created_at": 1492503761000,
      "updated_at": 1492503761000,
      "uuid": "30db6210-2410-11e7-a6c5-2f821f4426e9",
      "username": "test124532",
      "phone": "18742038812",
      "email": "test@test.com",
      "status": "enable",
      "roleId": 2,
      "role": {
        "id": 2,
        "key": "member",
        "name": "普通用户",
        "description": "普通用户"
      }
    },
    /* ignore */
  ],
  "userTotalCount": 2
}

获取VDC资源配额

get: /multi-cloud-service/:version/vdcs/:vdcId/quotas

response:

[
  {
    "id": "2",
    "quotaId": 3,
    "quotaKey": "quota.vm.ram",
    "quotaName": "云主机内存",
    "typeId": 1,
    "typeKey": "vm",
    "typeName": "云主机",
    "typeDescription": "云主机",
    "unit": "个",
    "limitSize": 111,
    "usedSize": 0,
    "version": 1
  },
  /* ignore */
]

关联用户到VDC

put: /multi-cloud-vdc-service/:version/vdcs/:vdcId/association/users

body:

[
  "31ead640-2410-11e7-a6c5-2f821f4426e9",
  "30db6210-2410-11e7-a6c5-2f821f4426e9",
  "31eaaf30-2410-11e7-a6c5-2f821f4426e9"
]

response:

备注:只返回成功关联的用户Id。

[
  "30db6210-2410-11e7-a6c5-2f821f4426e9",
  "31eaaf30-2410-11e7-a6c5-2f821f4426e9"
]

查询用户与VDC关联情况

get: /multi-cloud-vdc-service/:version/vdc-user-associations

params:

KeyValue
userIds"759c1c30-2a43-11e7-9ce5-7b2b6a43b4a9"

response:

[
  {
    "id": 1,
    "vdcId": 22,
    "userId": "759c1c30-2a43-11e7-9ce5-7b2b6a43b4a9",
    "vdc": {
      "created_at": 1494212990000,
      "updated_at": 1494212990000,
      "deleted_at": "",
      "id": 22,
      "name": "feng-vdc",
      "description": "create from vdc"
    }
  }
]

关联项目到VDC

put: /multi-cloud-vdc-service/:version/vdcs/:vdcId/association/projects

body:

[
  1,
  2,
  3
]

response:

备注:只返回成功关联的项目。

{
  "totalCount": 2,
  "list": [
    {
      "id": 1,
      "openstackProjectId": "123",
      "name": "test-1",
      "description": "test-1",
      "vdcId": "2",
      "cloudId": 1
    },
    /* ignore */
  ]
}

修改配额

put: /multi-cloud-vdc-service/:version/vdcs/:vdcId/quotas/:quotaId

body:

{
  "limitSize": 10
}

response:

{
  "id": 2,
  "vdcId": 2,
  "quotaId": 3,
  "limitSize": "111",
  "usedSize": 0,
  "version": 1
}

创建项目

post: /multi-cloud-vdc-service/:version/projects

body:

{
  "name": "test",
  "description": "description",
  "vdcId": 9,
  "cloudId": 5
}

response:

{
  "id": 9,
  "name": "test",
  "description": "description",
  "vdcId": 9,
  "cloudId": 5,
  "openstackProjectId": "31ead640-2410-11e7-a6c5-2f821f4426e9"
}

获取项目列表

get: /multi-cloud-vdc-service/:version/projects

params:

KeyValue
pageIndex
pagesize
all

response:

{
  "pageSize": 15,
  "pageIndex": 1,
  "totalCount": 4,
  "list": [
    {
      "id": 1,
      "openstackProjectId": "31eaaf30-2410-11e7-a6c5-2f821f4426e9",
      "name": "test-1",
      "description": "test-1",
      "vdcId": 9,
      "cloudId": 1
    },
    /* ignore */
  ]
}

获取项目详情

get: /multi-cloud-vdc-service/:version/projects/:projectId

response:

{
  "id": 2,
  "openstackProjectId": "31eaaf30-2410-11e7-a6c5-2f821f4426e9",
  "name": "test",
  "description": "test",
  "vdcId": 9,
  "cloudId": 1,
  "vdc": {
    "created_at": 1492531290000,
    "updated_at": 1492531290000,
    "id": 9,
    "name": "test-vdc",
    "description": "description"
  }
}

修改项目

put: /multi-cloud-vdc-service/:version/projects/:projectId

body:

{
  "name": "test",
  "description": "description"
}

response:

{
  "id": 2,
  "openstackProjectId": "31eaaf30-2410-11e7-a6c5-2f821f4426e9",
  "name": "test",
  "description": "description",
  "vdcId": 9,
  "cloudId": 1
}

获取卷列表

get: /multi-cloud-vdc-service/:version/resources/projects/:projectId/volumes

params:

KeyValue
pageIndex
pagesize
all
statussuccess/error/timeout/creating/updating/deleting

response:

{
  "pageSize": 15,
  "pageIndex": 1,
  "totalCount": 3,
  "list": [
    {
      "deleted_at": "",
      "id": 92,
      "uuid": "d3a19276-254a-40e2-acee-59514768a3fe",
      "projectId": 14,
      "typeId": 2,
      "status": "success",
      "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
      "owner": null,
      "volume": {
        "migration_status": null,
        "attachments": [],
        "links": [
          {
            "href": "http://192.168.0.50:8776/v2/bda668f46d9c43bc9cc29eeb9d03378e/volumes/d3a19276-254a-40e2-acee-59514768a3fe",
            "rel": "self"
          },
          {
            "href": "http://192.168.0.50:8776/bda668f46d9c43bc9cc29eeb9d03378e/volumes/d3a19276-254a-40e2-acee-59514768a3fe",
            "rel": "bookmark"
          }
        ],
        "availability_zone": "nova",
        "os-vol-host-attr:host": "ds@ds#ds",
        "encrypted": false,
        "updated_at": "2017-05-04T08:51:24.000000",
        "replication_status": "disabled",
        "snapshot_id": null,
        "id": "d3a19276-254a-40e2-acee-59514768a3fe",
        "size": 16,
        "user_id": "f63dcacdcae24ad2aeffcc0736472d8d",
        "copies": 3,
        "os-vol-tenant-attr:tenant_id": "bda668f46d9c43bc9cc29eeb9d03378e",
        "os-vol-mig-status-attr:migstat": null,
        "metadata": {},
        "status": "available",
        "description": null,
        "multiattach": false,
        "source_volid": null,
        "consistencygroup_id": null,
        "os-vol-mig-status-attr:name_id": null,
        "name": "volume-test-2",
        "bootable": "false",
        "created_at": "2017-05-04T08:35:24.000000",
        "volume_type": "default"
      }
    },
    /* ignore */
  ]
}

获取卷详情

get: /multi-cloud-vdc-service/:version/resources/projects/:projectId/volumes/:volumeId

response:

{
  "deleted_at": "",
  "id": 92,
  "uuid": "d3a19276-254a-40e2-acee-59514768a3fe",
  "projectId": 14,
  "typeId": 2,
  "status": "success",
  "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
  "owner": null,
  "volume": {
    "migration_status": null,
    "attachments": [],
    "links": [
      {
        "href": "http://192.168.0.50:8776/v2/bda668f46d9c43bc9cc29eeb9d03378e/volumes/d3a19276-254a-40e2-acee-59514768a3fe",
        "rel": "self"
      },
      {
        "href": "http://192.168.0.50:8776/bda668f46d9c43bc9cc29eeb9d03378e/volumes/d3a19276-254a-40e2-acee-59514768a3fe",
        "rel": "bookmark"
      }
    ],
    "availability_zone": "nova",
    "os-vol-host-attr:host": "ds@ds#ds",
    "encrypted": false,
    "updated_at": "2017-05-04T08:51:24.000000",
    "replication_status": "disabled",
    "snapshot_id": null,
    "id": "d3a19276-254a-40e2-acee-59514768a3fe",
    "size": 16,
    "user_id": "f63dcacdcae24ad2aeffcc0736472d8d",
    "copies": 3,
    "os-vol-tenant-attr:tenant_id": "bda668f46d9c43bc9cc29eeb9d03378e",
    "os-vol-mig-status-attr:migstat": null,
    "metadata": {},
    "status": "available",
    "description": null,
    "multiattach": false,
    "source_volid": null,
    "consistencygroup_id": null,
    "os-vol-mig-status-attr:name_id": null,
    "name": "volume-test-2",
    "bootable": "false",
    "created_at": "2017-05-04T08:35:24.000000",
    "volume_type": "default"
  }
}

创建卷

post: /multi-cloud-vdc-service/:version/resources/projects/:projectId/volumes

body:

{
  "name": "volume-test",
  "size": 10
}

response:

{
  "deleted_at": "",
  "id": 94,
  "projectId": "14",
  "typeId": 2,
  "status": "creating",
  "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
  "uuid": "ce5522f2-6cc3-496f-9333-43a770c6ac8e",
  "volume": {
    "migration_status": null,
    "attachments": [],
    "links": [
      {
        "href": "http://192.168.0.50:8776/v2/bda668f46d9c43bc9cc29eeb9d03378e/volumes/ce5522f2-6cc3-496f-9333-43a770c6ac8e",
        "rel": "self"
      },
      {
        "href": "http://192.168.0.50:8776/bda668f46d9c43bc9cc29eeb9d03378e/volumes/ce5522f2-6cc3-496f-9333-43a770c6ac8e",
        "rel": "bookmark"
      }
    ],
    "availability_zone": "nova",
    "encrypted": false,
    "updated_at": null,
    "replication_status": "disabled",
    "snapshot_id": null,
    "id": "ce5522f2-6cc3-496f-9333-43a770c6ac8e",
    "size": 10,
    "user_id": "f63dcacdcae24ad2aeffcc0736472d8d",
    "copies": null,
    "metadata": {},
    "status": "creating",
    "description": null,
    "multiattach": false,
    "source_volid": null,
    "consistencygroup_id": null,
    "name": "volume-test-2",
    "bootable": "false",
    "created_at": "2017-05-04T10:26:06.265081",
    "volume_type": "default"
  }
}

扩展卷

put: /multi-cloud-vdc-service/:version/resources/projects/:projectId/volumes/:volumeId

body:

{
  "new_size": 16
}

response:

{
  "deleted_at": "",
  "id": 92,
  "uuid": "d3a19276-254a-40e2-acee-59514768a3fe",
  "projectId": 14,
  "typeId": 2,
  "status": "error",
  "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
  "owner": null
}

删除卷

delete: /multi-cloud-vdc-service/:version/resources/projects/:projectId/volumes/:volumeId

创建快照

post: /multi-cloud-vdc-service/:version/resources/projects/:projectId/snapshots

body:

{
  "name": "snapshot-test",
  "description": "test",
  "volumeId": "211bc72b-b563-4ee1-a0e5-7e08463c0adc"
}

response:

{
  "deleted_at": "",
  "id": 108,
  "uuid": "ca40e398-dda3-4e1c-a692-d585e55114d9",
  "projectId": 22,
  "typeId": 3,
  "status": "error",
  "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
  "owner": null,
  "snapshot": {
    "status": "creating",
    "description": "test-desc",
    "updated_at": null,
    "volume_id": "a3774a4c-2c04-48b8-8cc7-afb3cba88ea3",
    "id": "ca40e398-dda3-4e1c-a692-d585e55114d9",
    "size": 10,
    "os-extended-snapshot-attributes:progress": "0%",
    "name": "test-snapshot",
    "os-extended-snapshot-attributes:project_id": "148c5262ef6843e997064736fa30490c",
    "created_at": "2017-05-05T03:28:44.000000",
    "metadata": {}
  }
}

获取快照详情

get: /multi-cloud-vdc-service/:version/resources/projects/:projectId/snapshots/:snapshotId

response:

{
  "deleted_at": "",
  "id": 108,
  "uuid": "ca40e398-dda3-4e1c-a692-d585e55114d9",
  "projectId": 22,
  "typeId": 3,
  "status": "error",
  "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
  "owner": null,
  "snapshot": {
    "status": "creating",
    "description": "test-desc",
    "updated_at": null,
    "volume_id": "a3774a4c-2c04-48b8-8cc7-afb3cba88ea3",
    "id": "ca40e398-dda3-4e1c-a692-d585e55114d9",
    "size": 10,
    "os-extended-snapshot-attributes:progress": "0%",
    "name": "test-snapshot",
    "os-extended-snapshot-attributes:project_id": "148c5262ef6843e997064736fa30490c",
    "created_at": "2017-05-05T03:28:44.000000",
    "metadata": {}
  }
}

获取快照列表

get: /multi-cloud-vdc-service/:version/resources/projects/:projectId/snapshots

params:

KeyValue
pageIndex
pagesize
all
statussuccess/error/timeout/creating/updating/deleting

response:

{
  "pageSize": 15,
  "pageIndex": 1,
  "totalCount": 1,
  "list": [
    {
      "deleted_at": "",
      "id": 108,
      "uuid": "ca40e398-dda3-4e1c-a692-d585e55114d9",
      "projectId": 22,
      "typeId": 3,
      "status": "error",
      "creator": "18221900-2a44-11e7-9ce5-7b2b6a43b4a9",
      "owner": null,
      "snapshot": {
        "status": "creating",
        "description": "test-desc",
        "updated_at": null,
        "volume_id": "a3774a4c-2c04-48b8-8cc7-afb3cba88ea3",
        "id": "ca40e398-dda3-4e1c-a692-d585e55114d9",
        "size": 10,
        "os-extended-snapshot-attributes:progress": "0%",
        "name": "test-snapshot",
        "os-extended-snapshot-attributes:project_id": "148c5262ef6843e997064736fa30490c",
        "created_at": "2017-05-05T03:28:44.000000",
        "metadata": {}
      }
    },
    /* ignore */
  ]
}

删除快照

delete: /multi-cloud-vdc-service/:version/resources/projects/:projectId/snapshots/:snapshotId

Error Codes

CodeMean
102001创建VDC失败
102002VDC ID为空
102003VDC ID不正确
102004VDC 名称为空
102005VDC 不存在
102006VDC 被使用
102007VDC 删除失败
102008名称重复
102009项目ID为空
102010项目名称为空
102011项目不存在
102012项目被使用
102013项目删除失败
102014云ID为空
102015项目创建失败
102016项目更新失败
102017配额size不能低于当前使用值
102018配额size为空或不正确
102019配额更新冲突
102020没有配额供使用
102021配额不存在
102022资源类型不存在
102023无效的用户列表
102024资源不存在
102025资源与类型不匹配
102026配额未找到
102027资源名称为空
102028资源大小不是整数
102029未找到管理员用户
102030不期望发生的异常,未知异常
102031资源操作冲突
102032资源ID为空
102033无效的资源