Search Docs...
⌘ K
Migration ToolArcfra CloudMoveVM Initialization ToolArcfra VMTools

After creating a virtual machine template, you can use it to create new virtual machines. During creation, in addition to the regular parameters, you can also customize the initialization data for new virtual machines. After the initialization is complete, the VM Initialization Tool will be automatically disabled to prevent the virtual machine from initializing again during restart.

You can create new virtual machines on the Arcfra Operation Center (AOC) management platform, or via the Web console, AOC RESTful API, or SDK. This section only describes the initialization configuration when creating a virtual machine from a template. See the Management > Managing virtual machines > Creating and configuring virtual machines > Creating a virtual machine > Creating a VM from a template section for full details on creating a virtual machine from a virtual machine template.

Note:

When a virtual machine with the VM Initialization Tool installed is cloned, the newly created virtual machine cannot inherit the same initialization configuration as the source virtual machine. It is recommended to uninstall the VM Initialization Tool from the Guest OS before cloning. For details, see Uninstalling the tool from a Linux virtual machine.

Creating a virtual machine on AOC or Web console

The method of creating a virtual machine on the Web console and AOC is basically the same. In the following procedure, AOC is used as an example.

Procedure

  1. Log in to AOC to access its homepage. On the upper right corner of the homepage, click Create, and then select Create VM from template to open the Create VM from template dialog box.

  2. In the Create VM from template dialog box, select the virtual machine template you created. Refer to Management > Managing virtual machines > Creating and configuring virtual machines > Virtual machine configuration options section for details on the configurations of basic information, compute resources, and storage resources.

  3. When configuring Network device, go to Network configuration for VM initialization and choose the IP address configuration mode for the virtual machine.

    • Configure static IP address: Once selected, you need to configure the static IP address and static routing for the virtual machine.

    • Enable network card DHCP: Once selected, you need to enable DHCP on the virtual machine to get a dynamic IP address.

    • Not configured: Do not configure the IP address.

    Note:

    • When the network type of the virtual machine’s NIC is VPC Network, if the IP address is left blank, the Configure static IP address mode is not allowed to be selected; if an IP address has been filled in and the Configure static IP address method is selected, the system will automatically configure the static IP of the virtual machine's NIC to the filled IP address.
    • If Configure static IP address is selected, the system will perform an IP address conflict check after you click Next. If a conflict is detected, you can either modify the IP address or disable the virtual NIC. Continuing to use the current IP address may cause conflicts and affect other services within the cluster.
  4. In the Initialization configuration section, configure the initial data for the virtual machine.

    1. Enter the hostname, default username and password, SSH public key, and DNS server configurations.

    2. Configure the user data. Up to 32 KB of user data is supported. See Examples of user data for examples.

  5. Click Create to complete the virtual machine creation.

Examples of user data

Refer to the following documents to check the user data supported by the VM Initialization Tool for Linux virtual machines.

This section provides examples using the user data script and cloud-config runcmd to configure the user data. Refer to the official documentation for other configurations needed.

User data script

Configure the following shell script so that the virtual machine executes the echo "Hello World. The time is now $(date -R)!" >> /root/arcfra.txt command upon its first startup:

#!/bin/sh
echo "Hello World.  The time is now $(date -R)!" >> /root/arcfra.txt

cloud-config runcmd

Configure the following cloud-config runcmd so that the virtual machine executes the curl https://www.arcfra.com/ -o /root/arcfra.html command upon its first startup:

#cloud-config
runcmd:
 - [ curl, "https://www.arcfra.com/", -o, /root/arcfra.html ]

Creating a virtual machine via AOC RESTful API or SDK

You can also create a virtual machine via the AOC RESTful API or SDK and configure the initialization data for the virtual machine.