Code Monkey home page Code Monkey logo

openqa2vm's Introduction

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

openqa2vm's People

Contributors

czerw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

openqa2vm's Issues

try to download HDD_1 image in case PUBLISH_HDD_1 wasn't created

Currently openqa2vm is checking if variable PUBLISH_HDD_1 exists and if not, goes to HDD_1 variable. In case PUBLISH_HDD_1 variable is present, but test failed before expected qcow2 was created, download fails, whereas it could get at least HDD_1 image.

Set system hostname

All openQA images has same hostname and it is not comfortable to have several servers with same hostname.

We need to make difference between different virtual machines:

  • automatically generate hostname from job details (version, name etc...)
  • add configuration option to set hostname

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.