裸金属服务器 BMS-创建裸金属服务器:请求示例

时间:2024-10-22 15:30:18

请求示例

  • 创建一个裸金属服务器,镜像ID为766a545a-02e1-433e-b1d1-733b5dc95e94,规格为physical.s3.large,计费模式为包年包月,使用密码方式远程登录。
    1
    POST https://{BMS Endpoint}/v1/{project_id}/baremetalservers
    
     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
    48
    {
        "server": {
            "availability_zone": "az1",
            "name": "bms-75c7",
            "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",
                    "ip_address": ""
                }
            ],
            "count": 1,
            "schedulerHints": {
                "dec_baremetal": "share"
            },
            "extendparam": {    
                "chargingMode": "prePaid",
                "periodType": "month",
                "periodNum": 1,
                "isAutoRenew": "true",
                "isAutoPay": "true",
                "regionID": "region01"
            },
            "metadata": {
                "op_svc_userid": "59781460e9e54886a7d03df7d3f3fc81",
                "BYOL": "false",
                "admin_pass": "$ADMIN_PASS"
            },
            "publicip": {
                "id": "1b036bce-26b4-465c-acea-99fdbb0573a3"
            },
            "user_data": "$USER_DATA",
            "security_groups": [
                {
                    "id": "993f2916-5bad-4f24-bc3c-db539f1a6d19"
                }
            ]
        }
    }
    
  • 创建一个包年包月的Linux裸金属服务器,可用区为az1,名称为bms-3b91,镜像ID为766a545a-02e1-433e-b1d1-733b5dc95e94规格为physical.o2.large且使用密钥方式远程登录。
     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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    {
        "server": {
            "availability_zone": "az1",
            "name": "bms-3b91",
            "imageRef": "766a545a-02e1-433e-b1d1-733b5dc95e94",
            "flavorRef": "physical.o2.large",
            "data_volumes": [
                {
                    "volumetype": "SAS",
                    "size": 10,
                    "shareable": true
                }
            ],
            "vpcid": "8df83bf2-fd2e-4ee0-9692-c0b7736513fb",
            "nics": [
                {
                    "subnet_id": "c6bb8788-4fd1-4a8f-adab-7eba3bed8616",
                    "ip_address": ""
                },
                {
                    "subnet_id": "2b8bcf33-33f2-4a63-aa9c-b1e17ff0ed7f",
                    "ip_address": ""
                }
            ],
            "count": 1,
            "schedulerHints": {
                "dec_baremetal": "share"
            },
            "extendparam": {
                "chargingMode": "prePaid",
                "periodType": "month",
                "periodNum": 1,
                "isAutoRenew": "true",
                "isAutoPay": "true",
                "regionID": "region01"
            },
            "metadata": {
                "op_svc_userid": "59781460e9e54886a7d03df7d3f3fc81",
                "BYOL": "false"
            },
            "publicip": {
                "eip": {
                    "iptype": "5_bpg",
                    "bandwidth": {
                        "chargemode": "",
                        "name": "bms-3b91-bandwidth",
                        "size": 1,
                        "sharetype": "PER"
                    },
                    "extendparam": {
                       "chargingMode": "prePaid"
                    }
                }
            },
            "security_groups": [
                {
                    "id": "993f2916-5bad-4f24-bc3c-db539f1a6d19"
                }
            ],
            "key_name": "$key_name"
        }
    }
    

    Java 语言生成 user_data示例如下:

    1
    2
    3
    String userData_org = "#!/bin/bash \r\n echo    'root:xxxxx' | chpasswd ;";
    byte[] userData_byte = userData_org.getBytes();
    String userData = new BASE64Encoder().encode(userData_byte);
    
  • 创建包年包月的Windows操作系统的裸金属服务器,可用区为az1,名称为bms-6a1e,镜像ID为fd04041a-5f35-45ae-a27c-bf30f921c6b5,规格为physical.s3.large且使用密钥方式远程登录。
     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
    48
    { 
         "server": { 
             "availability_zone": "az1", 
             "name": "bms-6a1e", 
             "imageRef": "fd04041a-5f35-45ae-a27c-bf30f921c6b5", 
             "flavorRef": "physical.s3.large", 
             "data_volumes": [ 
                 { 
                     "volumetype": "SAS", 
                     "size": 10, 
                     "shareable": false 
                 } 
             ], 
             "vpcid": "0adc2847-c160-4263-be1f-e03d36e93e32", 
             "nics": [ 
                 { 
                     "subnet_id": "4f1cf6cc-4cc3-41d3-8192-625293dccce0", 
                     "ip_address": "" 
                 } 
             ], 
             "count": 1, 
             "schedulerHints": { 
                 "dec_baremetal": "share" 
             }, 
            "extendparam": { 
                "chargingMode": "prePaid", 
                "periodType": "month", 
                "periodNum": 1, 
                "isAutoRenew": "true", 
                "isAutoPay": "true", 
                "regionID": "region1" 
             }, 
             "metadata": { 
                "op_svc_userid": "8a74baed155b47e8b59fbca853d6cb48", 
                "BYOL": "false" 
             }, 
             "publicip": { 
                 "id": "db9c4f39-fabd-4cc2-8685-82e7715d099f" 
             }, 
             "user_data": "$USER_DATA", 
             "security_groups": [ 
                 { 
                     "id": "33cf5e40-0b65-4e03-867d-4c67947c49be" 
                 } 
             ], 
             "key_name": "$key_name"
         } 
     }
    
support.huaweicloud.com/api-bms/bms_api_0606.html