Skip to content

TUTORIAL: Libvirt Host CentOS7

vlj91 edited this page Sep 18, 2015 · 6 revisions

#CentOS7 Libvirt Host

Guide to building OpenStack ready images using a CentOS7 libvirt host in an OpenStack environment.

##Prerequisites

  1. OpenStack Environment Access
  2. OpenStack User Networking Setup

##CentOS7 Libvirt Host - OpenStack Compute Instance

###Creating a CentOS7 Compute Instance To begin creating the CentOS7 Nova instance to build OpenStack ready images, log in to the preferred method of creating OpenStack compute instances (Horizon GUI or CLI).

Note: If no CentOS6 cloud image is available in the public Glance repository, a CentOS6 cloud image can be added to the Glance registry from the following mirror:

#### Creating via Horizon To begin creating a libvirt build host, navigate to the Compute -> Instances tab within Horizon, then click the Launch Instance button. Several options are available, we have included our recommended settings for creating a CentOS7 libvirt host:

Option Recommended Setting
Details -> Availability Zone regionOne
Details -> Instance Name User preference - sets hostname of instance
Details -> Flavor m1.medium
Details -> Instance Count 1
Details -> Instance Boot Source Boot from image -> CentOS7
Access & Security -> Key Pair Select Nova keypair to insert to instance
Access & Security -> Security Groups Select Neutron Security Groups to use, to access via SSH ensure a security group with incoming port 22 (SSH) enabled
Networking -> Selected Networks Select which networks to use
Post-Creation -> Customization Script Source Blank, or provide cloud-init for automated setup
Advanced Options -> Disk Partition Automatic

Once the instance has started booting, assign a Floating IP address

#### Creating via CLI SSH to the login node of the OpenStack environment using the provided credentials, and source the appropriate OpenStack RC file to begin using OpenStack services (e.g. . OpenStackRC.sh. If no RC file is available, please contact your system administrator for assistance with obtaining the appropraite OpenStack RC file.

Once appropriate OpenStack networking features have been set up, we can create our CentOS7 build instance with the following:


nova boot VM-NAME \
--flavor 3 \
--image CentOS7  \
--key-name KeystoneKeyPair appropriate keypair previously created \
--nic net-id=NETWORKID # use the unique network ID through neutron net-list\
--security-groups SECGROUP1,SECGROUP2 # security groups required

###CentOS7 Libvirt Host Preperation

#### Preparing via command-line

The following packages are required to begin building the OpenStack image:


$ sudo yum update -y

$ sudo yum groupinstall -y 'Virtualization Tools'

$ sudo yum install -y libguestfs-tools virt-install virt-manager virt-viewer libvirt

$ sudo systemctl restart libvirtd


####Cloud-init

The following can be provided as cloud-init input to customize the image with the required packages. Cloud-init can be provided through the Horizon User customisation setting, or through the nova boot command with the --user-data /path/to/cloudinit option.


#cloud-config

package_upgrade: true 

packages:
 - libguestfs
 - libguestfs-tools
 - virt-manager
 - libvirt
 - kvm
 - virt-install
 - qemu-kvm
 - virt-viewer

runcmd:
 - [ systemctl, restart, libvirtd ]

Clone this wiki locally