multi-cloud-vdc-service

5.0.0 • Public • Published

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:

Key Value
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:

Key Value
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:

Key Value
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:

Key Value
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:

Key Value
pageIndex
pagesize
all
status success/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:

Key Value
pageIndex
pagesize
all
status success/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

Code Mean
102001 创建VDC失败
102002 VDC ID为空
102003 VDC ID不正确
102004 VDC 名称为空
102005 VDC 不存在
102006 VDC 被使用
102007 VDC 删除失败
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 无效的资源

Package Sidebar

Install

npm i multi-cloud-vdc-service

Weekly Downloads

2

Version

5.0.0

License

ISC

Last publish

Collaborators

  • zfeng