salt.modules.swift

Module for handling OpenStack Swift calls Author: Anthony Stanton <anthony.stanton@gmail.com>

Inspired by the S3 and Nova modules

depends
  • swiftclient Python module

configuration

This module is not usable until the user, tenant, auth URL, and password or auth_key are specified either in a pillar or in the minion's config file. For example:

keystone.user: admin
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
keystone.password: verybadpass
# or
keystone.auth_key: 203802934809284k2j34lkj2l3kj43k

If configuration for multiple OpenStack accounts is required, they can be set up as different configuration profiles: For example:

openstack1:
  keystone.user: admin
  keystone.tenant: admin
  keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
  keystone.password: verybadpass
  # or
  keystone.auth_key: 203802934809284k2j34lkj2l3kj43k

openstack2:
  keystone.user: admin
  keystone.tenant: admin
  keystone.auth_url: 'http://127.0.0.2:5000/v2.0/'
  keystone.password: verybadpass
  # or
  keystone.auth_key: 303802934809284k2j34lkj2l3kj43k

With this configuration in place, any of the swift functions can make use of a configuration profile by declaring it explicitly. For example:

salt '*' swift.get mycontainer myfile /tmp/file profile=openstack1

NOTE: For Rackspace cloud files setting keystone.auth_version = 1 is recommended.

salt.modules.swift.delete(cont, path=None, profile=None)

Delete a container, or delete an object from a container.

CLI Example to delete a container:

salt myminion swift.delete mycontainer

CLI Example to delete an object from a container:

salt myminion swift.delete mycontainer remoteobject
salt.modules.swift.get(cont=None, path=None, local_file=None, return_bin=False, profile=None)

List the contents of a container, or return an object from a container. Set return_bin to True in order to retrieve an object wholesale. Otherwise, Salt will attempt to parse an XML response.

CLI Example to list containers:

salt myminion swift.get

CLI Example to list the contents of a container:

salt myminion swift.get mycontainer

CLI Example to return the binary contents of an object:

salt myminion swift.get mycontainer myfile.png return_bin=True

CLI Example to save the binary contents of an object to a local file:

salt myminion swift.get mycontainer myfile.png local_file=/tmp/myfile.png
salt.modules.swift.head()
salt.modules.swift.put(cont, path=None, local_file=None, profile=None)

Create a new container, or upload an object to a container.

CLI Example to create a container:

salt myminion swift.put mycontainer

CLI Example to upload an object to a container:

salt myminion swift.put mycontainer remotepath local_file=/path/to/file