charmhelpers.fetch package¶
charmhelpers.fetch.archiveurl module¶
-
class
charmhelpers.fetch.archiveurl.ArchiveUrlFetchHandler¶ Bases:
charmhelpers.fetch.BaseFetchHandlerHandler to download archive files from arbitrary URLs.
Can fetch from http, https, ftp, and file URLs.
Can install either tarballs (.tar, .tgz, .tbz2, etc) or zip files.
Installs the contents of the archive in $CHARM_DIR/fetched/.
-
can_handle(source)¶
-
download(source, dest)¶ Download an archive file.
Parameters: - source (str) – URL pointing to an archive file.
- dest (str) – Local path location to download archive file to.
-
download_and_validate(url, hashsum, validate='sha1')¶
-
install(source, dest=None, checksum=None, hash_type='sha1')¶ Download and install an archive file, with optional checksum validation.
The checksum can also be given on the source URL’s fragment. For example:
handler.install('http://example.com/file.tgz#sha1=deadbeef')
Parameters: - source (str) – URL pointing to an archive file.
- dest (str) – Local destination path to install to. If not given, installs to $CHARM_DIR/archives/archive_file_name.
- checksum (str) – If given, validate the archive file after download.
- hash_type (str) – Algorithm used to generate checksum.
Can be any hash alrgorithm supported by
hashlib, such as md5, sha1, sha256, sha512, etc.
-
-
charmhelpers.fetch.archiveurl.splitpasswd(user)¶ urllib.splitpasswd(), but six’s support of this is missing
-
charmhelpers.fetch.archiveurl.splituser(host)¶ urllib.splituser(), but six’s support of this seems broken
charmhelpers.fetch.bzrurl module¶
-
class
charmhelpers.fetch.bzrurl.BzrUrlFetchHandler¶ Bases:
charmhelpers.fetch.BaseFetchHandlerHandler for bazaar branches via generic and lp URLs.
-
branch(source, dest, revno=None)¶
-
can_handle(source)¶
-
install(source, dest=None, revno=None)¶
-
-
exception
charmhelpers.fetch.AptLockError¶ Bases:
exceptions.Exception
-
class
charmhelpers.fetch.BaseFetchHandler¶ Bases:
objectBase class for FetchHandler implementations in fetch plugins
-
base_url(url)¶ Return url without querystring or fragment
-
can_handle(source)¶ Returns True if the source can be handled. Otherwise returns a string explaining why it cannot
-
install(source)¶ Try to download and unpack the source. Return the path to the unpacked files or raise UnhandledSource.
-
parse_url(url)¶
-
-
exception
charmhelpers.fetch.SourceConfigError¶ Bases:
exceptions.Exception
-
exception
charmhelpers.fetch.UnhandledSource¶ Bases:
exceptions.Exception
-
charmhelpers.fetch.configure_sources(update=False, sources_var='install_sources', keys_var='install_keys')¶ Configure multiple sources from charm configuration.
The lists are encoded as yaml fragments in the configuration. The fragment needs to be included as a string. Sources and their corresponding keys are of the types supported by add_source().
- Example config:
- install_sources: |
- “ppa:foo”
- “http://example.com/repo precise main”
- install_keys: |
- null
- “a1b2c3d4”
Note that ‘null’ (a.k.a. None) should not be quoted.
-
charmhelpers.fetch.install_from_config(config_var_name)¶ Install a file from config.
-
charmhelpers.fetch.install_remote(source, *args, **kwargs)¶ Install a file tree from a remote source.
- The specified source should be a url of the form:
- scheme://[host]/path[#[option=value][&...]]
Schemes supported are based on this modules submodules. Options supported are submodule-specific. Additional arguments are passed through to the submodule.
For example:
dest = install_remote('http://example.com/archive.tgz', checksum='deadbeef', hash_type='sha1')
This will download archive.tgz, validate it using SHA1 and, if the file is ok, extract it and return the directory in which it was extracted. If the checksum fails, it will raise
charmhelpers.core.host.ChecksumError.
-
charmhelpers.fetch.plugins(fetch_handlers=None)¶