Help Center> Bare Metal Server> API Reference> Examples> Example 1: Creating a BMS
Updated on 2024-05-17 GMT+08:00

Example 1: Creating a BMS

Scenarios

BMSs are recommended for key applications and services that require high performance (such as Big Data clusters and enterprise middleware systems) and a secure and reliable running environment.

This section describes how to create a BMS using the Creating BMSs API. For details about how to call the API, see Calling APIs.

Currently, only yearly/monthly BMSs can be created.

Prerequisites

  • The BMS boot device can be a local disk or EVS disk. Quickly provisioned BMSs boot from an EVS disk. You can use either of the following methods to check the boot device:
    • After selecting a flavor on the BMS console, if System Disk is displayed in the Disk option, the flavor boots from an EVS disk. Otherwise, the flavor boots from a local disk.
    • Call the Querying Parameter extra_specs of a BMS Flavor API and check the value of baremetal:extBootType in the response. If the value is LocalDisk, the boot device is a local disk. If the value is Volume, the boot device is an EVS disk.

Create a BMS with Local Disks

The following example uses the most basic configuration required for creating a BMS with local disks.

 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: AZ where you want to create the BMS.
  • name: name of the BMS, for example, bms-test01
  • imageRef: ID of the image (OS) used to create the BMS You can query the image ID on the IMS console.
  • flavorRef: BMS flavor ID in physical.x.x format You can obtain the flavor ID from the BMS console and determine the boot device of the flavor based on Prerequisites. In this example, a flavor that boots from a local disk is used, for example, physical.s3.large.
  • vpcid: ID of the VPC where the BMS resides. You can query the ID on the VPC console or using the Querying VPCs API.
  • nics.subnet_id: ID of the VPC subnet. You can query the ID on the VPC console or using the Querying Subnets API.
  • extendparam: chargingMode specifies the billing mode, and prePaid indicates prepayment, that is, the yearly/monthly mode. periodType specifies the period type, and month indicates the monthly mode. periodNum specifies the number of periods, and 1 in this example indicates one month. isAutoRenew specifies whether to enable auto-renewal. isAutoPay specifies whether to automatically deduct the charges from your account balance without requiring manual payment. regionID specifies the ID of the region where the BMS resides.
  • metadata.op_svc_userid: user ID, which you can obtain from My Credentials on the management console.
  • key_name: key pair name. To log in to the BMS using an SSH key pair, set the value to the name of an existing key pair. You can obtain the key pair name from the Key Pair page on the Cloud Server Console.

Create a BMS Supporting Quick Provisioning

The following example uses the most basic configuration required for creating a BMS supporting quick provisioning.

 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"
    }
}

Compared with creating a BMS with local disks, you need to select a flavor whose boot device is EVS disk and set system disk parameters.

  • volumetype: type of the system disk. SAS indicates high I/O. You can specify other types. For details, see the parameter descriptions in Creating BMSs.
  • size: system disk size (GB). The value ranges from 40 to 1024. The system disk size cannot be less than the minimum size of the system disk (min_disk) in the image. You can obtain the value of min_disk using the Querying Images API.

Create a BMS with Data Disks

You can configure data disks for BMSs by adding the data_volumes field to the request body. An example is as follows:

 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: data disk type. SAS indicates high I/O.
  • size: data disk size (GB). The value ranges from 10 to 32768.
  • shareable: whether the disk is shareable. true indicates a shared disk and false indicates a common disk.

Create a BMS with an EIP

You can bind an EIP to the BMS by adding the publicip field to the request body. During the BMS creation, an EIP is assigned and bound to the BMS. An example is as follows:

 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: EIP type. 5_bgp indicates dynamic BGP.
  • chargemode: bandwidth billing type. The value can be traffic or bandwidth.
  • name: bandwidth name
  • size: bandwidth (Mbit/s). The value ranges from 1 to 2000.
  • sharetype: bandwidth sharing type. PER indicates dedicated bandwidth.
  • extendparam.chargingMode: billing mode of the EIP. prePaid indicates prepayment, that is, the yearly/monthly mode.