Provisioning virtual machines on oVirt

oVirt is an enterprise-grade server and desktop virtualization platform. In orcharhino, you can manage virtualization functions through oVirt’s REST API. This includes creating virtual machines and controlling their power states.

You can use oVirt provisioning to create virtual machines over a network connection or from an existing image.

You can use cloud-init to configure the virtual machines that you provision. Using cloud-init avoids any special configuration on the network, such as a managed DHCP and TFTP, to finish the installation of the virtual machine. This method does not require orcharhino to connect to the provisioned virtual machine using SSH to run the finish script.

Prerequisites
  • Provide the installation medium for the operating systems that you want to use to provision hosts. For more information, see Syncing Repositories in Managing Content.

  • Provide an activation key for host registration. For more information, see Creating An Activation Key in Managing Content.

  • A orcharhino Proxy managing a logical network on the oVirt environment. Ensure no other DHCP services run on this network to avoid conflicts with orcharhino Proxy. For more information, see Configuring Networking in Provisioning Hosts.

  • An existing template, other than the blank template, if you want to use image-based provisioning. For more information about creating templates for virtual machines, see Templates in the oVirt documentation.

  • An administration-like user on oVirt for communication with orcharhino Server. Do not use the admin@internal user for this communication. Instead, create a new oVirt user with the following permissions:

    • System > Configure System > Login Permissions

    • Network > Configure vNIC Profile > Create

    • Network > Configure vNIC Profile > Edit Properties

    • Network > Configure vNIC Profile > Delete

    • Network > Configure vNIC Profile > Assign vNIC Profile to VM

    • Network > Configure vNIC Profile > Assign vNIC Profile to Template

    • Template > Provisioning Operations > Import/Export

    • VM > Provisioning Operations > Create

    • VM > Provisioning Operations > Delete

    • VM > Provisioning Operations > Import/Export

    • VM > Provisioning Operations > Edit Storage

    • Disk > Provisioning Operations > Create

    • Disk > Disk Profile > Attach Disk Profile

      For more information about how to create a user and add permissions in oVirt, see Users and Roles in the oVirt documentation.

Installing the oVirt plugin

Install the oVirt plugin to attach an oVirt compute resource provider to orcharhino. This allows you to manage and deploy hosts to oVirt.

Procedure
  • Install the oVirt compute resource provider on your orcharhino Server:

    # orcharhino-installer --enable-foreman-compute-ovirt
Verification
  • Optional: In the orcharhino management UI, navigate to Administer > About and select the Compute resources tab to verify the installation of the oVirt plugin.

Adding the oVirt connection to orcharhino Server

Use this procedure to add oVirt as a compute resource in orcharhino. To use the CLI instead of the orcharhino management UI, see the CLI procedure.

Procedure
  1. In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click Create Compute Resource.

  2. In the Name field, enter a name for the new compute resource.

  3. From the Provider list, select oVirt.

  4. In the Description field, enter a description for the compute resource.

  5. In the URL field, enter the connection URL for the oVirt Engine’s API in the following form: https://ovirt.example.com/ovirt-engine/api/v4.

  6. In the User field, enter the name of a user with permissions to access oVirt Engine’s resources.

  7. In the Password field, enter the password of the user.

  8. Click Load Datacenters to populate the Datacenter list with data centers from your oVirt environment.

  9. From the Datacenter list, select a data center.

  10. From the Quota ID list, select a quota to limit resources available to orcharhino.

  11. In the X509 Certification Authorities field, enter the certificate authority for SSL/TLS access. Alternatively, if you leave the field blank, a self-signed certificate is generated on the first API request by the server.

  12. Click the Locations tab and select the location you want to use.

  13. Click the Organizations tab and select the organization you want to use.

  14. Click Submit to save the compute resource.

