# salt.cloud.clouds.libvirt

## Libvirt Cloud Module

Example provider:

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

Example profile:

    base-itest:
      # 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/deploy.sh
      # -F makes the bootstrap script overwrite existing config
      # which make reprovisioning a box work
      script_args: -F
      grains:
        sushi: more tasty
      # point at the another master at another port
      minion:
        master: 192.168.16.1
        master_port: 5506

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

salt.cloud.clouds.libvirt.create(vm_)

  Provision a single machine

salt.cloud.clouds.libvirt.create_volume_with_backing_store_xml(volume)

salt.cloud.clouds.libvirt.create_volume_xml(volume)

salt.cloud.clouds.libvirt.destroy(name, 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.

  Dependencies:

    list_nodes

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

salt.cloud.clouds.libvirt.destroy_domain(conn, domain)

salt.cloud.clouds.libvirt.do_cleanup(cleanup)

  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.

  Parameters:

    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.

  Returns:

    none

  Added in version 2017.7.3.

salt.cloud.clouds.libvirt.find_pool_and_volume(conn, path)

salt.cloud.clouds.libvirt.generate_new_name(orig_name)

salt.cloud.clouds.libvirt.get_configured_provider()

  Return the first configured instance.

salt.cloud.clouds.libvirt.get_domain_ip(domain, idx, ip_source, skip_loopback=True)

salt.cloud.clouds.libvirt.get_domain_ips(domain, ip_source)

salt.cloud.clouds.libvirt.get_domain_volumes(conn, domain)

salt.cloud.clouds.libvirt.libvirt_error_handler(ctx, error)

  Redirect stderr prints from libvirt to salt logging.

salt.cloud.clouds.libvirt.list_nodes(call=None)

  Return a list of the VMs

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

salt.cloud.clouds.libvirt.list_nodes_full(call=None)

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

salt.cloud.clouds.libvirt.list_nodes_select(call=None)

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

salt.cloud.clouds.libvirt.to_ip_addr_type(addr_type)