# salt.modules.libcloud_storage

## Apache Libcloud Storage Management

Connection module for Apache Libcloud Storage (object/blob) management for a full list of supported clouds, see http://libcloud.readthedocs.io/en/latest/storage/supported_providers.html

Clouds include Amazon S3, Google Storage, Aliyun, Azure Blobs, Ceph, OpenStack swift

Added in version 2018.3.0.

configuration:

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

      libcloud_storage:
          profile_test1:
            driver: google_storage
            key: GOOG0123456789ABCXYZ
            secret: mysecret
          profile_test2:
            driver: s3
            key: 12345
            secret: mysecret

depends:

  apache-libcloud

salt.modules.libcloud_storage.create_container(container_name, profile, **libcloud_kwargs)

  Create a container in the cloud

  Parameters:

    - container_name (`str`) -- Container name

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

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

  CLI Example:

      salt myminion libcloud_storage.create_container MyFolder profile1

salt.modules.libcloud_storage.delete_container(container_name, profile, **libcloud_kwargs)

  Delete an object container in the cloud

  Parameters:

    - container_name (`str`) -- Container name

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

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

  Returns:

    True if an object container has been successfully deleted, False otherwise.

  Return type:

    `bool`

  CLI Example:

      salt myminion libcloud_storage.delete_container MyFolder profile1

salt.modules.libcloud_storage.delete_object(container_name, object_name, profile, **libcloud_kwargs)

  Delete an object in the cloud

  Parameters:

    - container_name (`str`) -- Container name

    - object_name (`str`) -- Object name

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

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

  Returns:

    True if an object has been successfully deleted, False otherwise.

  Return type:

    `bool`

  CLI Example:

      salt myminion libcloud_storage.delete_object MyFolder me.jpg profile1

salt.modules.libcloud_storage.download_object(container_name, object_name, destination_path, profile, overwrite_existing=False, delete_on_failure=True, **libcloud_kwargs)

  Download an object to the specified destination path.

  Parameters:

    - container_name (`str`) -- Container name

    - object_name (`str`) -- Object name

    - destination_path (`str`) -- Full path to a file or a directory where the incoming file will be saved.

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

    - overwrite_existing (`bool`) -- True to overwrite an existing file, defaults to False.

    - delete_on_failure (`bool`) -- True to delete a partially downloaded file if the download was not successful (hash mismatch / file size).

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

  Returns:

    True if an object has been successfully downloaded, False otherwise.

  Return type:

    `bool`

  CLI Example:

      salt myminion libcloud_storage.download_object MyFolder me.jpg /tmp/me.jpg profile1

salt.modules.libcloud_storage.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 delete_container method

  CLI Example:

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

salt.modules.libcloud_storage.get_container(container_name, profile, **libcloud_kwargs)

  List container details for the given container_name on the given profile

  Parameters:

    - container_name (`str`) -- Container name

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

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

  CLI Example:

      salt myminion libcloud_storage.get_container MyFolder profile1

salt.modules.libcloud_storage.get_container_object(container_name, object_name, profile, **libcloud_kwargs)

  Get the details for a container object (file or object in the cloud)

  Parameters:

    - container_name (`str`) -- Container name

    - object_name (`str`) -- Object name

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

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

  CLI Example:

      salt myminion libcloud_storage.get_container_object MyFolder MyFile.xyz profile1

salt.modules.libcloud_storage.list_container_objects(container_name, profile, **libcloud_kwargs)

  List container objects (e.g. files) for the given container_id on the given profile

  Parameters:

    - container_name (`str`) -- Container name

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

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

  CLI Example:

      salt myminion libcloud_storage.list_container_objects MyFolder profile1

salt.modules.libcloud_storage.list_containers(profile, **libcloud_kwargs)

  Return a list of containers.

  Parameters:

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

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

  CLI Example:

      salt myminion libcloud_storage.list_containers profile1

salt.modules.libcloud_storage.upload_object(file_path, container_name, object_name, profile, extra=None, verify_hash=True, headers=None, **libcloud_kwargs)

  Upload an object currently located on a disk.

  Parameters:

    - file_path (`str`) -- Path to the object on disk.

    - container_name (`str`) -- Destination container.

    - object_name (`str`) -- Object name.

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

    - verify_hash (`bool`) -- Verify hash

    - extra (`dict`) -- Extra attributes (driver specific). (optional)

    - headers (`dict`) -- (optional) Additional request headers, such as CORS headers. For example: headers = {'Access-Control-Allow-Origin': 'http://mozilla.com'}

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

  Returns:

    The object name in the cloud

  Return type:

    `str`

  CLI Example:

      salt myminion libcloud_storage.upload_object /file/to/me.jpg MyFolder me.jpg profile1