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.
-
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.
-
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.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click Create Compute Resource.
-
In the Name field, enter a name for the new compute resource.
-
From the Provider list, select oVirt.
-
In the Description field, enter a description for the compute resource.
-
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
. -
In the User field, enter the name of a user with permissions to access oVirt Engine’s resources.
-
In the Password field, enter the password of the user.
-
Click Load Datacenters to populate the Datacenter list with data centers from your oVirt environment.
-
From the Datacenter list, select a data center.
-
From the Quota ID list, select a quota to limit resources available to orcharhino.
-
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.
-
Click the Locations tab and select the location you want to use.
-
Click the Organizations tab and select the organization you want to use.
-
Click Submit to save the compute resource.
-
Enter the
hammer compute-resource create
command withOvirt
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.
-
In oVirt, create a virtual machine to use for image-based provisioning in orcharhino.
-
On the virtual machine, install
cloud-init
:dnf install cloud-init
-
To the
/etc/cloud/cloud.cfg
file, add the following information:datasource_list: ["NoCloud", "ConfigDrive"]
-
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.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click the name of the oVirt connection.
-
Click Create Image.
-
In the Name field, enter a name for the image.
-
From the Operating System list, select the base operating system of the image.
-
From the Architecture list, select the operating system architecture.
-
In the Username field, enter the SSH user name for image access. This is normally the
root
user. -
In the Password field, enter the SSH password for image access.
-
From the Image list, select an image from the oVirt compute resource.
-
Optional: Select the User Data checkbox if the image supports user data input, such as
cloud-init
data. -
Click Submit to save the image details.
-
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
-
In the orcharhino management UI, navigate to Hosts > Provisioning Templates, and click Create Template.
-
In the Name field, enter a name for the template.
-
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
-
Click the Type tab and from the Type list, select User data template.
-
Click the Association tab, and from the Applicable Operating Systems list, select the operating system that you want associate with the template.
-
Click the Locations tab, and from the Locations list, select the location that you want to associate with the template.
-
Click the Organizations tab, and from the Organization list, select the organization that you want to associate with the template.
-
Click Submit.
-
In the orcharhino management UI, navigate to Hosts > Operating Systems, and select the operating system you want to associate with the template.
-
Click the Templates tab, and from the User data template list, select the name of the new template.
-
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.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Profiles.
-
In the Compute Profiles window, click the name of an existing compute profile, or click Create Compute Profile, enter a Name, and click Submit.
-
Click the name of the oVirt compute resource.
-
From the Cluster list, select the target host cluster in the oVirt environment.
-
From the Template list, select the oVirt template to use for the Cores and Memory settings.
-
In the Cores field, enter the number of CPU cores to allocate to the new host.
-
In the Memory field, enter the amount of memory to allocate to the new host.
-
From the Image list, select image to use for image-based provisioning.
-
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:
-
In the Name field, enter the name of the network interface.
-
From the Network list, select The logical network that you want to use.
-
-
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:
-
In the Size (GB) enter the size, in GB, for the new volume.
-
From the Storage domain list, select the storage domain for the volume.
-
From the Preallocate disk, select either thin provisioning or preallocation of the full disk.
-
From the Bootable list, select whether you want a bootable or non-bootable volume.
-
-
Click Submit to save the compute profile.
-
To create a compute profile, enter the following command:
$ hammer compute-profile create --name "oVirt CP"
-
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.
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.
-
In the orcharhino management UI, navigate to Hosts > Create Host.
-
In the Name field, enter a name for the host.
-
Click the Organization and Location tabs to ensure that the provisioning context is automatically set to the current context.
-
From the Host Group list, select the host group that you want to use to populate the form.
-
From the Deploy on list, select the oVirt connection.
-
From the Compute Profile list, select a profile to use to automatically populate virtual machine settings.
-
Click the Interface tab and click Edit on the host’s interface.
-
Verify that the fields are automatically populated, particularly the following items:
-
The Name from the Host tab becomes the DNS name.
-
orcharhino Server automatically assigns an IP address for the new host.
-
The MAC address field is blank. The oVirt server assigns a MAC address to the host.
-
The Managed, Primary, and Provision options are automatically selected for the first interface on the host. If not, select them.
-
The oVirt-specific fields are populated with settings from your compute profile. Modify these settings if required.
-
-
Click the Operating System tab, and confirm that all fields automatically contain values.
-
Select the Provisioning Method that you want to use:
-
For network-based provisioning, click Network Based.
-
For image-based provisioning, click Image Based.
-
-
Click Resolve in Provisioning templates to check the new host can identify the right provisioning templates to use.
-
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.
-
Click the Parameters tab, and ensure that a parameter exists that provides an activation key. If not, add an activation key.
-
Click Submit to save the host entry.
-
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 \ --name "oVirt-vm1" \ --organization "My_Organization" \ --location "New York" \ --hostgroup "Base" \ --compute-resource "My_oVirt" \ --provision-method build \ --build true \ --enabled true \ --managed true \ --interface "managed=true,primary=true,provision=true,compute_name=eth0,compute_network=satnetwork" \ --compute-attributes="cluster=Default,cores=1,memory=1073741824,start=true" \ --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 \ --name "oVirt-vm2" \ --organization "My_Organization" \ --location "New York" \ --hostgroup "Base" \ --compute-resource "My_oVirt" \ --provision-method image \ --image "oVirt_Image" \ --enabled true \ --managed true \ --interface "managed=true,primary=true,provision=true,compute_name=eth0,compute_network=satnetwork" \ --compute-attributes="cluster=Default,cores=1,memory=1073741824,start=true" \ --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 3.0 Unported ("CC-BY-SA") license. This page also contains text from the official Foreman documentation which uses the same license ("CC-BY-SA"). |