Libvirt Cloud Module

Example provider:

# A provider maps to a libvirt instance
  driver: libvirt
  # url: "qemu+ssh://user@remotekvm/system?socket=/var/run/libvirt/libvirt-sock"
  url: qemu:///system

Example profile:

  # points back at provider configuration e.g. the libvirt daemon to talk to
  provider: my-libvirt-config
  base_domain: base-image
  # ip_source = [ ip-learning | qemu-agent ]
  ip_source: ip-learning
  # clone_strategy = [ quick | full ]
  clone_strategy: quick
  ssh_username: vagrant
  # has_ssh_agent: True
  password: vagrant
  # if /tmp is mounted noexec do workaround
  deploy_command: sh /tmp/.saltcloud/
  # -F makes the bootstrap script overwrite existing config
  # which make reprovisioning a box work
  script_args: -F
    sushi: more tasty
  # point at the another master at another port
    master_port: 5506

Tested on: - Fedora 26 (libvirt 3.2.1, qemu 2.9.1) - Fedora 25 (libvirt, qemu 2.6.1) - Fedora 23 (libvirt 1.2.18, qemu 2.4.1) - Centos 7 (libvirt 1.2.17, qemu 1.5.3)

Provision a single machine, call=None)

This function irreversibly destroys a virtual machine on the cloud provider. Before doing so, it should fire an event on the Salt event bus.

The tag for this event is salt/cloud/<vm name>/destroying. Once the virtual machine has been destroyed, another event is fired. The tag for that event is salt/cloud/<vm name>/destroyed.



@param name: @type name: str @param call: @type call: @return: True if all went well, otherwise an error message @rtype: bool|str, domain)

Clean up clone domain leftovers as much as possible.

Extra robust clean up in order to deal with some small changes in libvirt behavior over time. Passed in volumes and domains are deleted, any errors are ignored. Used when cloning/provisioning a domain fails.


cleanup -- list containing dictionaries with two keys: 'what' and 'item'. If 'what' is domain the 'item' is a libvirt domain object. If 'what' is volume then the item is a libvirt volume object.



New in version 2017.7.3., path)

Return the first configured instance., idx, ip_source, skip_loopback=True), ip_source), domain), error)

Redirect stderr prints from libvirt to salt logging.

Return a list of the VMs

id (str) image (str) size (str) state (str) private_ips (list) public_ips (list)

Because this module is not specific to any cloud providers, there will be no nodes to list.

Return a list of the VMs that are on the provider, with select fields