CLI procedure
  • Enter the hammer compute-resource create command with Ovirt for --provider and the name of the data center you want to use for --datacenter.

    # hammer compute-resource create \
    --name "My_oVirt" --provider "Ovirt" \
    --description "oVirt server at ovirt.example.com" \
    --url "https://ovirt.example.com/ovirt-engine/api" \
    --user "orcharhino_User" --password "My_Password" \
    --locations "New York" --organizations "My_Organization" \
    --datacenter "My_Datacenter"

Preparing cloud-init images in oVirt

To use cloud-init during provisioning, you must prepare an image with cloud-init installed in oVirt, and then import the image to orcharhino to use for provisioning.

Procedure
  1. In oVirt, create a virtual machine to use for image-based provisioning in orcharhino.

  2. On the virtual machine, install cloud-init:

    # zypper install cloud-init
  3. To the /etc/cloud/cloud.cfg file, add the following information:

    datasource_list: ["NoCloud", "ConfigDrive"]
  4. In oVirt, create an image from this virtual machine.

When you add this image to orcharhino, ensure that you select the User Data checkbox.

Adding oVirt images to orcharhino Server

To create hosts using image-based provisioning, you must add information about the image, such as access details and the image location, to your orcharhino Server.

To use the CLI instead of the orcharhino management UI, see the CLI procedure.

Procedure
  1. In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click the name of the oVirt connection.

  2. Click Create Image.

  3. In the Name field, enter a name for the image.

  4. From the Operating System list, select the base operating system of the image.

  5. From the Architecture list, select the operating system architecture.

  6. In the Username field, enter the SSH user name for image access. This is normally the root user.

  7. In the Password field, enter the SSH password for image access.

  8. From the Image list, select an image from the oVirt compute resource.

  9. Optional: Select the User Data checkbox if the image supports user data input, such as cloud-init data.

  10. Click Submit to save the image details.

CLI procedure
  • Create the image with the hammer compute-resource image create command. Use the --uuid option to store the template UUID on the oVirt server.

    # hammer compute-resource image create \
    --name "oVirt_Image" \
    --compute-resource "My_oVirt"
    --operatingsystem "RedHat version" \
    --architecture "x86_64" \
    --username root \
    --uuid "9788910c-4030-4ae0-bad7-603375dd72b1" \

Preparing a cloud-init template

Procedure
  1. In the orcharhino management UI, navigate to Hosts > Templates > Provisioning Templates, and click Create Template.

  2. In the Name field, enter a name for the template.

  3. In the Editor field, enter the following template details:

    <%#
    kind: user_data
    name: Cloud-init
    -%>
    #cloud-config
    hostname: <%= @host.shortname %>
    
    <%# Allow user to specify additional SSH key as host parameter -%>
    <% if @host.params['sshkey'].present? || @host.params['remote_execution_ssh_keys'].present? -%>
    ssh_authorized_keys:
    <% if @host.params['sshkey'].present? -%>
      - <%= @host.params['sshkey'] %>
    <% end -%>
    <% if @host.params['remote_execution_ssh_keys'].present? -%>
    <% @host.params['remote_execution_ssh_keys'].each do |key| -%>
      - <%= key %>
    <% end -%>
    <% end -%>
    <% end -%>
    runcmd:
      - |
        #!/bin/bash
    <%= indent 4 do
        snippet 'subscription_manager_registration'
    end %>
    <% if @host.info['parameters']['realm'] && @host.realm && @host.realm.realm_type == 'Red Hat Identity Management' -%>
      <%= indent 4 do
        snippet 'freeipa_register'
      end %>
    <% end -%>
    <% unless @host.operatingsystem.atomic? -%>
        # update all the base packages from the updates repository
        yum -t -y -e 0 update
    <% end -%>
    <%
        # safemode renderer does not support unary negation
        non_atomic = @host.operatingsystem.atomic? ? false : true
        pm_set = @host.puppetmaster.empty? ? false : true
        puppet_enabled = non_atomic && (pm_set || @host.params['force-puppet'])
    %>
    <% if puppet_enabled %>
        yum install -y puppet
        cat > /etc/puppet/puppet.conf << EOF
      <%= indent 4 do
        snippet 'puppet.conf'
      end %>
        EOF
        # Setup puppet to run on system reboot
        /sbin/chkconfig --level 345 puppet on
    
        /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags no_such_tag <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize
        /sbin/service puppet start
    <% end -%>
    phone_home:
     url: <%= foreman_url('built') %>
     post: []
     tries: 10pp
  4. Click the Type tab and from the Type list, select User data template.

  5. Click the Association tab, and from the Applicable Operating Systems list, select the operating system that you want associate with the template.

  6. Click the Locations tab, and from the Locations list, select the location that you want to associate with the template.

  7. Click the Organizations tab, and from the Organization list, select the organization that you want to associate with the template.

  8. Click Submit.

  9. In the orcharhino management UI, navigate to Hosts > Provisioning Setup > Operating Systems.

  10. Select the operating system you want to associate with the template.

  11. Click the Templates tab, and from the User data template list, select the name of the new template.

  12. Click Submit.

