Search Docs...
⌘ K
OverviewDeploymentManagementOperationReference

After creating the cloud-init template, you can use it to create new virtual machines. During this process, you can configure not only regular parameters, but also the initialization data for the newly created virtual machines.

You can create the virtual machines either on the AOC management platform or web console, or via the AOC RESTful API or AOC SDK. Note that this section only covers the initial configuration when creating a virtual machine from the cloud-init template. For details on creating a virtual machine from the virtual machine template, see the Creating a virtual machine from a template section.

Creating a virtual machine with cloud-init on AOC or via the web console

The steps of creating a virtual machine via the web console and AOC are similar. The following procedure uses AOC 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 cloud-init template you have created. Then refer to "Virtual machine configuration options" chapter for configuring the basic information, computing resources, storage resources and other items to the virtual machine.

  3. When configuring Network device, go to Cloud-init configuration and choose the IP address configuration mode for the virtual machine:

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

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

    • Not configured: No IP address is configured.

    Note:

    When the VM network type is VPC networking, leaving the IP address blank will disable the Configure static IP address option. If you already input an IP address and select the Configure static IP address option, the IP address you input will be automatically configured as the virtual machine static IP.

  4. In the Initial 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. AVE supports up to 32 KB of user data. See the User data examples section for examples.

  5. Click Create.

User data examples

Refer to the official cloud-init documentation for supported user data:

This section provides examples using User Data Script and Cloud-Config Runcmd to configure the user data. You can refer to the official documentation for other configurations if needed.

User Data Script

Configure Shell Script as follows so that the virtual machine with cloud-init executes the echo "Hello World. The time is now $(date -R)!" >> /root/arcfra.txt command on its first boot:

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

Cloud-Config Runcmd

Configure Cloud-Config Runcmd as follows so that the virtual machine with cloud-init executes the curl https://www.arcfra.com/ -o /root/arcfra.html command on its first boot:

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

Creating a virtual machine with cloud-init via AOC RESTful API or SDK

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