vm5k.actions

A set of functions to manipulate virtual machines on Grid‘5000

This module provides tools to interact with the virtual machines.

VM definition and distribution

vm5k.actions.show_vms(vms)

Print a short resume of vms parameters.

Params vms:a list containing a dict by virtual machine
vm5k.actions.define_vms(vms_id, template=None, ip_mac=None, tap=None, state=None, host=None, n_cpu=None, cpusets=None, mem=None, hdd=None, backing_file=None, real_file=None)

Create a list of virtual machines, where VM parameter is a dict similar to {‘id’: None, ‘host’: None, ‘ip’: None, ‘mac’: None, ‘mem’: 512, ‘n_cpu’: 1, ‘cpuset’: ‘auto’, ‘hdd’: 10, ‘backing_file’: ‘/tmp/vm-base.img’, ‘state’: ‘KO’}

Can be generated from a template or using user defined parameters that can be a single element or a list of element

Parameters:
  • vms_id – a list of string that will be used as vm id
  • template – an XML element defining the template of the VM
  • ip_mac – a list of tuple containing ip, mac correspondance
  • state – the state of the VM
  • host – the host of the VM (string)
  • n_cpu – the number of virtual CPU of the VMs
  • real_file – boolean to use a real file
vm5k.actions.distribute_vms(vms, hosts, distribution='round-robin')

Distribute the virtual machines on the hosts.

Parameters:
  • vms – a list of VMs dicts which host key will be updated
  • hosts – a list of hosts
  • distribution – a string defining the distribution type: ‘round-robin’, ‘concentrated’, ‘n_by_hosts’, ‘random
vm5k.actions.list_vm(hosts, not_running=False)

Return the list of VMs on hosts using a disk which keys are the hosts and value are list of VM id

VM state

vm5k.actions.destroy_vms(hosts, undefine=False)

Destroy all the VM on the hosts

vm5k.actions.create_disks(vms)

Return an action to create the disks for the VMs on the hosts

vm5k.actions.create_disks_all_hosts(vms, hosts)

Create a temporary file containing the vms disks creation commands upload it and run it on the hosts

vm5k.actions.install_vms(vms)

Return an action to install the VM on the hosts

vm5k.actions.start_vms(vms)

Return an action to start the VMs on the hosts

vm5k.actions.wait_vms_have_started(vms, restart=True)

Scan port 22 on all vms, distributed on hosts

vm5k.actions.migrate_vm(vm, host)

Migrate a VM to an host

vm5k.actions.rm_qcow2_disks(hosts)

Removing qcow2 disks located in /tmp