Adding oVirt details to a compute profile

Use this procedure to add oVirt hardware settings to a compute profile. When you create a host on KVM using this compute profile, these settings are automatically populated.

To use the CLI instead of the orcharhino management UI, see the CLI procedure.

Procedure
  1. In the orcharhino management UI, navigate to Infrastructure > Compute Profiles.

  2. In the Compute Profiles window, click the name of an existing compute profile, or click Create Compute Profile, enter a Name, and click Submit.

  3. Click the name of the oVirt compute resource.

  4. From the Cluster list, select the target host cluster in the oVirt environment.

  5. From the Template list, select the oVirt template to use for the Cores and Memory settings.

  6. In the Cores field, enter the number of CPU cores to allocate to the new host.

  7. In the Memory field, enter the amount of memory to allocate to the new host.

  8. From the Image list, select image to use for image-based provisioning.

  9. In the Network Interfaces area, enter the network parameters for the host’s network interface. You can create multiple network interfaces. However, at least one interface must point to a orcharhino Proxy-managed network. For each network interface, enter the following details:

    1. In the Name field, enter the name of the network interface.

    2. From the Network list, select The logical network that you want to use.

  10. In the Storage area, enter the storage parameters for the host. You can create multiple volumes for the host. For each volume, enter the following details:

    1. In the Size (GB) enter the size, in GB, for the new volume.

    2. From the Storage domain list, select the storage domain for the volume.

    3. From the Preallocate disk, select either thin provisioning or preallocation of the full disk.

    4. From the Bootable list, select whether you want a bootable or non-bootable volume.

  11. Click Submit to save the compute profile.

CLI procedure
  1. To create a compute profile, enter the following command:

    # hammer compute-profile create --name "oVirt CP"
  2. To set the values for the compute profile, enter the following command:

    # hammer compute-profile values create --compute-profile "oVirt CP" \
    --compute-resource "My_oVirt" \
    --interface "compute_interface=Interface_Type,compute_name=eth0,compute_network=satnetwork" \
    --volume "size_gb=20G,storage_domain=Data,bootable=true" \
    --compute-attributes "cluster=Default,cores=1,memory=1073741824,start=true""

Creating hosts on oVirt

In orcharhino, you can use oVirt provisioning to create hosts over a network connection or from an existing image:

  • If you want to create a host over a network connection, the new host must be able to access either orcharhino Server’s integrated orcharhino Proxy or an external orcharhino Proxy on a oVirt virtual network, so that the host has access to PXE provisioning services. This new host entry triggers the oVirt server to create and start a virtual machine. If the virtual machine detects the defined orcharhino Proxy through the virtual network, the virtual machine boots to PXE and begins to install the chosen operating system.

  • If you want to create a host with an existing image, the new host entry triggers the oVirt server to create the virtual machine using a pre-existing image as a basis for the new volume.

