Skip to content

Automatic VM creation on KVM using robotframework

Notifications You must be signed in to change notification settings

iorchard/robot4kvm

Repository files navigation

Robot4KVM

This is robot automation process for VM setup using KVM hypervisor.

Here is the automated process.

  1. Downloads the latest debian stable openstack image and SHA256 checksum and signature files.
  2. Verify the checksum and image files.
  3. Copy the downloaded source image to VM images.
  4. Create virsh xml file and interfaces file.
  5. Manipulate VM images with vm_man.sh script.
  6. Define VM.
  7. Start VM.

Pre-requisite

Install libguestfs-tools package.:

$ sudo apt update && sudo apt install -y libguestfs-tools

Install robot framework. I always create virtual env to have python environment.:

$ sudo apt install -y python3-venv dirmngr
$ python3 -m venv ~/.envs/robot
$ source ~/.envs/robot/bin/activate
(robot) $ pip install wheel
(robot) $ pip install robotframework

Before running robot codes, edit the following files in data/ directory for your environment.

  • default.tpl: virsh xml template for admin and client vm. You can change anything except upper-case placeholder variables like NAME, MEM, CORES, UUID.
  • grub: grub file to inject into VM

Copy props.py.sample to props.py and edit props.py until "# Do not edit below this line!!!"

Run

To set up VMs:

(robot) $ read -s -p 'user pw: ' USERPW
user pw:
(robot) $ export USERPW
(robot) $ robot -d output setup.robot
(robot) $ unset USERPW

USERPW variable should be set up before running robot tasks. It is to set up the password of USERID in VM. (USERID is defined in props.py)

You can run each task in setup.robot separately with -i <tag_name> option.

  1. Get VM image template.:

    (robot) $ robot -d output -i preflight setup.robot
    
  2. Prepare VM image.:

    (robot) $ robot -d output -i takeoff setup.robot
    
  3. Run VM.:

    (robot) $ robot -d output -i flying setup.robot
    

Tear Down

To tear down VMs.:

(robot) $ robot -d output teardown.robot

It will stop VMs and delete VM images.

About

Automatic VM creation on KVM using robotframework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published