Skip to content

czerw/openqa2vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

experimental

openqa2vm

openqa2vm is shell script for manipulation of qcow2 images generated by openQA.

Description

It has ability to download, prepare and install images, start virtual machine using terraform with libvirt provider. Virtual machines can be started on local libvirt or remote libvirt locations. Root privileges are needed to prepare/install qcow2 images and create/start/stop/delete virtual machines.

Information about IP address provided, when is virtual machine successfully started. Connection to cloned machine can be done using ssh as root. Keys for ssh are automatically injected from logged user who runs openqa2vm script.

Default openQA instance is openqa.opensuse.org, but it can be changed by -f option or environment variable FROM to any openQA instance like openqa.suse.de or even private instance.

Local libvirt qemu:///system is used as default with NAT network. Type of the network can be changed to bridge by -b option or BRIDGE variable with supplied name of the bridge interface. If you want to set macvtap interface, use environment variable MACVTAP with network device.

Remote libvirt can be configured by environment variable LIBVIRT_HOST, ssh access for root user is needed for remote libvirt operations.

Environmental variables MEMORY, VCPU, NODES can be used to configure amount of memory, cpus and number nodes of virtual machines. Variables LIBVIRT_VOLUME_POOL and LIBVIRT_IMAGE_DIR are available for advanced configuration of libvirt volume pools.

All environmental variables can be supplied on command line or defined in /etc/openqa2vm/default configuration file. You can re-define configuration file by CFG_FILE variable to have multiple configuration files for different scenarios.

Default values of variables:

  • CFG_FILE /etc/openqa2vm/default
  • FROM openqa.suse.de
  • SSH_KEY_USER currently logged user who runs openqa2vm script
  • SSH_KEY_FILE created from SSH_KEY_USER
  • LIBVIRT_HOST not set
  • LIBVIRT_IMAGE_DIR /var/lib/libvirt/images
  • LIBVIRT_VOLUME_POOL default
  • NODES 1
  • MEMORY 1024
  • VCPU 1
  • BRIDGE not set
  • MACVTAP not set

Requirements

Terraform for virtual machine management

Add terraform OBS repository.

openSUSE Tumbleweed

sudo zypper ar https://download.opensuse.org/repositories/systemsmanagement:/terraform/openSUSE_Tumbleweed/systemsmanagement:terraform.repo

openSUSE Leap 15.0

sudo zypper ar https://download.opensuse.org/repositories/systemsmanagement:/terraform/openSUSE_Leap_15.0/systemsmanagement:terraform.repo

Installation

Add openqa2vm OBS repository.

openSUSE Tumbleweed

sudo zypper ar https://download.opensuse.org/repositories/home:/czerw:/openqa2vm/openSUSE_Tumbleweed/home:czerw:openqa2vm.repo 

openSUSE Leap 15.0

sudo zypper ar https://download.opensuse.org/repositories/home:/czerw:/openqa2vm/openSUSE_Leap_15.0/home:czerw:openqa2vm.repo 

Install openqa2vm package

sudo zypper in openqa2vm 

Usage

Find proper job on openQA instance. It can be openqa.suse.de, openqa.opensuse.org or on any openQA private installation. Job must produce image defined in PUBLISH_HDD_1 or job has defined image in HDD_1 variable. Installation only jobs don't generate images, they are not suited for openqa2vm. Look for create_hdd_* or mru-install-* jobs.

Options:
  -f HOST     get job from specified host (default openqa.opensuse.org) 
  -b BRIDGE   enable bridge networking on BRIDGE
  -s JOBID    show information about job
  -d JOBID    download image for the job
  -p JOBID    prepare image for virtual machine
  -i JOBID    install image to libvirt directory
  -r JOBID    run virtual machine
  -x JOBID    destroy(stop and delete) virtual machine
  -c JOBID    openqa2vm cleanup 
              stop vm, delete vm, delete images, delete tmp files
  -h          display help

Examples

Show job information on o.s.d

sudo openqa2vm -f openqa.suse.de -s 2783196

Show job information on o.o.o

sudo openqa2vm -s 899225

Create (download, prepare and install image) and start virtual machine

sudo openqa2vm -r 899225

Download qcow2 image

sudo openqa2vm -d 899225

Prepare qcow2 image

sudo openqa2vm -p 899225

Install qcow2 image to libvirt directory /var/lib/libvirt/images

sudo openqa2vm -i 899225

Create and start virtual machine

sudo openqa2vm -r 899225

Destroy (stop and delete) virtual machine

sudo openqa2vm -x 899225

Clean job files, stop and delete virtual machine, delete image file

sudo openqa2vm -c 899225

Create dual node cluster with 4096 MB RAM and 2 VCPUs for each node on remote libvirt system

sudo LIBVIRT_HOST=192.168.50.250 MEMORY=4096 VCPU=2 NODES=2 openqa2vm -b br0 -x 899225

Contributing

Pull requests are welcomed :)

License

GPLv3

Releases

No releases published

Packages

No packages published

Languages