To use the CLI instead of the orcharhino management UI, see the CLI procedure.

DHCP conflicts

For network-based provisioning, if you use a virtual network on the oVirt server for provisioning, select a network that does not provide DHCP assignments. This causes DHCP conflicts with orcharhino Server when booting new hosts.

Procedure
  1. In the orcharhino management UI, navigate to Hosts > Create Host.

  2. In the Name field, enter a name for the host.

  3. Optional: Click the Organization tab and change the organization context to match your requirement.

  4. Optional: Click the Location tab and change the location context to match your requirement.

  5. From the Host Group list, select a host group that you want to assign your host to. That host group will populate the form.

  6. From the Deploy on list, select the oVirt connection.

  7. From the Compute Profile list, select a profile to use to automatically populate virtual machine settings. The oVirt-specific fields are populated with settings from your compute profile. Modify these settings if required.

  8. Click the Interfaces tab, and on the interface of the host, click Edit.

  9. Verify that the fields are populated with values. Note in particular:

    • orcharhino automatically assigns an IP address for the new host.

    • Ensure that the MAC address field is blank. oVirt assigns a MAC address to the host during provisioning.

    • The Name from the Host tab becomes the DNS name.

    • Ensure that orcharhino automatically selects the Managed, Primary, and Provision options for the first interface on the host. If not, select them.

  10. Click OK to save. To add another interface, click Add Interface. You can select only one interface for Provision and Primary.

  11. Click the Operating System tab, and confirm that all fields automatically contain values.

  12. Select the Provisioning Method that you want to use:

    • For network-based provisioning, click Network Based.

    • For image-based provisioning, click Image Based.

  13. Click Resolve in Provisioning templates to check the new host can identify the right provisioning templates to use.

  14. Click the Virtual Machine tab and confirm that these settings are populated with details from the host group and compute profile. Modify these settings to suit your needs.

  15. Click the Parameters tab, and ensure that a parameter exists that provides an activation key. If not, add an activation key.

  16. Click Submit to save the host entry.

CLI procedure
  • To use network-based provisioning, create the host with the hammer host create command and include --provision-method build. Replace the values in the following example with the appropriate values for your environment.

    # hammer host create \
    --build true \
    --compute-attributes="cluster=Default,cores=1,memory=1073741824,start=true" \
    --compute-resource "MyoVirt_" \
    --enabled true \
    --hostgroup "My_Host_Group" \
    --interface "managed=true,primary=true,provision=true,compute_name=eth0,compute_network=satnetwork" \
    --location "My_Location" \
    --managed true \
    --name "My_Host_Name" \
    --organization "My_Organization" \
    --provision-method build \
    --volume="size_gb=20G,storage_domain=Data,bootable=true"
  • To use image-based provisioning, create the host with the hammer host create command and include --provision-method image. Replace the values in the following example with the appropriate values for your environment.

    # hammer host create \
    --compute-attributes="cluster=Default,cores=1,memory=1073741824,start=true" \
    --compute-resource "MyoVirt_" \
    --enabled true \
    --hostgroup "My_Host_Group" \
    --image "MyoVirt_Image_" \
    --interface "managed=true,primary=true,provision=true,compute_name=eth0,compute_network=satnetwork" \
    --location "My_Location" \
    --managed true \
    --name "My_Host_Name" \
    --organization "My_Organization" \
    --provision-method "image" \
    --volume="size_gb=20G,storage_domain=Data,bootable=true"

For more information about additional host creation parameters for this compute resource, enter the hammer host create --help command.

The text and illustrations on this page are licensed by ATIX AG under a Creative Commons Attribution Share Alike 4.0 International ("CC BY-SA 4.0") license. This page also contains text from the official Foreman documentation which uses the same license ("CC BY-SA 4.0").