# salt.modules.libcloud_compute

## Apache Libcloud Compute Management

Connection module for Apache Libcloud Compute management for a full list of supported clouds, see http://libcloud.readthedocs.io/en/latest/compute/supported_providers.html

Clouds include Amazon EC2, Azure, Google GCE, VMware, OpenStack Nova

Added in version 2018.3.0.

configuration:

  This module uses a configuration profile for one or multiple cloud providers

      libcloud_compute:
          profile_test1:
            driver: google
            key: service-account@googlecloud.net
            secret: /path/to.key.json
          profile_test2:
            driver: arm
            key: 12345
            secret: mysecret

depends:

  apache-libcloud

salt.modules.libcloud_compute.attach_volume(node_id, volume_id, profile, device=None, **libcloud_kwargs)

  Attaches volume to node.

  Parameters:

    - node_id (`str`) -- Node ID to target

    - volume_id (`str`) -- Volume ID from which to attach

    - profile (`str`) -- The profile key

    - device (`str`) -- Where the device is exposed, e.g. '/dev/sdb'

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's attach_volume method

  CLI Example:

      salt myminion libcloud_compute.detach_volume vol1 profile1

salt.modules.libcloud_compute.copy_image(source_region, image_id, name, profile, description=None, **libcloud_kwargs)

  Copies an image from a source region to the current region.

  Parameters:

    - source_region (`str`) -- Region to copy the node from.

    - image_id (`str`) -- Image to copy.

    - name (`str`) -- name for new image.

    - profile (`str`) -- The profile key

    - description -- description for new image.

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's copy_image method

  CLI Example:

      salt myminion libcloud_compute.copy_image us-east1 image1 'new image' profile1

salt.modules.libcloud_compute.create_image(node_id, name, profile, description=None, **libcloud_kwargs)

  Create an image from a node

  Parameters:

    - node_id (`str`) -- Node to run the task on.

    - name (`str`) -- name for new image.

    - profile (`str`) -- The profile key

    - description (`description`) -- description for new image.

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's create_image method

  CLI Example:

      salt myminion libcloud_compute.create_image server1 my_image profile1
      salt myminion libcloud_compute.create_image server1 my_image profile1 description='test image'

salt.modules.libcloud_compute.create_key_pair(name, profile, **libcloud_kwargs)

  Create a single key pair by name

  Parameters:

    - name (`str`) -- Name of the key pair to create.

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's create_key_pair method

  CLI Example:

      salt myminion libcloud_compute.create_key_pair pair1 profile1

salt.modules.libcloud_compute.create_volume(size, name, profile, location_id=None, **libcloud_kwargs)

  Create a storage volume

  Parameters:

    - size (`int`) -- Size of volume in gigabytes (required)

    - name (`str`) -- Name of the volume to be created

    - location_id (`str`) -- Which data center to create a volume in. If empty, undefined behavior will be selected. (optional)

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_volumes method

  CLI Example:

      salt myminion libcloud_compute.create_volume 1000 vol1 profile1

salt.modules.libcloud_compute.create_volume_snapshot(volume_id, profile, name=None, **libcloud_kwargs)

  Create a storage volume snapshot

  Parameters:

    - volume_id (`str`) -- Volume ID from which to create the new snapshot.

    - profile (`str`) -- The profile key

    - name (`str`) -- Name of the snapshot to be created (optional)

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's create_volume_snapshot method

  CLI Example:

      salt myminion libcloud_compute.create_volume_snapshot vol1 profile1

salt.modules.libcloud_compute.delete_image(image_id, profile, **libcloud_kwargs)

  Delete an image of a node

  Parameters:

    - image_id (`str`) -- Image to delete

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's delete_image method

  CLI Example:

      salt myminion libcloud_compute.delete_image image1 profile1

salt.modules.libcloud_compute.delete_key_pair(name, profile, **libcloud_kwargs)

  Delete a key pair

  Parameters:

    - name (`str`) -- Key pair name.

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's import_key_pair_from_xxx method

  CLI Example:

      salt myminion libcloud_compute.delete_key_pair pair1 profile1

salt.modules.libcloud_compute.destroy_node(node_id, profile, **libcloud_kwargs)

  Destroy a node in the cloud

  Parameters:

    - node_id (`str`) -- Unique ID of the node to destroy

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's destroy_node method

  CLI Example:

      salt myminion libcloud_compute.destry_node as-2346 profile1

salt.modules.libcloud_compute.destroy_volume(volume_id, profile, **libcloud_kwargs)

  Destroy a volume.

  Parameters:

    - volume_id (`str`) -- Volume ID from which to destroy

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's destroy_volume method

  CLI Example:

      salt myminion libcloud_compute.destroy_volume vol1 profile1

