我要评分
获取效率
正确性
完整性
易理解

Provisioning a Bare Metal Instance

The operations for managing bare metal instances are the same as those for managing VMs. For details about how to perform operations on the UI, see the VM instance provisioning process. Perform the following operations on the controller node.

  1. Create an instance flavor.
    1
    openstack flavor create --ram $RAM_MB --vcpus $CPU --disk $DISK_GB  ${flavor_name}
    

    flavor_name can be customized.

    Set the flavor properties as required.

    1
    2
    3
    4
    openstack flavor set --property resources:CUSTOM_${CLASS_NAME}=1 $flavorName
    openstack flavor set --property resources:VCPU=0 $flavorName
    openstack flavor set --property resources:MEMORY_MB=0 $flavorName
    openstack flavor set --property resources:DISK_GB=0 $flavorName
    

    The value of custom resource class in flavor must be associated with the bare metal instance management resource type. The association rules are as follows:

    • The value starts with "CUSTOM_".
    • Change the bare metal instance management resource type to uppercase.
    • Replace all punctuation marks with underscores (_).

    For example, if the resource type is baremetal-small, the value is CUSTOM_BAREMETAL_SMALL.

  2. Check the status of the bare metal instance management node.
    1. The bare metal instance management node must be in the available state, and the maintenance status must be disabled. You can run the following command to check whether the management node meets the requirements:
      1
      openstack baremetal node list --provision-state available --no-maintenance
      
    2. Ensure that the Compute service is enabled and running.
      1
      openstack compute service list --service nova-compute
      

    3. Check whether the resource properties of the management node have been set.
      1
      openstack --os-baremetal-api-version 1.21 baremetal node list --fields uuid name resource_class
      

    4. Check properties of the management node.
      1
      openstack baremetal node show $BM_NAME --fields properties
      

      It must contain information such as memory_mb, cpu_arch, local_gb and cpus.

      Check properties of the created instance flavor.

      The properties should correspond to those of the bare metal instance management node, but the display format is different.

  3. Create a user data file and initialize the bare metal instance.
    The following example demonstrates the root user login and the root password configuration.
    1. Create a cloud-init user data file /opt/cloud-init-user-data.txt.
      vi /opt/cloud-init-user-data.txt
    1. Press i to enter the insert mode and add the following content to the file:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      #cloud-config
      users:
        - name: root
      chpasswd:
        list: |
          root:PASSWORD
        expire: False
      ssh_pwauth: true
      disable_root: false
      
      runcmd:
       - [ systemctl, restart, network ]
      
    2. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Create an instance.
    1
    nova boot --config-drive true --flavor ${flavor_name} --image ${image_uuid} ${instance_name} --nic net-id=${network_uuid} --user-data /opt/cloud-init-user-data.txt
    

    instance_name can be customized.

    The user image used here is the image described in 1. The architecture of the user image must match the actual physical server. You can run the openstack image list command to obtain the image UUID. The network used here is the network created in Creating a Provisioning Network. You can run the openstack network list command to obtain the network UUID.

  5. The clean operation is invoked asynchronously and does not return the result immediately. You can run the following command to view the status of the management node:
    1
    watch -d -n 1 "openstack baremetal node list"
    

    The value of Provisioning State for the configured management node changes as follows: available -> deploying -> wait call-back -> deploying -> active.

  6. After the deployment is successful, you can view the instance information.
    1
    nova show ${instance_name}
    

    The value of status should be ACTIVE.

  7. Check information about the bare metal instance management node.
    1
    openstack baremetal node list
    

    The value of Provisioning State for the bare metal instance management node is active, and the value of Instance UUID is the UUID of the created instance.

    If Nova returns the error message "No valid host was found", perform the operations in 2. In addition, check whether the nova-scheduler service log is filtered. If no, view the ironic-conductor service log to locate the fault.