Skip to content

win_feature

Pedro Ielpi edited this page Sep 25, 2024 · 4 revisions

Guest Contextualization Features

Similar to the Linux contextualization, Windows images can automatically configure themselves based on the context definitions. The contextualization packages ensure streamlined integration of the VM in the OpenNebula cloud, by leveraging information from the VM. The contextualization process enables users to:

  • Configure guest networking and hostname settings.
  • Set up user credentials for seamless VM access.
  • Define the system timezone.
  • Resize disk partitions as needed.
  • Execute custom actions during boot.

Configuration parameters are passed to the contextualization packages through the CONTEXT attribute of the virtual machine. These parameters can be added to the template by using the CLI or the Sunstone Template Wizard. Below is an example of the context section in the CLI:

    CONTEXT = [
            NETWORK = "YES",
            SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]"
    ]

Network Configuration

OpenNebula does not rely on a DHCP server to configure networking in the Virtual Machines. Instead, it injects the network information in the contextualization section, with the option NETWORK = "YES" (shown in the example above). When OpenNebula finds this option, it adds the IP information for each of the configured network interfaces, plus extra information that resides in the Virtual Network template such as DNS, gateway and network mask.

Users can also customize the method for configuring interface IP addresses through the NIC attributes METHOD (for IPv4) and IP6_METHOD (for IPv6). The supported methods include:

METHOD - IPv4:

  • Empty or static: Assigns static addresses based on context variables.
  • dhcp: Uses DHCPv4.
  • skip: Bypasses IPv4 configuration.

IP6_METHOD - IPv6:

  • Empty or static: Assigns static addresses based on context variables.
  • auto: Enables SLAAC (Stateless Address Autoconfiguration).
  • dhcp: Facilitates SLAAC and DHCPv6.
  • disable: Turns off IPv6 within the guest.
  • skip: Skips IPv6 configuration.

User Credentials

User credentials are an essential configuration item. You will need these credentials to connect to the newly-created Virtual Machine. You can use SSH public key authentication, including on Windows OS images.

To add SSH user credentials, begin by adding your SSH public key(s) to your OpenNebula user configuration. You can add SSH keys using the Sunstone web UI or using the CLI.

Next, ensure that the Virtual Machine will inherit the SSH key of the user that initiated it. In the VM template, include the following option:

CONTEXT = [
    SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]"
]

You can also use the options USERNAME and PASSWORD to create an initial administrator and set their password:

CONTEXT = [
    USERNAME = "Administrator",
    PASSWORD = "VeryComplexPassw0rd"
]

Note

This password is encrypted both within the virtual machine and in the virtual machine template.

Running Scripts on Boot

To execute commands during boot you can use the START_SCRIPT option. This option creates and executes a new file containing the specified value.

CONTEXT = [
    START_SCRIPT="choco upgrade all"
]

For more intricate scripts, use the START_SCRIPT_BASE64 option, which accepts a base64-encoded string that will be decoded before writing the temporary script file.

File System Configuration

OpenNebula enables resizing VM disk images before boot, allowing users to provide lightweight base images. In this case you can instruct the context packages to grow the file systems to match the new disk size. In particular you can add to the CONTEXT section the following options:

  • GROW_ROOTFS: Automatically grows the root file system.
  • GROW_FS: Specifies drives to grow (e.g., C:).

Other System Configuration

The following CONTEXT attributes allow for defining additional configuration on the guest:

  • TIMEZONE: Specifies the time zone to set.
  • SET_HOSTNAME: Sets the VM hostname. Alternatively, add DNS_HOSTNAME = "YES" to set the VM hostname to the reverse DNS name from the first IP.

OneGate Client

OpenNebula offers a centralized service that enables sharing of data between Virtual Machines and the main OpenNebula daemon. You can tailor the interaction between the OpenNebula OneGate server and the OneGate client in the VM, by using the below parameters in the CONTEXT section:

  • TOKEN: When set to YES, adds a security token for the VM to authenticate to the OneGate server.
  • ONEGATE_ENDPOINT: The URL where the OneGate server is running. OpenNebula will automatically add this variable if TOKEN=YES is set. Defaults to http://169.254.16.9:5030. The value is loaded from /etc/one/oned.conf.
  • REPORT_READY: When set to YES the OneGate client in the VM will report to the OneGate server that the VM is READY. This is useful for the OneFlow service to ensure that a VM has finished booting and is effectively in the RUNNING state.
Clone this wiki locally