云服务器内容精选

  • 操作步骤 查询密钥列表。 接口相关信息 URI格式:POST /v1.0/{project_id}/kms/list-keys 详情请参见“查询密钥列表”。 请求示例 POST: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms/list-keys {endpoint}信息请从地区和终端节点获取。 Body: { "limit": "2", "marker": "1" } 响应示例 { "keys": [ "0d0466b0-e727-4d9c-b35d-f84bb474a37f", "2e258389-bb1e-4568-a1d5-e1f50adf70ea" ], "key_details": [ { "key_id":"0d0466b0-e727-4d9c-b35d-f84bb474a37f", "domain_id":"00074811d5c27c4f8d48bb91e4a1dcfd", "key_alias":"caseuirpr", "realm":"aaaa", "key_description":"123", "creation_date":"1502799822000", "scheduled_deletion_date":"", "key_state":"2", "default_key_flag":"0", "key_type":"1", "expiration_time":"1501578672000", "origin":"kms" }, { "key_id":"2e258389-bb1e-4568-a1d5-e1f50adf70ea", "domain_id":"00074811d5c27c4f8d48bb91e4a1dcfd", "key_alias":"casehvniz", "realm":"aaaa", "key_description":"234", "creation_date":"1502799820000", "scheduled_deletion_date":"", "key_state":"2", "default_key_flag":"0", "key_type":"1", "expiration_time":"1501578673000", "origin":"kms" } ], "next_marker": "", "truncated": "false", "total":2 } 查询密钥信息。 接口相关信息 URI格式:POST /v1.0/{project_id}/kms/describe-key 详情请参见“查询密钥信息”。 请求示例 POST: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms/describe-key {endpoint}信息请从地区和终端节点获取。 您可使用查询密钥列表接口获取当前用户密钥列表,包括key_id等信息 。 Body: { "key_id": "0d0466b0-e727-4d9c-b35d-f84bb474a37f" } 响应示例 { "key_info": { "key_id": "0d0466b0-e727-4d9c-b35d-f84bb474a37f", "domain_id": "b168fe00ff56492495a7d22974df2d0b", "key_alias": "kms_test", "realm": "aaa", "key_description": "", "creation_date": "1472442386000", "scheduled_deletion_date": "", "key_state": "2", "default_key_flag": "0", "key_type": "1", "expiration_time":"1501578672000", "origin":"kms", "key_rotation_enabled":"false", "sys_enterprise_project_id ": "0", } } 查询密钥实例。 接口相关信息 URI格式:POST /v1.0/{project_id}/kms/resource_instances/action 详情请参见“查询密钥实例”。 请求示例 POST: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms//resource_instances/action {endpoint}信息请从地区和终端节点获取。 Body: { "offset": "100", "limit": "100", "action": "filter", "matches":[ { "key": "resource_name", "value": "resource1" } ], "tags": [ { "key": "key1", "values": [ "value1", "value2" ] } ] } 响应示例 { "resources" : [ { "resource_id" : "90c03e67-5534-4ed0-acfa-89780e47a535", "resource_detail" : [ { "key_id" : "90c03e67-5534-4ed0-acfa-89780e47a535", "domain_id" : "4B688Fb77412Aee5570E7ecdbeB5afdc", "key_alias" : "tagTest_xmdmi", "key_description" : "123", "creation_date" : 1521449277000, "scheduled_deletion_date" : "", "key_state" : 2, "default_key_flag" : 0, "key_type" : 1, "key_rotation_enabled" : false, "expiration_time" : "", "origin" : "kms", "sys_enterprise_project_id" : "0", "realm" : "cn-north-7" } ], "resource_name" : "tagTest_xmdmi", "tags" : [ { "key" : "key", "value" : "testValue!" }, { "key" : "haha", "value" : "testValue" } ] } ], "total_count" : 1 } 查询密钥标签。 接口相关信息 URI格式:GET /v1.0/{project_id}/kms/{key_id}/tags 详情请参见“查询密钥标签”。 请求示例 GET: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms/94752282-805e-4032-ada8-34966f70e02f/tags {endpoint}信息请从地区和终端节点获取。 Body: 无 响应示例 { "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value3" } ], "existTagsNum":2 }
  • 操作步骤 创建云硬盘。 创建云硬盘。 接口相关信息 URI格式:POST /v2/{project_id}/volumes 详情请参见创建云硬盘。 请求示例 POST https://{endpoint}/v2/74610f3a5ad941998e91f076297ecf27/volumes {endpoint}信息请从地区和终端节点获取。 Body: { "volume": { "name": "openapi_vol02", "availability_zone":"az_test_01", "description": "create for api test", "volume_type": "SSD", "size": 40 } } 响应示例 { "volume": { "status": "creating", "user_id": "f79791beca3c48159ac2553fff22e166", "attachments": [], "links": [ { "href": "https://xxx/v2/74610f3a5ad941998e91f076297ecf27/volumes/51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "rel": "self" }, { "href": "https://xxx/74610f3a5ad941998e91f076297ecf27/volumes/51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "rel": "bookmark" } ], "availability_zone": "az_test_01", "bootable": "false", "encrypted": false, "created_at": "2018-05-16T11:19:33.992984", "description": "create for api test", "updated_at": null, "volume_type": "SSD", "name": "openapi_vol02", "replication_status": "disabled", "consistencygroup_id": null, "source_volid": null, "snapshot_id": null, "shareable": false, "multiattach": false, "metadata": { "__system__volume_name": "openapi_vol02" }, "id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "size": 40 } } 记录响应中“volume”的ID。 挂载磁盘。 接口相关信息 URI格式:POST /v1/{project_id}/cloudservers/{server_id}/attachvolume 详情请参见弹性云服务器挂载磁盘。 请求示例 POST https://{endpoint}/v1/74610f3a5ad941998e91f076297ecf27/cloudservers/9f4d9281-95e7-4915-a126-1ee597101e2e/attachvolume {endpoint}信息请从地区和终端节点获取。 Body: { "volumeAttachment": { "volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "device": "/dev/sdb", "volume_type": "SSD", "count": 5, "hw:passthrough": "true" }, "dry_run": false } 响应示例 { "job_id": "ff80808288d41e1b018990260955686a" } 确认挂载磁盘是否成功。 接口相关信息 URI格式:GET /v1/{project_id}/cloudservers/{server_id}/os-volume_attachments 详情请参见查询弹性云服务器挂载磁盘信息。 请求示例 GET https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments GET https://{endpoint}/v1/74610f3a5ad941998e91f076297ecf27/cloudservers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments {endpoint}信息请从地区和终端节点获取。 响应示例 { "volumeAttachments": [ { "device": "/dev/sda", "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", "serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e", "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" }, { "device": "/dev/sdb", "id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e", "volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3" } ] }
  • 操作步骤 获取用户Token,用于调用点播接口时进行认证鉴权。 详细信息请参见构造请求。以“华北-北京四”为示例,若您需要调用其它区域的点播接口,请替换成对应区域的 IAM 终端节点。 POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "password", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "projectname" } } } } 如图2所示,红框中的信息为获取用户Token。 图2 获取用户Token 调用创建媒资:上传方式接口,创建媒资,在请求头中增加“X-Auth-Token”字段,其中“Value”为步骤1获取的。 POST https://vod.cn-north-4.myhuaweicloud.com/v1.0/{project_id}/asset { "title": "test", "description": "test", "category_id": 87748, "video_name": "test.mp4", "video_type": "MP4", "cover_type": "PNG", "tags":"mytags,test", "auto_publish": 0, "template_group_name":"test", "subtitles":[ { "id":1, "language":"CN", "type": "SRT", "md5": "SqcyFjJZoDZaP8oKIY6rgQ==", "description":"AAAAA" , "name":"cc.srt" } ], "thumbnail":{ "type":"time", "cover_position":1 }, "review":{ "interval":10, "politics":-1, "terrorism":-1, "porn":-1 } } “vod.cn-north-4.myhuaweicloud.com”为点播服务的终端节点,您可以在VOD终端节点中获取。 “category_id”为媒资分类ID。用户需要提前创建完成媒资分类,操作请参考创建媒资分类。 “template_group_name”为转码模板组名称。用户需要提前创建完成转码模板,操作请参考创建自定义转码模板。 调用IAM接口的区域需与调用点播接口的区域一致,如调用“cn-north-4”区域的IAM接口获取用户Token,则该Token仅能用于调用“cn-north-4”区域点播接口的鉴权。 在返回参数中获取“video_upload_url”,“cover_upload_url”和“subtitle_upload_urls”。 { "asset_id": "3f40a2c7c60454f5f84381e0313ca230", "video_upload_url": "https://vod-bucket-81.obs.cn-north-4.myhuaweicloud.com:443/474bcff2992f4be5b883a2fb9cec7343/3f40a2c7c60454f5f84381e0313ca230/cdeda86cd1b7b3dd760a3ff28a5ee497.mp4?AWSAccessKeyId=BG923RWHL4HFXOGKCVAL&Expires=1560420274&Signature=9f%2BZcdD6SwjIU5ARHYiP6YY1Lyw%3D", "cover_upload_url": "https://vod-bucket-81.obs.cn-north-4.myhuaweicloud.com:443/474bcff2992f4be5b883a2fb9cec7343/3f40a2c7c60454f5f84381e0313ca230/cover/Cover0.png?AWSAccessKeyId=BG923RWHL4HFXOGKCVAL&Expires=1560420274&Signature=4Aa88NK%2By%2By1Xo0RvLpOvuaFCoE%3D", "subtitle_upload_urls": [ "https://vod-bucket-81.obs.cn-north-4.myhuaweicloud.com:443/474bcff2992f4be5b883a2fb9cec7343/3f40a2c7c60454f5f84381e0313ca230/subtitle/1.srt?AWSAccessKeyId=BG923RWHL4HFXOGKCVAL&Expires=1560420274&Signature=l0UclE9yfaVrxkl0kaNnr%2BemG98%3D" ], "target": { "bucket": "vod-bucket-81", "location": "cn-north-4", "object": "474bcff2992f4be5b883a2fb9cec7343/3f40a2c7c60454f5f84381e0313ca230/cdeda86cd1b7b3dd760a3ff28a5ee497.mp4" } } 使用PUT请求分别向“video_upload_url”,“cover_upload_url”和“subtitle_upload_urls”中上传音视频文件、封面图片和字幕文件。 其中,请求头“Content-Type”需要根据上传的文件类型分别设置,如下所示: 视频文件:video/视频格式,如:“video/mp4”。更多视频文件格式对应的请求头填写规则,请参见表1。 音频文件:audio/音频格式,如:“audio/mp3”。更多音频文件格式对应的请求头填写规则,请参见表2。 图片文件:image/图片格式,如:“image/png”。 字幕文件:application/octet-stream。 表1 视频文件请求头填写说明 文件后缀 Content-Type MP4 video/mp4 MOV video/quicktime MXF application/mxf TS video/mp2t MPG video/mpeg FLV video/flv WMV video/x-ms-wmv AVI video/x-msvideo M4V video/m4v F4V application/f4v MPEG video/mpeg M3U8 application/octet-stream _3GP/3GP video/3gpp ASF video/x-ms-asf MKV video/x-matroska WEBM video/webm MPD video/dash 表2 音频文件请求头填写说明 文件后缀 Content-Type MP3 audio/mp3 WMA audio/wma APE audio/ape FLAC audio/flac AAC audio/aac AC3 audio/ac3 MMF audio/mmf AMR audio/amr M4A audio/m4a M4R audio/m4r OGG audio/ogg WAV audio/wav WV audio/wv MP2 audio/mp2 调用接口确认媒资上传接口,完成媒资上传。 POST https://vod.cn-north-4.myhuaweicloud.com/v1.0/{project_id}/asset/status/uploaded { "asset_id": "0f4d3f1f32ec353d8866f2d84a036124", "status":"CREATED" } 媒资上传成功后,您可以在 视频点播 控制台查看媒资相关详细信息。
  • 操作步骤 创建虚拟IP。 发送“POST https://VPC的Endpoint/v2.0/ports”。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,其中vip所在子网需与E CS 同子网。 { "port": { "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "device_owner": "neutron:VIP_PORT", "name": "vip_port_test" } } 或者如下,可以指定IP创建: { "port": { "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "device_owner": "neutron:VIP_PORT", "name": "vip_port_test", "fixed_ips": [ { "ip_address": "192.168.0.220" } ] } } 查看请求响应结果。 请求成功时,响应参数如下: { "port": { "id": "a7d98f3c-b42f-460b-96a1-07601e145961", "name": "port-test", "status": "DOWN", "admin_state_up": true, "fixed_ips": [{ "subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12", "ip_address": "192.168.0.220" }], "mac_address": "fa:16:3e:01:f7:90", "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "tenant_id": "db82c9e1415a464ea68048baa8acc6b8", "project_id": "db82c9e1415a464ea68048baa8acc6b8", "device_id": "", "device_owner": "neutron:VIP_PORT", "security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"], "extra_dhcp_opts": [], "allowed_address_pairs": [], "binding:vnic_type": "normal", "binding:vif_details": {}, "binding:profile": {}, "port_security_enabled": true, "created_at": "2018-09-20T01:45:26", "updated_at": "2018-09-20T01:45:26" } } 请求异常时,错误码请参见错误码。 通过云服务器的ID查询网卡信息。 发送“GET https://VPC的Endpoint/v2.0/ports?device_id={ecs_id}&network_id={network_id}” 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 请求成功时,响应参数如下: { "ports": [{ "id": "02c72193-efec-42fb-853b-c33f2b802467", "name": "", "status": "ACTIVE", "admin_state_up": true, "fixed_ips": [{ "subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12", "ip_address": "192.168.0.75" }], "mac_address": "fa:16:3e:47:5f:c1", "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "tenant_id": "db82c9e1415a464ea68048baa8acc6b8", "project_id": "db82c9e1415a464ea68048baa8acc6b8", "device_id": "ea61f836-b52f-41bf-9d06-685644001d6f", "device_owner": "compute:br-iaas-odin1a", "security_groups": [ "e0598d96-9451-4f8a-8de0-b8b4d451d9e7" ], "extra_dhcp_opts": [], "allowed_address_pairs": [], "binding:vnic_type": "normal", "binding:vif_details": { "primary_interface": true }, "binding:profile": {}, "port_security_enabled": true, "created_at": "2020-06-20T08:07:29", "updated_at": "2020-06-20T08:07:29" }] } 请求异常时,错误码请参见错误码。 将云服务器与虚拟IP绑定。 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为上面创建的虚拟IP对应的port_id。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,ip_address为2查询出的云服务器的网卡ip。 { "port": { "allowed_address_pairs": [{ "ip_address": "192.168.0.75" }] } } 查看请求响应结果。 请求成功时,响应参数如下: { "port": { "id": "a7d98f3c-b42f-460b-96a1-07601e145961", "name": "port-test", "status": "DOWN", "admin_state_up": true, "fixed_ips": [{ "subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12", "ip_address": "192.168.0.220" }], "mac_address": "fa:16:3e:01:f7:90", "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "tenant_id": "db82c9e1415a464ea68048baa8acc6b8", "project_id": "db82c9e1415a464ea68048baa8acc6b8", "device_id": "", "device_owner": "neutron:VIP_PORT", "security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"], "extra_dhcp_opts": [], "allowed_address_pairs": [{ "ip_address": "192.168.0.75" }] "binding:vnic_type": "normal", "binding:vif_details": {}, "binding:profile": {}, "port_security_enabled": true, "created_at": "2018-09-20T01:45:26", "updated_at": "2018-09-20T01:45:26" } } 请求异常时,错误码请参见错误码。 关闭云服务器网卡的源/目的检查。 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为2查询到的网卡ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下:ip_address为1.1.1.1/0查询出的云服务器的网卡ip。 { "port": { "allowed_address_pairs": [{ "ip_address": "1.1.1.1/0" }] } } 查看请求响应结果。 请求成功时,响应参数如下: { "port": { "id": "02c72193-efec-42fb-853b-c33f2b802467", "name": "", "status": "ACTIVE", "admin_state_up": true, "fixed_ips": [{ "subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12", "ip_address": "192.168.0.75" }], "mac_address": "fa:16:3e:47:5f:c1", "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "tenant_id": "db82c9e1415a464ea68048baa8acc6b8", "project_id": "db82c9e1415a464ea68048baa8acc6b8", "device_id": "ea61f836-b52f-41bf-9d06-685644001d6f", "device_owner": "compute:br-iaas-odin1a", "security_groups": ["e0598d96-9451-4f8a-8de0-b8b4d451d9e7"], "extra_dhcp_opts": [], "allowed_address_pairs": [{ "ip_address": "1.1.1.1/0" }], "binding:vnic_type": "normal", "binding:vif_details": { "primary_interface": true }, "binding:profile": {}, "port_security_enabled": true, "created_at": "2020-06-20T08:07:29", "updated_at": "2020-06-20T08:07:29" } } 请求异常时,错误码请参见错误码。
  • 操作步骤 指定limit与offset查询DDS实例列表。 接口相关信息 URI格式:GET https://{Endpoint}/v3/{project_id}/instances?id={id}&name={name}&mode={mode}&datastore_type={datastore_type}&vpc_id={vpc_id}&subnet_id={subnet_id}&offset={offset}&limit={limit} {Endpoint}信息请从地区和终端节点获取。 {limit}可根据DDS实例数据调整。 详情请参见查询实例列表和详情。 请求示例 根据指定limit与offset查询DDS实例列表 https://dds.cn-north-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances?offset=0&limit=1 响应示例 根据指定limit与offset查询DDS实例列表: { "instances": [ { "id": "8436a91546294036b75931e879882200in02", "name": "dds-efa6", "status": "normal", "port": 8635, "mode": "ReplicaSet", "region": "aaa", "datastore": { "type": "DDS-Community", "version": "3.4" }, "engine": "wiredTiger", "created": "2019-01-17T07:05:52", "updated": "2019-01-17T07:05:47", "db_user_name": "rwuser", "ssl": "1", "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", "backup_strategy": { "start_time": "16:00-17:00", "keep_days": 7 }, "pay_mode": "0", "maintenance_window": "02:00-06:00", "groups": [ { "type": "replica", "volume": { "size": "10", "used": "0.33" }, "nodes": [ { "id": "233eaac9c6f245c0bb9c2d21eea12d1bno02", "name": "dds-efa6_replica_node_2", "status": "normal", "role": "Primary", "private_ip": "192.168.0.174", "public_ip": "", "spec_code": "dds.mongodb.s2.medium.4.repset", "availability_zone": "bbb" }, { "id": "d57d76d6320a4a7b86db82c317550c4ano02", "name": "dds-efa6_replica_node_1", "status": "normal", "role": "Hidden", "private_ip": "192.168.0.39", "public_ip": "", "spec_code": "dds.mongodb.s2.medium.4.repset", "availability_zone": "bbb" }, { "id": "f46b0a1cf4d9400e9fd7af17f8742d37no02", "name": "dds-efa6_replica_node_3", "status": "normal", "role": "Secondary", "private_ip": "192.168.0.176", "public_ip": "", "spec_code": "dds.mongodb.s2.medium.4.repset", "availability_zone": "bbb" } ] } ], "enterprise_project_id": "0", "time_zone": "", "actions": [ ] } ], "total_count": 24 } 汇总查询结果。 参考1持续调用,如果查询的DDS实例列表为空,或者返回的body体中不存在instances字段,表明所有DDS实例查询完成。 汇总所有查询到的DDS实例即当前查询条件下的所有DDS实例。
  • 操作步骤 查询证书列表。 接口相关信息 URI格式:GET /v3/scm/certificates 详情请参见查询证书列表。 请求示例 GET: https://{endpoint}/v3/scm/certificates {endpoint}信息请从地区和终端节点获取。 Body: { "limit": "2", "offset": "0" } 响应示例 { "certificates" : [ { "id" : "scs1554192131150", "name" : "test", "domain" : "www.zx.com", "type" : "OV_SSL_CERT", "brand" : "GEOTRUST", "expire_time" : "2021-05-27 16:46:25.0", "domain_type" : "MULTI_DOMAIN", "validity_period" : 12, "status" : "ISSUED", "domain_count" : 2, "wildcard_count" : 0, "description" : null } ], "total_count" : 1 } 删除证书。 接口相关信息 URI格式:DELETE /v3/scm/certificates/{certificate_id} 详情请参见删除证书。 请求示例 DELETE: https://{endpoint}/v3/scm/certificates/scs1554192131150 {endpoint}信息请从地区和终端节点获取。 Body: { certificate_id:scs1554192131150 } 响应示例 { } 或 { "error_code" : "SCM.XXX", "error_msg" : "XXX" }
  • 创建快速发放裸金属服务器 如下示例是创建快速发放裸金属服务器最简单的配置。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 { "server": { "availability_zone": "cn-north-4a", "name": "bms-test02", "imageRef": "766a545a-02e1-433e-b1d1-733b5dc95e94", "flavorRef": "physical.h2.large", "root_volume": { "volumetype": "SAS", "size": 150 }, "vpcid": "8df83bf2-fd2e-4ee0-9692-c0b7736513fb", "nics": [ { "subnet_id": "c6bb8788-4fd1-4a8f-adab-7eba3bed8616" } ], "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "regionID": "cn-north-4" }, "metadata": { "op_svc_userid": "59781460e9e54886a7d03df7d3f3fc81" }, "key_name": "$key_name" } } 相比创建本地盘裸金属服务器,此场景的不同之处是选择启动源为云硬盘的规格,以及设置系统盘参数。 volumetype:系统盘的类型,“SAS”表示“高IO”,您还可以指定其他类型,具体请参见创建裸金属服务器中的参数解释。 size:系统盘大小,容量单位为GB,输入大小范围为[40,1024]。系统盘大小取值应不小于镜像中系统盘的最小值(min_disk属性),您可以通过查询镜像列表API查询镜像的min_disk参数值。
  • 创建带弹性公网IP的裸金属服务器 您还可以为裸金属服务器配置弹性公网IP,只需在请求消息体中增加publicip字段即可,创建裸金属服务器的时候会同时创建一个弹性公网IP,且弹性公网IP与裸金属服务器绑定在一起。示例如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 { "server": { "availability_zone": "cn-north-4a", "name": "bms-test04", "imageRef": "766a545a-02e1-433e-b1d1-733b5dc95e94", "flavorRef": "physical.s3.large", "data_volumes": [ { "volumetype": "SAS", "size": 10, "shareable": false } ], "vpcid": "8df83bf2-fd2e-4ee0-9692-c0b7736513fb", "nics": [ { "subnet_id": "c6bb8788-4fd1-4a8f-adab-7eba3bed8616" } ], "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "regionID": "cn-north-4" }, "metadata": { "op_svc_userid": "59781460e9e54886a7d03df7d3f3fc81" }, "publicip": { "eip": { "iptype": "5_bgp", "bandwidth": { "chargemode": "bandwidth", "name": "bms-test04-bandwidth", "size": 1, "sharetype": "PER" }, "extendparam": [ "chargingMode": "prePaid" ] } }, "key_name": "$key_name" } } iptype:弹性公网IP地址类型,“5_bgp”表示全动态BGP。 chargemode:带宽的计费类型,取值包括“traffic”(按流量计费)和“bandwidth”(按带宽计费)。 name:带宽名称。 size:带宽大小,单位为Mbit/s,输入大小范围为[1,2000]。 sharetype:带宽的共享类型,“PER”表示独享。 extendparam.chargingMode:弹性公网IP的计费模式,“prePaid”表示预付费,即包年包月。
  • 创建带数据盘的裸金属服务器 您还可以为裸金属服务器配置数据盘,只需在请求消息体中增加data_volumes字段即可,示例如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 { "server": { "availability_zone": "cn-north-4a", "name": "bms-test03", "imageRef": "766a545a-02e1-433e-b1d1-733b5dc95e94", "flavorRef": "physical.s3.large", "data_volumes": [ { "volumetype": "SAS", "size": 10, "shareable": false } ], "vpcid": "8df83bf2-fd2e-4ee0-9692-c0b7736513fb", "nics": [ { "subnet_id": "c6bb8788-4fd1-4a8f-adab-7eba3bed8616" } ], "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "regionID": "cn-north-4" }, "metadata": { "op_svc_userid": "59781460e9e54886a7d03df7d3f3fc81" }, "key_name": "$key_name" } } volumetype:数据盘的类型,“SAS”表示“高IO”。 size:数据盘大小,容量单位为GB,输入大小范围为[10,32768]。 shareable:是否为共享磁盘。“true”为共享盘,“false”为普通云硬盘。
  • 创建本地盘裸金属服务器 如下示例是创建本地盘裸金属服务器最简单的配置。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 { "server": { "availability_zone": "cn-north-4a", "name": "bms-test01", "imageRef": "766a545a-02e1-433e-b1d1-733b5dc95e94", "flavorRef": "physical.s3.large", "vpcid": "8df83bf2-fd2e-4ee0-9692-c0b7736513fb", "nics": [ { "subnet_id": "c6bb8788-4fd1-4a8f-adab-7eba3bed8616" } ], "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "regionID": "cn-north-4" }, "metadata": { "op_svc_userid": "59781460e9e54886a7d03df7d3f3fc81" }, "key_name": "$key_name" } } availability_zone:服务所在区域的可用区,您可以在地区和终端节点查询。例如,“cn-north-4a”表示“华北-北京四”的“可用区1”。 name:裸金属服务器的名称,由您自定义,例如取名为“bms-test01”。 imageRef:镜像ID,即创建裸金属服务器使用哪个镜像(操作系统)。镜像ID可以在 镜像服务 控制台查询。 flavorRef:裸金属服务器使用的规格ID,格式为physical.x.x。规格ID可以从裸金属服务器控制台获取,并参考前提条件判断规格的启动源,此处选择启动源为本地盘的规格,例如“physical.s3.large”。 vpcid:裸金属服务器所在VPC(虚拟私有云)的ID,您可以在虚拟私有云控制台查询,也可以通过查询VPC列表API获取。 nics.subnet_id:VPC内子网的网络ID,您可以在虚拟私有云控制台查询,也可以通过查询子网列表API获取。 extendparam:“chargingMode”表示计费模式,“prePaid”为预付费,即包年/包月;“periodType”表示订购周期类型,“month”表示按月;“periodNum”表示订购周期数,本例中的“1”表示一个月;“isAutoRenew”表示是否自动续订;“isAutoPay”表示下单订购后,是否自动从客户的账户中支付,而不需要客户手动去支付;“regionID”表示服务所在的区域ID,您可以在地区和终端节点查询。 metadata.op_svc_userid:用户ID,您可以在我的凭证查询。 key_name:密钥对名称。如果使用SSH密钥方式登录裸金属服务器,需要指定已有密钥的名称。您可以在密钥对控制台查询。
  • 前提条件 您需要规划裸金属服务器所在的区域信息,并根据区域确定调用API的Endpoint,详细信息请参见终端节点(Endpoint)。 裸金属服务器的启动源分为本地盘和云硬盘,对应的裸金属服务器为本地盘裸金属服务器,和快速发放裸金属服务器。有两种方式查看启动源是本地盘还是云硬盘: 在裸金属服务器控制台选择某一规格后,如果“磁盘”配置项中出现“系统盘”参数,表示该规格的启动盘为云硬盘。反之为本地盘。 调用查询裸金属服务器规格extra_specs参数的详情API,在响应参数中查找“baremetal:extBootType”取值,“LocalDisk”表示启动源为本地盘,“Volume”表示启动源为云硬盘。
  • 操作步骤 参考认证鉴权,通过调用IAM服务的API,获取用户的Token。 参考获取任务ID,获取需要查询的任务ID。 URI格式: /v3/{project_id}/jobs/batch-status 请求示例: POST: https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-status {endpoint}信息请从地区和终端节点获取。 请求样例: https://{endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/batch-status { "jobs" : [ "9a470239-2308-4bb5-a6bc-1040402fjb21", "dc67695a-ee3e-49b8-a022-a099bd81jb21" ], "page_req" : { "cur_page" : 1, "per_page" : 10 } } 响应示例: { "results" : [ { "id" : "9a470239-2308-4bb5-a6bc-1040402fjb21", "status" : "INCRE_TRANSFER_STARTED" }, { "id" : "dc67695a-ee3e-49b8-a022-a099bd81jb21", "status" : "INCRE_TRANSFER_FAILED" } ], "count" : 2 }
  • 操作步骤 获取用户Token,用于调用SparkRTC接口时进行认证鉴权。 在“我的凭证”页面获取username、password、domainname,调用如下接口 获取Token 。详细信息请参见构造请求。 POST https://iam.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", //用户名。 "password": "password", //用户登录密码。 "domain": { "name": "domainname" //用户所属的账号名。 } } } }, "scope": { "domain": { "name": "domainname" //用户所属的账号名。 } } } } 如图1所示,红框中的信息为获取用户Token。 图1 获取用户Token 调用创建应用接口创建SparkRTC应用。 选择POST请求方法并输入URI。 https://rtc-api.myhuaweicloud.com/v2/apps 请求消息头中增加“X-Auth-Token”,值设置为步骤1中获取的用户Token。 Request Body中传入如下参数: { "app_name" : "rtctest" } 请求响应成功后,返回已创建应用的ID。 { "app_id": "5ff9701f2346968bb306cb43", } 调用创建或更新录制规则接口,创建录制规则。 选择POST请求方法并输入URI。 https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/record-rules 请求消息头中增加“X-Auth-Token”,值设置为步骤1中获取的用户Token。 Request Body中传入如下参数: { "obs_addr": { "bucket": "obsName", "location": "cn-north-4", "object": "Record/", "project_id": "01234567890123456789012345678901" }, "record_formats": ["MP4"], "mp4_config": {} } 请求响应成功后,返回已创建的录制规则。 { "app_id": "5ff9701f2346968bb306cb43", "rule_id": "5d0ec2c53a2c15625017adb8bbbcd9ab", "create_time": "2021-04-21T10:29:33Z", "hls_config": { "record_cycle": 0, "record_max_duration_to_merge_file": 0 }, "mp4_config": { "record_cycle": 7200, "record_max_duration_to_merge_file": 0, "record_prefix": "Record/{publish_domain}/{app}/{record_type}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time}" }, "obs_addr": { "bucket": "obsName", "location": "cn-north-4", "object": "Record/", "project_id": "01234567890123456789012345678901" }, "record_formats": [ "MP4" ], "update_time": "2021-04-21T10:29:33Z" } 调用RTC增值(录制)事件回调配置接口,配置录制回调。 选择PUT请求方法并输入URI。 https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/record-callback 请求消息头中增加“X-Auth-Token”,值设置为步骤1中获取的用户Token。 Request Body中传入如下参数: { "url": "http://mydomain.com/callback", "auth_key": "8923ab8c2dcef4538923ab8c2dcef453" } 请求响应成功后,返回已创建的回调信息。 { "app_id": "5ff9701f2346968bb306cb43", "record_callback": { "auth_key": "8923ab8c2dcef4538923ab8c2dcef453", "update_time": "2021-04-07T12:05:18.0718Z", "url": "http://mydomain.com/callback", "notify_event_subscription": [ "RECORD_NEW_FILE_START", "RECORD_FILE_COMPLETE", "CLOUD_RECORD_OVER" ] } } 终端用户通过SparkRTC APP加入某个SparkRTC房间,SparkRTC APP的集成开发请参见客户端SDK。 调用启动单流任务接口,创建录制任务。 选择POST请求方法并输入URI。 https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/individual-stream-jobs 请求消息头中增加“X-Auth-Token”,值设置为步骤1中获取的用户Token。 Request Body中传入如下参数: { "room_id": "room001", "user_id": "user001", "is_record_audio": true, "video_type": "CAMERASTREAM", "resolution": "1280*720", "resolution_policy": "DOWNWARD", "max_idle_time": 30, "record_param": { "record_rule_id": "5d0ec2c53a2c15625017adb8bbbcd9ab" } } 请求响应成功后,返回录制任务信息。 { "app_id": "5ff9701f2346968bb306cb43", "create_time": "2021-04-21T10:51:55Z", "is_record_audio": true, "job_id": "607f87cf00d861eeefffa6c88054cdab", "job_unique_id": "a77bb33dbdc948d8", "max_idle_time": 30, "push_param": { "rtmp_urls": null }, "record_files": null, "record_param": { "record_rule_id": "5d0ec2c53a2c15625017adb8bbbcd9ab" }, "resolution_policy": "DOWNWARD", "resolution": "1280*720", "room_id": "room001", "start_time": "2021-04-21T10:51:55Z", "state": "INIT", "stop_time": "0001-01-01T00:00:00Z", "stream_name": "s_607f87cf00d861eeefffa6c88054cdab_room001_user001", "update_time": "2021-04-21T10:51:55Z", "user_id": "user001", "video_type": "CAMERASTREAM" } SparkRTC房间结束音视频互动后,您可以在配置的OBS桶中获取录制文件。
  • 操作步骤 注册微服务my-provider。 调用创建微服务静态信息接口,请求示例如下。 curl -k -H "x-domain-name:default" -XPOST "https://{cse_endpoint}/v4/default/registry/microservices" -d '{ "service": { "serviceName": "my-provider", "appId": "default", "version": "1.0.0", "description": "test", "level": "MIDDLE", "status": "UP" } }' 返回结果: {"serviceId":"918282e8562dc5fdc9a8dcd4d1baabb492190aa4"} 得到的serviceId,后续示例中以{providerServiceId}代替。 注册微服务my-provider的实例。 调用注册微服务实例接口。实例有效期1小时,到期自动下线。假设provider实例监听的地址为127.0.0.1:8080,请求示例如下。 curl -k -H "x-domain-name:default" -XPOST "https://{cse_endpoint}/v4/default/registry/microservices/{providerServiceId}/instances" -d '{ "instance": { "hostName": "test", "endpoints": [ "rest:127.0.0.1:8080" ], "status": "UP", "healthCheck": { "mode": "push", "interval": 900, "times": 3 } } }' 返回结果: {"instanceId":"2be605a095ed11eabcbe0255ac100fa3"} 注册微服务my-consumer。 调用创建微服务静态信息接口,请求示例如下。 curl -k -H "x-domain-name:default" -XPOST "https://{cse_endpoint}/v4/default/registry/microservices" -d '{ "service": { "serviceName": "my-consumer", "appId": "default", "version": "1.0.0", "description": "test", "level": "MIDDLE", "status": "UP" } }' 返回结果: {"serviceId":"9db248934c31fc754d6e922b48ede4a5c004d3c1"} 得到的serviceId,后续示例中以{consumerServiceId}代替。 my-consumer发现my-provider的实例。 调用按条件查询微服务实例接口,consumer带着自身的serviceId去服务中心查询provider的实例信息,请求示例如下。 curl -k -H "x-domain-name:default" -H "X-ConsumerId:{consumerServiceId}" -XGET "https://{cse_endpoint}/v4/default/registry/instances?appId=default&serviceName=my-provider&version=0.0.0%2B" 返回结果: { "instances": [ { "instanceId": "2be605a095ed11eabcbe0255ac100fa3", "serviceId": "918282e8562dc5fdc9a8dcd4d1baabb492190aa4", "endpoints": [ "rest:127.0.0.1:8080" ], "hostName": "test", "status": "UP", "healthCheck": { "mode": "push", "interval": 150, "times": 3 }, "timestamp": "1589465646", "modTimestamp": "1589465646", "version": "1.0.0" } ] } 在实际业务中,consumer可从实例查询结果中的"endpoint"字段获取provider实例的地址,发起业务调用。 您还可以进入微服务引擎控制台的“微服务目录”,查看服务注册信息。
  • 操作场景 环境是用于组件部署和运行的计算(如云容器引擎 CCE、弹性云服务器 ECS等)、网络(如弹性负载均衡 ELB、弹性IP EIP等)和中间件(如分布式缓存 DCS、云数据库 RDS等)等基础资源的集合。ServiceStage把多种基础资源组合为一个环境,如:开发环境、测试环境、预生产环境和生产环境。按环境维度来管理资源、部署组件,可以减少具体基础资源运维管理的复杂性。 下面介绍如何调用创建环境API创建环境,再调用根据环境ID修改环境资源API为环境添加其他需要的资源,最后调用根据环境ID获取环境详细信息API根据环境ID查询环境详细信息。 API的调用方法请参见如何调用API。