salt.modules.libcloud_compute.destroy_volume_snapshot(volume_id, snapshot_id, profile, **libcloud_kwargs)

  Destroy a volume snapshot.

  Parameters:

    - volume_id (`str`) -- Volume ID from which the snapshot belongs

    - snapshot_id (`str`) -- Volume Snapshot ID from which to destroy

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's destroy_volume_snapshot method

  CLI Example:

      salt myminion libcloud_compute.destroy_volume_snapshot snap1 profile1

salt.modules.libcloud_compute.detach_volume(volume_id, profile, **libcloud_kwargs)

  Detaches a volume from a node.

  Parameters:

    - volume_id (`str`) -- Volume ID from which to detach

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's detach_volume method

  CLI Example:

      salt myminion libcloud_compute.detach_volume vol1 profile1

salt.modules.libcloud_compute.extra(method, profile, **libcloud_kwargs)

  Call an extended method on the driver

  Parameters:

    - method (`str`) -- Driver's method name

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's method

  CLI Example:

      salt myminion libcloud_compute.extra ex_get_permissions google container_name=my_container object_name=me.jpg --out=yaml

salt.modules.libcloud_compute.get_image(image_id, profile, **libcloud_kwargs)

  Get an image of a node

  Parameters:

    - image_id (`str`) -- Image to fetch

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's delete_image method

  CLI Example:

      salt myminion libcloud_compute.get_image image1 profile1

salt.modules.libcloud_compute.get_key_pair(name, profile, **libcloud_kwargs)

  Get a single key pair by name

  Parameters:

    - name (`str`) -- Name of the key pair to retrieve.

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's get_key_pair method

  CLI Example:

      salt myminion libcloud_compute.get_key_pair pair1 profile1

salt.modules.libcloud_compute.import_key_pair(name, key, profile, key_type=None, **libcloud_kwargs)

  Import a new public key from string or a file path

  Parameters:

    - name (`str`) -- Key pair name.

    - key (`str` or path `str`) -- Public key material, the string or a path to a file

    - profile (`str`) -- The profile key

    - key_type (`str`) -- The key pair type, either FILE or STRING. Will detect if not provided and assume that if the string is a path to an existing path it is a FILE, else STRING.

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's import_key_pair_from_xxx method

  CLI Example:

      salt myminion libcloud_compute.import_key_pair pair1 key_value_data123 profile1
      salt myminion libcloud_compute.import_key_pair pair1 /path/to/key profile1

salt.modules.libcloud_compute.list_images(profile, location_id=None, **libcloud_kwargs)

  Return a list of images for this cloud

  Parameters:

    - profile (`str`) -- The profile key

    - location_id (`str`) -- The location key, from list_locations

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_images method

  CLI Example:

      salt myminion libcloud_compute.list_images profile1

salt.modules.libcloud_compute.list_key_pairs(profile, **libcloud_kwargs)

  List all the available key pair objects.

  Parameters:

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_key_pairs method

  CLI Example:

      salt myminion libcloud_compute.list_key_pairs profile1

salt.modules.libcloud_compute.list_locations(profile, **libcloud_kwargs)

  Return a list of locations for this cloud

  Parameters:

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_locations method

  CLI Example:

      salt myminion libcloud_compute.list_locations profile1

salt.modules.libcloud_compute.list_nodes(profile, **libcloud_kwargs)

  Return a list of nodes

  Parameters:

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_nodes method

  CLI Example:

      salt myminion libcloud_compute.list_nodes profile1

salt.modules.libcloud_compute.list_sizes(profile, location_id=None, **libcloud_kwargs)

  Return a list of node sizes

  Parameters:

    - profile (`str`) -- The profile key

    - location_id (`str`) -- The location key, from list_locations

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_sizes method

  CLI Example:

      salt myminion libcloud_compute.list_sizes profile1
      salt myminion libcloud_compute.list_sizes profile1 us-east1

salt.modules.libcloud_compute.list_volume_snapshots(volume_id, profile, **libcloud_kwargs)

  Return a list of storage volumes snapshots for this cloud

  Parameters:

    - volume_id (`str`) -- The volume identifier

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_volume_snapshots method

  CLI Example:

      salt myminion libcloud_compute.list_volume_snapshots vol1 profile1

salt.modules.libcloud_compute.list_volumes(profile, **libcloud_kwargs)

  Return a list of storage volumes for this cloud

  Parameters:

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's list_volumes method

  CLI Example:

      salt myminion libcloud_compute.list_volumes profile1

salt.modules.libcloud_compute.reboot_node(node_id, profile, **libcloud_kwargs)

  Reboot a node in the cloud

  Parameters:

    - node_id (`str`) -- Unique ID of the node to reboot

    - profile (`str`) -- The profile key

    - libcloud_kwargs (`dict`) -- Extra arguments for the driver's reboot_node method

  CLI Example:

      salt myminion libcloud_compute.reboot_node as-2346 profile1