Developing for Packages¶
The Packages plugin offers multiple backends to support different types of software repositories. New backends can be written to handle new types of software repositories.
Each new Packages backend must be contained in its own module in
Bcfg2.Server.Plugins.Packages
. Each module must implement two
classes: A
Bcfg2.Server.Plugins.Packages.Collection.Collection
subclass
called <module>Collection
, and a
Bcfg2.Server.Plugins.Packages.Source.Source
subclass called
<module>Source
. E.g., the
Bcfg2.Server.Plugins.Packages.Yum
backend has
Bcfg2.Server.Plugins.Packages.Yum.YumCollection
and
Bcfg2.Server.Plugins.Packages.Yum.YumSource
objects. These
interfaces are explained in detail below.
The Collection Object¶
Collection
objects represent the set of
Bcfg2.Server.Plugins.Packages.Source.Source
objects that
apply to a given client, and can be used to query all software
repositories for a client in aggregate. In some cases this can give
faster or more accurate results.
In most cases, Collection
methods have been designed to defer the
call to the Sources in the Collection
and aggregate the results as
appropriate. The simplest Collection
implemention is thus often a
simple subclass that adds no additional functionality.
Overriding Methods¶
As noted above, the Collection
object is written expressly so that
you can subclass it and override no methods or attributes, and it will
work by deferring all calls to the Source objects it contains. There
are thus three approaches to writing a Collection
subclass:
- Keep the superclass almost entirely intact and defer to the
Source
objects inside it. For an example of this kind ofCollection
object, seeBcfg2.Server.Plugins.Packages.Apt
. - Keep
Collection.complete()
intact, and override the methods it calls:Collection.is_package()
,Collection.is_virtual_package()
,Collection.get_deps()
,Collection.get_provides()
,Collection.get_vpkgs()
, andCollection.setup_data()
. There are no examples of this kind ofCollection
subclass yet. - Provide your own implementation of
Collection.complete()
, in which case you do not have to override the above methods. You may want to overrideCollection.packages_from_entry()
,Collection.packages_to_entry()
, andCollection.get_new_packages()
. For an example of this kind ofCollection
object, seeBcfg2.Server.Plugins.Packages.yum
.
In either case, you may want to override
Collection.get_groups()
, Collection.get_group()
,
Collection.get_essential()
, Collection.get_config()
,
Collection.filter_unknown()
, and
Collection.build_extra_structures()
.
Conversion Between Package Objects and XML Entries¶
Collection objects have to translate Bcfg2 entries,
lxml.etree._Element
objects, into objects suitable for use by
the backend for resolving dependencies. This is handled by two
functions:
Collection.packages_from_entry()
is called to translate an XML entry into a list of packages;Collection.packages_to_entry()
is called to translate a list of packages back into an XML entry.
Because of this translation layer, the return type of any functions
below that return packages (e.g., Collection.get_group()
) is
actually indeterminate; they must return an object suitable for
passing to Collection.packages_to_entry()
. Similarly, functions
that take a package as an argument (e.g.,
Collection.is_package()
) take the appropriate package object.
In the documentation below, the actual parameter return type (usually
.``string``) used in this base implementation is noted, as well as
this fact.
The Collection Module¶
-
class
Bcfg2.Server.Plugins.Packages.Collection.
Collection
(metadata, sources, cachepath, basepath, debug=False)[source]¶ Bases:
list
,Bcfg2.Logger.Debuggable
Collection
objects represent the set ofBcfg2.Server.Plugins.Packages.Source
objects that apply to a given client, and can be used to query all software repositories for a client in aggregate. In some cases this can give faster or more accurate results.Parameters: - metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata for this collection
- sources (list of
Bcfg2.Server.Plugins.Packages.Source.Source
objects) – A list of all sources known to the server that will be used to generate the list of sources that apply to this client - cachepath (string) – The filesystem path where cache and other temporary data will be stored
- basepath (string) – The filesystem path to the Packages plugin directory, where more permanent data can be stored
- debug (bool) – Enable debugging output
-
__package_groups__
= False¶ Whether or not this Packages backend supports package groups
-
build_extra_structures
(independent)[source]¶ Add additional entries to the
<Independent/>
section of the final configuration. This can be used to handle, e.g., GPG keys and other entries besides packages that need to be handled for a complete client configuration.Parameters: independent (lxml.etree._Element) – The XML tag to add extra entries to. This is modified in place.
-
cachefiles
¶ A list of the full path to all cachefiles used by this collection.
The base implementation simply aggregates
Bcfg2.Server.Plugins.Packages.Source.Source.cachefile
attributes.
-
cachekey
¶ A unique identifier for the set of sources contained in this
Collection
object. This is unique to a set of sources, not necessarily to the client, which lets clients with identical sources share cache data.
-
complete
(*args, **kwargs)[source]¶ Build a complete list of all packages and their dependencies.
Parameters: packagelist (set of strings, but see Conversion Between Package Objects and XML Entries) – Set of initial packages computed from the specification. Returns: tuple of sets - The first element contains a set of strings (but see Conversion Between Package Objects and XML Entries) describing the complete package list, and the second element is a set of symbols whose dependencies could not be resolved.
-
filter_unknown
(unknown)[source]¶ After
complete()
, filter out packages that appear in the list of unknown packages but should not be presented to the user. E.g., packages that you expect to be unknown.The base implementation filters out packages that are expected to be unknown by any source in this collection.
Parameters: unknown (set of strings, but see Conversion Between Package Objects and XML Entries) – A set of unknown packages. The set should be modified in place.
-
get_additional_data
()[source]¶ Get additional
Bcfg2.Server.Plugin.interfaces.Connector
data to be supplied toBcfg2.Server.Plugins.Packages.Packages.get_additional_data()
(and thence to client metadata objects).The base implementation simply aggregates
Bcfg2.Server.Plugins.Packages.Source.Source.url_map
attributes.Returns: list of additional Connector data
-
get_config
()[source]¶ Get the configuration for the package tool used by this source type. This should be a config appropriate for use on either the server (to resolve dependencies) or the client.
Subclasses must override this method in order to be able to generate configs. By default it logs an error and returns the empty string.
Returns: string
-
get_deps
(package, recs=None)[source]¶ Get a list of the dependencies of the given package.
The base implementation simply aggregates the results of
Bcfg2.Server.Plugins.Packages.Source.Source.get_deps()
.Parameters: package (string) – The name of the symbol, but see Conversion Between Package Objects and XML Entries Returns: list of strings, but see Conversion Between Package Objects and XML Entries
-
get_essential
()[source]¶ Get a list of packages that are essential to the repository.
The base implementation simply aggregates
Bcfg2.Server.Plugins.Packages.Source.Source.essentialpkgs
attributesReturns: list of strings, but see Conversion Between Package Objects and XML Entries
-
get_group
(*args, **kwargs)[source]¶ Get the list of packages of the given type in a package group.
The base implementation simply aggregates the results of
Bcfg2.Server.Plugins.Packages.Source.Source.get_group()
.Parameters: - group (string) – The name of the group to query
- ptype (string) – The type of packages to get, for backends that support multiple package types in package groups (e.g., “recommended,” “optional,” etc.)
Returns: list of strings - package names, but see Conversion Between Package Objects and XML Entries
-
get_groups
(*args, **kwargs)[source]¶ Given a list of package group names, return a dict of
<group name>: <list of packages>
. This method is provided since some backends may be able to query multiple groups at once faster than serially.The base implementation simply aggregates the results of
Bcfg2.Server.Plugins.Packages.Source.Source.get_group()
.Parameters: grouplist (list of strings - group names) – The list of groups to query Returns: dict of <group name>: <list of packages>
In this implementation the packages will be strings, but see Conversion Between Package Objects and XML Entries.
-
get_new_packages
(initial, complete)[source]¶ Compute the difference between the complete package list (as returned by
complete()
) and the initial package list computed from the specification. This is necessary because the format may be different between the two lists due topackages_to_entry()
andpackages_from_entry()
. See Conversion Between Package Objects and XML Entries for more details.Parameters: - initial (set of strings, but see Conversion Between Package Objects and XML Entries) – The initial package list
- complete (set of strings, but see Conversion Between Package Objects and XML Entries) – The final package list
Returns: set of strings, but see Conversion Between Package Objects and XML Entries - the set of packages that are in
complete
but not ininitial
-
get_provides
(package)[source]¶ Get a list of all symbols provided by the given package.
The base implementation simply aggregates the results of
Bcfg2.Server.Plugins.Packages.Source.Source.get_provides()
.Parameters: package (string) – The name of the package, but see Conversion Between Package Objects and XML Entries Returns: list of strings, but see Conversion Between Package Objects and XML Entries
-
get_relevant_groups
()[source]¶ Get all groups that might be relevant to determining which sources apply to this collection’s client.
The base implementation simply aggregates the results of
Bcfg2.Server.Plugins.Packages.Source.Source.get_relevant_groups()
Returns: list of strings - group names
-
get_vpkgs
()[source]¶ Get a list of all virtual packages provided by all sources.
The base implementation simply aggregates the results of
Bcfg2.Server.Plugins.Packages.Source.Source.get_vpkgs()
.Returns: list of strings, but see Conversion Between Package Objects and XML Entries
-
is_package
(package)[source]¶ Return True if a package is a package, False otherwise.
The base implementation returns True if any Source object’s
Bcfg2.Server.Plugins.Packages.Source.Source.is_package()
returns True.Parameters: package (string) – The name of the package, but see Conversion Between Package Objects and XML Entries Returns: bool
-
is_virtual_package
(package)[source]¶ Return True if a name is a virtual package (i.e., is a symbol provided by a real package), False otherwise.
The base implementation returns True if any Source object’s
Bcfg2.Server.Plugins.Packages.Source.Source.is_virtual_package()
returns True.Parameters: package (string) – The name of the symbol, but see Conversion Between Package Objects and XML Entries Returns: bool
-
packages_from_entry
(entry)[source]¶ Given a Package or BoundPackage entry, get a list of the package(s) described by it in a format appropriate for passing to
complete()
. By default, that’s just the name; only theBcfg2.Server.Plugins.Packages.Yum
backend supports versions or other extended data. See Conversion Between Package Objects and XML Entries for more details.Parameters: entry (lxml.etree._Element) – The XML entry describing the package or packages. Returns: list of strings, but see Conversion Between Package Objects and XML Entries
-
packages_to_entry
(pkglist, entry)[source]¶ Given a list of package objects as returned by
packages_from_entry()
orcomplete()
, return an XML tree describing the BoundPackage entries that should be included in the client configuration. See Conversion Between Package Objects and XML Entries for more details.Parameters: - pkglist (list of strings, but see Conversion Between Package Objects and XML Entries) – A list of packages as returned by
complete()
- entry (lxml.etree._Element) – The base XML entry to add all of the Package entries to. This should be modified in place.
- pkglist (list of strings, but see Conversion Between Package Objects and XML Entries) – A list of packages as returned by
-
setup_data
(force_update=False)[source]¶ Do any collection-level data setup tasks. This is called when sources are loaded or reloaded by
Bcfg2.Server.Plugins.Packages.Packages
.The base implementation is a no-op; the child
Bcfg2.Server.Plugins.Packages.Source.Source
objects will handle all data setup.Parameters: force_update (bool) – Ignore all local cache and setup data from its original upstream sources (i.e., the package repositories)
-
Bcfg2.Server.Plugins.Packages.Collection.
get_collection_class
(source_type)[source]¶ Given a source type, determine the class of Collection object that should be used to contain these sources. Note that
source_type
is not aBcfg2.Server.Plugins.Packages.Source.Source
subclass; it’s the name of a source type as given insources.xml
.Parameters: source_type (string) – The type of source, e.g., “yum” or “apt” Returns: type - the Collection subclass that should be used to instantiate an object to contain sources of the given type.
The Source Object¶
Source
objects represent a single <Source> tag in
sources.xml
. Note that a single Source tag can itself describe
multiple repositories (if it uses the “url” attribute instead of
“rawurl”), and so can the Source
object. This can be the source
(har har) of some confusion. See
Bcfg2.Server.Plugins.Packages.Collection.Collection.sourcelist()
for the proper way to get all repos from a Source
object.
Source objects are aggregated into
Bcfg2.Server.Plugins.Packages.Collection.Collection
objects, which are actually called by
Bcfg2.Server.Plugins.Packages.Packages
. This way a more
advanced subclass can query repositories in aggregate rather than
individually, which may give faster or more accurate results.
The base Source
object must be subclassed to handle each
repository type. How you subclass Source
will depend on how you
subclassed
Bcfg2.Server.Plugins.Packages.Collection.Collection
; see
Bcfg2.Server.Plugins.Packages.Collection
for more details on
different methods for doing that.
If you are using the stock (or a near-stock)
Bcfg2.Server.Plugins.Packages.Collection.Collection
object,
then you will need to implement the following methods and attributes
in your Source
subclass:
Additionally, you may want to consider overriding the following methods and attributes:
Source.is_virtual_package()
Source.get_group()
Source.unknown_filter
Source.load_state
Source.save_state
For an example of this kind of Source
object, see
Bcfg2.Server.Plugins.Packages.Apt
.
If you are overriding the Collection
object in more depth, then
you have more leeway in what you might want to override or implement
in your Source
subclass. For an example of this kind of
Source
object, see Bcfg2.Server.Plugins.Packages.Yum
.
-
Bcfg2.Server.Plugins.Packages.Source.
REPO_RE
= <_sre.SRE_Pattern object>¶ A regular expression used to determine the base name of a repo from its URL. This is used when generating repo configs and by
Source.get_repo_name()
. It handles Pulp and mrepo repositories specially, and otherwise grabs the last component of the URL (as delimited by slashes).
-
class
Bcfg2.Server.Plugins.Packages.Source.
Source
(basepath, xsource)[source]¶ Bases:
Bcfg2.Logger.Debuggable
Source
objects represent a single <Source> tag insources.xml
. Note that a single Source tag can itself describe multiple repositories (if it uses the “url” attribute instead of “rawurl”), and so can theSource
object.Note that a number of the attributes of this object may be more or less specific to one backend (e.g.,
essentialpkgs
,recommended
,gpgkeys
, but they are included in the superclass to make the parsing of sources from XML more consistent, and to make it trivial for other backends to support those features.Parameters: - basepath (string) – The base filesystem path under which cache data for this source should be stored
- xsource – The XML tag that describes this source
Raises: -
applies
(metadata)[source]¶ Return true if this source applies to the given client, i.e., the client is in all necessary groups.
Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata to check to see if this source applies Returns: bool
-
arch_groups_match
(metadata)[source]¶ Returns True if the client is in an arch group that matches the arch of this source.
Returns: bool
-
arches
= None¶ A list of the arches supported by this source
-
basepath
= None¶ The base filesystem path under which cache data for this source should be stored
-
blacklist
= None¶ A list of the the names of packages that are blacklisted from this source
-
cachefile
= None¶ The file (or directory) used for this source’s cache data
-
cachekey
¶ A unique key for this source that will be used to generate
cachefile
and other cache paths
-
client_options
= None¶ A dict of repository options that will be included in the configuration generated for the client (if that is supported by the backend)
-
components
= None¶ A list of the text of all ‘Component’ attributes of this source from XML
-
conditions
= None¶ A list of predicates that are used to determine if this source applies to a given
Bcfg2.Server.Plugins.Metadata.ClientMetadata
object.
-
debsrc
= None¶ Whether or not to include deb-src lines in the generated APT configuration
-
deps
= None¶ A dict of
<package name>
-><list of dependencies>
. This will not necessarily be populated, particularly by backends that reimplement large portions ofBcfg2.Server.Plugins.Packages.Collection.Collection
-
escape_url
(url)[source]¶ Given a URL to a repository metadata file, return the full path to a file suitable for storing that file locally. This is acheived by replacing all forward slashes in the URL with
@
.Parameters: url (string) – The URL to escape Returns: string
-
essential
= None¶ Whether or not to include essential packages from this source
-
essentialpkgs
= None¶ A set of package names that are deemed “essential” by this source
-
files
¶ A list of files stored in the local cache by this backend.
-
filter_unknown
(unknown)[source]¶ After
Bcfg2.Server.Plugins.Packages.Collection.Collection.complete()
, filter out packages that appear in the list of unknown packages but should not be presented to the user.unknown_filter
is called to assess whether or not a package is expected to be unknown.Parameters: unknown (set of strings) – A set of unknown packages. The set should be modified in place.
-
get_arches
(metadata)[source]¶ Get a list of architectures that the given client has and for which this source provides packages for. The return value will always include
global
.Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata to get matching architectures for Returns: list of strings
-
get_deps
(metadata, package, recommended=None)[source]¶ Get a list of the dependencies of the given package.
Parameters: package (string) – The name of the symbol Returns: list of strings
-
get_group
(metadata, group, ptype=None)[source]¶ Get the list of packages of the given type in a package group.
Parameters: - group (string) – The name of the group to query
- ptype (string) – The type of packages to get, for backends that support multiple package types in package groups (e.g., “recommended,” “optional,” etc.)
Returns: list of strings - package names
-
get_provides
(metadata, package)[source]¶ Get a list of all symbols provided by the given package.
Parameters: package (string) – The name of the package Returns: list of strings
-
get_relevant_groups
(metadata)[source]¶ Get all groups that might be relevant to determining which sources apply to this collection’s client.
Returns: list of strings - group names
-
get_repo_name
(url_map)[source]¶ Try to find a sensible name for a repository. Since
sources.xml
doesn’t provide for repository names, we have to try to guess at the names when generating config files or doing other operations that require repository names. This function tries several approaches:- First, if the source element containts a
name
attribute, use that as the name. - If the map contains a
component
key, use that as the name. - If not, then try to match the repository URL against
Bcfg2.Server.Plugins.Packages.Source.REPO_RE
. If that succeeds, use the first matched group; additionally, if the Source tag that describes this repo is contained in a<Group>
tag, prepend that to the name. - If
Bcfg2.Server.Plugins.Packages.Source.REPO_RE
does not match the repository, and the Source tag that describes this repo is contained in a<Group>
tag, use the name of the group. - Failing that, use the full URL to this repository, with the protocol and trailing slash stripped off if possible.
Once that is done, all characters disallowed in yum source names are replaced by dashes. See below for the exact regex. The yum rules are used here because they are so restrictive.
get_repo_name
is not guaranteed to return a unique name. If you require a unique name, then you will need to generate all repo names and make them unique through the approach of your choice, e.g., appending numbers to non-unique repository names. SeeBcfg2.Server.Plugins.Packages.Yum.Source.get_repo_name()
for an example.Parameters: url_map (dict) – A single url_map
dict, i.e., any single element ofurl_map
.Returns: string - the name of the repository. - First, if the source element containts a
-
get_vpkgs
(metadata)[source]¶ Get a list of all virtual packages provided by all sources.
Returns: list of strings
-
gpgkeys
= None¶ A list of URLs to GPG keys that apply to this source
-
groups
= None¶ Formerly, Packages only supported applying package sources to groups; that is, they could not be assigned by more complicated logic like per-client repositories and group or client negation. This attribute attempts to provide for some limited backwards compat with older code that relies on this.
-
is_package
(metadata, package)[source]¶ Return True if a package is a package, False otherwise.
Parameters: package (string) – The name of the package Returns: bool
-
is_virtual_package
(metadata, package)[source]¶ Return True if a name is a virtual package (i.e., is a symbol provided by a real package), False otherwise.
Parameters: package (string) – The name of the symbol, but see Conversion Between Package Objects and XML Entries Returns: bool
-
load_state
()[source]¶ Load saved state from
cachefile
. If caching and state is handled by the package library, then this function does not need to be implemented.Raises: OSError - If the saved data cannot be read Raises: cPickle.UnpicklingError - If the saved data is corrupt
-
pkgnames
= None¶ A set of all package names in this source. This will not necessarily be populated, particularly by backends that reimplement large portions of
Bcfg2.Server.Plugins.Packages.Collection.Collection
-
process_files
(dependencies, provides, recommends={})[source]¶ Given dicts of depends and provides generated by
read_files()
, this generatesdeps
andprovides
and callssave_state()
to save the cached data to disk.All arguments are dicts of dicts of lists. Keys are the arches of packages contained in this source; values are dicts whose keys are package names and values are lists of either dependencies for each package the symbols provided by each package.
Parameters: - dependencies (dict; see above.) – A dict of dependencies found in the metadata for this source.
- provides (dict; see above.) – A dict of symbols provided by packages in this repository.
- recommends (dict; see above.) – A dict of recommended dependencies found for this source.
-
provides
= None¶ A dict of
<package name>
-><list of provided symbols>
. This will not necessarily be populated, particularly by backends that reimplement large portions ofBcfg2.Server.Plugins.Packages.Collection.Collection
-
ptype
= None¶ The Package type handled by this Source class. The
type
attribute of Package entries will be set to the valueptype
when they are handled byBcfg2.Server.Plugins.Packages
.
-
rawurl
= None¶ The “rawurl” attribute from
xsource
, if applicable. A trailing slash is automatically appended to this if there wasn’t one already present.
-
read_files
()[source]¶ Read and parse locally downloaded metadata files and populates
Bcfg2.Server.Plugins.Packages.Source.Source.pkgnames
. Should callBcfg2.Server.Plugins.Packages.Source.Source.process_files()
as its final step.
-
recommended
= None¶ Whether or not to include recommended packages from this source
-
recommends
= None¶ A dict of
<package name>
-><list of recommended symbols>
. This will not necessarily be populated.
-
save_state
()[source]¶ Save state to
cachefile
. If caching and state is handled by the package library, then this function does not need to be implemented.
-
server_options
= None¶ A dict of repository options that will be included in the configuration generated on the server side (if such is applicable; most backends do not generate any sort of repository configuration on the Bcfg2 server)
-
setup_data
(*args, **kwargs)[source]¶ Perform all data fetching and setup tasks.
For most backends, this involves downloading all metadata from the repository, parsing it, and caching the parsed data locally. The order of operations is:
- Call
load_state()
to try to load data from the local cache. - If that fails, call
read_files()
to read and parse the locally downloaded metadata files. - If that fails, call
update()
to fetch the metadata, thenread_files()
to parse it.
Obviously with a backend that leverages repo access libraries to avoid downloading all metadata, many of the functions called by
setup_data
can be no-ops (or nearly so).Parameters: force_update (bool) – Ignore all locally cached and downloaded data and fetch the metadata anew from the upstream repository. - Call
-
unknown_filter
(package)[source]¶ A predicate that is used by
filter_unknown()
to filter packages from the results ofBcfg2.Server.Plugins.Packages.Collection.Collection.complete()
that should not be shown to the end user (i.e., that are not truly unknown, but are rather packaging system artifacts). By default, excludes any package whose name starts with “choice”Parameters: package (string) – The name of a package that was unknown to the backend Returns: bool
-
update
()[source]¶ Download metadata from the upstream repository and cache it locally.
Raises: ValueError - If any URL in urls
is malformedRaises: OSError - If there is an error writing the local cache Raises: HTTPError - If there is an error fetching the remote data
-
url
= None¶ The “url” attribute from
xsource
, if applicable. A trailing slash is automatically appended to this if there wasn’t one already present.
-
url_map
= None¶ A list of dicts, each of which describes the URL to one repository contained in this source. Each dict contains the following keys:
version
: The version of the repo (None
forrawurl
repos)component
: The component use to form this URL (None
forrawurl
repos)arch
: The architecture of this repobaseurl
: Either therawurl
attribute, or the format string built from theurl
attributeurl
: The actual URL to the repository
-
urls
¶ A list of URLs to the base metadata file for each repository described by this source.
-
whitelist
= None¶ A list of the the names of packages that are whitelisted in this source
-
xsource
= None¶ The XML tag that describes this source
-
exception
Bcfg2.Server.Plugins.Packages.Source.
SourceInitError
[source]¶ Bases:
exceptions.Exception
Raised when a
Source
object fails instantiation.
The Packages Module¶
Packages resolves Package entries on the Bcfg2 server in order to present a complete list of Package entries to the client in order to determine the completeness of the client configuration.
-
class
Bcfg2.Server.Plugins.Packages.
OnDemandDict
(**getters)[source]¶ Bases:
_abcoll.MutableMapping
This maps a set of keys to a set of value-getting functions; the values are populated on-the-fly by the functions as the values are needed (and not before). This is used by
Bcfg2.Server.Plugins.Packages.Packages.get_additional_data()
; see the docstring for that function for details on why.Unlike a dict, you should not specify values for for the righthand side of this mapping, but functions that get values. E.g.:
d = OnDemandDict(foo=load_foo, bar=lambda: "bar");
-
class
Bcfg2.Server.Plugins.Packages.
Packages
(core)[source]¶ Bases:
Bcfg2.Server.Plugin.base.Plugin
,Bcfg2.Server.Plugin.interfaces.StructureValidator
,Bcfg2.Server.Plugin.interfaces.Generator
,Bcfg2.Server.Plugin.interfaces.Connector
,Bcfg2.Server.Plugin.interfaces.ClientRunHooks
Packages resolves Package entries on the Bcfg2 server in order to present a complete list of Package entries to the client in order to determine the completeness of the client configuration. It does so by delegating control of package version information to a number of backends, which may parse repository metadata directly or defer to package manager libraries for truly dynamic resolution.
Parameters: core (Bcfg2.Server.Core) – The Bcfg2.Server.Core initializing the plugin Raises: OSError
if adding a file monitor failed;Bcfg2.Server.Plugin.exceptions.PluginInitError
on other errors-
Debuggable.
__rmi__
= ['toggle_debug', 'set_debug']¶ List of names of methods to be exposed as XML-RPC functions, if applicable to the child class
-
HandleEntry
(entry, metadata)[source]¶ Bind configuration entries.
HandleEntry
handles entries two different ways:- All
Package
entries have theirversion
andtype
attributes set according to the appropriateBcfg2.Server.Plugins.Packages.Collection.Collection
object for this client. Path
entries are delegated tocreate_config()
Parameters: - entry (lxml.etree._Element) – The entry to bind
- metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata
Returns: lxml.etree._Element - The fully bound entry
- All
-
HandlesEntry
(entry, metadata)[source]¶ Determine if the given entry can be handled. Packages handles two kinds of entries:
Package
entries are handled if the client has any sources at all.Path
entries are handled if they match the paths that are handled by a backend that can produce client configurations, e.g.,YUM_CONFIG_DEFAULT
,APT_CONFIG_DEFAULT
, or the overridden value of either of those from the configuration.
Parameters: - entry (lxml.etree._Element) – The entry to bind
- metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata
Returns: bool - Whether or not this plugin can handle the entry
Raises:
-
Refresh
(*args, **kwargs)[source]¶ Packages.Refresh() => True|False
Reload configuration specification and download sources
-
Reload
(*args, **kwargs)[source]¶ Packages.Refresh() => True|False
Reload configuration specification and sources
-
_build_packages
(*args, **kwargs)[source]¶ Perform dependency resolution and build the complete list of packages that need to be included in the specification by
validate_structures()
, based on the initial list of packages.Parameters: - metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata
- independent (lxml.etree._Element) – The XML tag to add package entries generated by dependency resolution to. This will be modified in place.
- structures (list of lxml.etree._Element objects) – A list of lxml.etree._Element objects describing the structures (i.e., bundles) for this client
- collection (Bcfg2.Server.Plugins.Packages.Collection.Collection) – The collection of sources for this client.
If none is given, one will be created with
get_collection()
-
cachepath
= None¶ Packages does a potentially tremendous amount of on-disk caching.
cachepath
holds the base directory to where data should be cached.
-
clients
= None¶ clients is a cache mapping of hostname ->
Bcfg2.Server.Plugins.Packages.Collection.Collection.cachekey
Unlikecollections
, this _is_ used to return aBcfg2.Server.Plugins.Packages.Collection.Collection
object when one is requested, so each entry is very short-lived – it’s purged at the end of each client run.
-
collections
= None¶ We cache
Bcfg2.Server.Plugins.Packages.Collection.Collection
objects incollections
so that callingRefresh()
orReload()
can tell the collection objects to clean up their cache, but we don’t actually use the cache to return aCollection
object when one is requested, because that prevents new machines from working, since aCollection
object gets created byget_additional_data()
, which is called for all clients at server startup and various other times. (It would also prevent machines that change groups from working properly; e.g., if you reinstall a machine with a new OS, then returning a cachedCollection
object would give the wrong sources to that client.) These are keyed by the collectionBcfg2.Server.Plugins.Packages.Collection.Collection.cachekey
, a unique key identifying the collection by its config, which could be shared among multiple clients.
-
conflicts
= ['Pkgmgr']¶ Packages is an alternative to
Bcfg2.Server.Plugins.Pkgmgr
and conflicts with it.
-
create_config
(entry, metadata)[source]¶ Create yum/apt config for the specified client.
Parameters: - entry (lxml.etree._Element) – The base entry to bind. This will be modified in place.
- metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client to create the config for.
-
end_client_run
(metadata)[source]¶ Hook to clear the cache for this client in
clients
, which must persist only the duration of a client run.Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata
-
end_statistics
(metadata)[source]¶ Hook to clear the cache for this client in
clients
once statistics are processed to ensure that a stray cachedBcfg2.Server.Plugins.Packages.Collection.Collection
object is not built during statistics and preserved until a subsequent client run.Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata
-
get_additional_data
(metadata)[source]¶ Return additional data for the given client. This will be an
Bcfg2.Server.Plugins.Packages.OnDemandDict
containing two keys:sources
, whose value is a list of data returned fromBcfg2.Server.Plugins.Packages.Collection.Collection.get_additional_data()
, namely, a list ofBcfg2.Server.Plugins.Packages.Source.Source.url_map
data; andget_config
, whose value is theBcfg2.Server.Plugins.Packages.Packages.get_config()
function, which can be used to get the Packages config for other systems.
This uses an OnDemandDict instead of just a normal dict because loading a source collection can be a fairly time-consuming process, particularly for the first time. As a result, when all metadata objects are built at once (such as after the server is restarted, or far more frequently if Metadata caching is disabled), this function would be a major bottleneck if we tried to build all collections at the same time. Instead, they’re merely built on-demand.
Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata Returns: dict of lists of url_map
data
-
get_collection
(*args, **kwargs)[source]¶ Get a
Bcfg2.Server.Plugins.Packages.Collection.Collection
object for this client.Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata to get a Collection for Returns: An instance of the appropriate subclass of Bcfg2.Server.Plugins.Packages.Collection.Collection
that contains all relevant sources that apply to the given client
-
get_config
(metadata)[source]¶ Get yum/apt config, as a string, for the specified client.
Parameters: metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client to create the config for.
-
keypath
= None¶ Where Packages should store downloaded GPG key files
-
set_debug
(debug)[source]¶ Explicitly enable or disable debugging.
Returns: bool - The new value of the debug flag
-
sources
= None¶ The
Bcfg2.Server.Plugins.Packages.PackagesSources.PackagesSources
object used to generateBcfg2.Server.Plugins.Packages.Source.Source
objects for this plugin.
-
validate_structures
(*args, **kwargs)[source]¶ Do the real work of Packages. This does two things:
- Given the full list of all packages that apply to this
client from the specification, calls
_build_packages()
to resolve dependencies, determine unknown packages (i.e., those that are not in any repository that applies to this client), and build a complete package list. - Calls
Bcfg2.Server.Plugins.Packages.Collection.Collection.build_extra_structures()
to add any other extra data required by the backend (e.g., GPG keys)
Parameters: - metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata
- metadata – The client metadata
- structures (list of lxml.etree._Element objects) – A list of lxml.etree._Element objects describing the structures (i.e., bundles) for this client. This can be modified in place.
Returns: None
- Given the full list of all packages that apply to this
client from the specification, calls
-
Packages Source Description¶
PackagesSources handles the
Packages sources.xml
file
-
class
Bcfg2.Server.Plugins.Packages.PackagesSources.
PackagesSources
(filename, cachepath, packages)[source]¶ Bases:
Bcfg2.Server.Plugin.helpers.StructFile
PackagesSources handles parsing of the
Bcfg2.Server.Plugins.Packages
sources.xml
file, and the creation of the appropriateBcfg2.Server.Plugins.Packages.Source.Source
object for eachSource
tag.Parameters: - filename (string) – The full path to
sources.xml
- cachepath (string) – The full path to the directory where
Bcfg2.Server.Plugins.Packages.Source.Source
data will be cached - packages (Bcfg2.Server.Plugins.Packages.Packages) – The Packages plugin object
sources.xml
is being parsed on behalf of (i.e., the calling object)
Raises: Bcfg2.Server.Plugin.exceptions.PluginInitError
- Ifsources.xml
cannot be read-
HandleEvent
(event=None)[source]¶ HandleEvent is called whenever the FAM registers an event.
When
loaded
becomes True,Bcfg2.Server.Plugins.Packages.Packages.Reload()
is called to reload all plugin data from the configured sources.Parameters: event (Bcfg2.Server.FileMonitor.Event) – The event object Returns: None
-
Index
(*args, **kwargs)[source]¶ Index() is called by
HandleEvent()
every time the data changes, and parses the data into usable data as required.Index
is responsible for callingsource_from_xml()
for eachSource
tag in each file.
-
cachepath
= None¶ The full path to the directory where
Bcfg2.Server.Plugins.Packages.Source.Source
data will be cached
-
loaded
¶ Whether or not all XML files (
sources.xml
and everything XIncluded in it) have been parsed. This flag is used to determine if the Packages plugin should be told to load its data.
-
parsed
= None¶ The set of all XML files that have been successfully parsed. This is used by
loaded
to determine if the sources have been fully parsed and theBcfg2.Server.Plugins.Packages.Packages
plugin should be told to reload its data.
-
pkg_obj
= None¶ The
Bcfg2.Server.Plugins.Packages.Packages
that instantiated thisPackagesSources
object
-
set_debug
(debug)[source]¶ Explicitly enable or disable debugging.
Returns: bool - The new value of the debug flag
-
source_from_xml
(*args, **kwargs)[source]¶ Create a
Bcfg2.Server.Plugins.Packages.Source.Source
subclass object from XML representation of a source insources.xml
.source_from_xml
determines the appropriate subclass ofSource
to instantiate according to thetype
attribute of theSource
tag.Parameters: xsource (lxml.etree._Element) – The XML tag representing the source Returns: Bcfg2.Server.Plugins.Packages.Source.Source
subclass, or None on error
- filename (string) – The full path to
Existing Packages Backends¶
Yum¶
Yum backend for Bcfg2.Server.Plugins.Packages
. This module
is the most complex backend because it has to handle Yum sources
without yum Python libraries, with yum Python libraries, and Pulp
sources. (See Package Groups for details on using the
yum Python libraries and Pulp Support for details on
Pulp sources.)
bcfg2-yum-helper¶
If using the yum Python libraries, YumCollection
makes shell
calls to an external command, bcfg2-yum-helper
, which performs the
actual yum API calls. This is done because the yum libs have horrific
memory leaks, and apparently the right way to get around that in
long-running processes it to have a short-lived helper. This is how
it’s done by yum itself in yum-updatesd
, which is a long-running
daemon that checks for and applies updates.
Package Objects¶
Bcfg2.Server.Plugins.Packages.Collection.Collection
objects
have the option to translate from some backend-specific representation
of packages to XML entries; see Conversion Between Package Objects and XML Entries for more
information on this. If you are using the Python yum libraries,
Bcfg2.Server.Plugins.Packages.Yum.YumCollection
opts to do
this, using the yum tuple representation of packages, which is:
(<name>, <arch>, <epoch>, <version>, <release>)
For shorthand this is occasionally abbrevated “naevr”. Any datum that
is not defined is None
. So a normal package entry that can be any
version would be passed to bcfg2-yum-helper as:
("somepackage", None, None, None, None)
A package returned from the helper might look more like this:
("somepackage", "x86_64", None, "1.2.3", "1.el6")
We translate between this representation and the XML representation of
packages with YumCollection.packages_from_entry()
and
YumCollection.packages_to_entry()
.
The Yum Backend¶
-
class
Bcfg2.Server.Plugins.Packages.Yum.
PulpCertificateData
(name, specific)[source]¶ Bases:
Bcfg2.Server.Plugin.helpers.SpecificData
Handle pulp consumer certificate data for
PulpCertificateSet
Parameters: - name (string) – The full path to the file
- specific (Bcfg2.Server.Plugin.helpers.Specificity) – A
Bcfg2.Server.Plugin.helpers.Specificity
object describing what clients this file applies to.
-
bind_entry
(entry, _)[source]¶ Given an abstract entry, add data to it and return it.
PulpCertificateSet
handles binding entry metadata.Parameters: entry (lxml.etree._Element) – The abstract entry to bind data to Returns: lxml.etree._Element - the bound entry
-
class
Bcfg2.Server.Plugins.Packages.Yum.
PulpCertificateSet
(path)[source]¶ Bases:
Bcfg2.Server.Plugin.helpers.EntrySet
Handle Pulp consumer certificates.
Parameters: path (string) – The path to the directory where Pulp consumer certificates will be stored -
HandleEvent
(event)[source]¶ Handle FAM events on certificate files.
Parameters: event (Bcfg2.Server.FileMonitor.Event) – The event to handle
-
certpath
= '/etc/pki/consumer/cert.pem'¶ The path to certificates on consumer machines
-
verify_file
(filename)[source]¶ Service the FAM events queued up by the key generation so the data structure entries will be available for binding.
NOTE: We wait for up to ten seconds. There is some potential for race condition, because if the file monitor doesn’t get notified about the new key files in time, those entries won’t be available for binding. In practice, this seems “good enough.”
Parameters: filename (string) – The filename to check for events on
-
write_data
(data, metadata)[source]¶ Write a new certificate to the filesystem.
Parameters: - data (string) – The new certificate data
- metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – Metadata for the client to write the certificate for
-
-
class
Bcfg2.Server.Plugins.Packages.Yum.
YumCollection
(metadata, sources, cachepath, basepath, debug=False)[source]¶ Bases:
Bcfg2.Server.Plugins.Packages.Collection.Collection
Handle collections of Yum sources. If we’re using the yum Python libraries, then this becomes a very full-featured
Bcfg2.Server.Plugins.Packages.Collection.Collection
object; if not, then it defers to theYumSource
object.-
_add_gpg_instances
(*args, **kwargs)[source]¶ Add GPG keys instances to a
Package
entry. This is called frombuild_extra_structures()
to add GPG keys to the specification.Parameters: - keyentry (lxml.etree._Element) – The
Package
entry to add key instances to. This will be modified in place. - localkey (string) – The full path to the key file on the Bcfg2 server
- remotekey (string) – The full path to the key file on the client. (If they key is not yet on the client, this will be the full path to where the key file will go eventually.)
- keydata (string) – The contents of the key file. If this is not
provided, read the data from
localkey
.
- keyentry (lxml.etree._Element) – The
-
_get_pulp_consumer
(*args, **kwargs)[source]¶ Get a Pulp consumer object for the client.
Parameters: consumerapi (pulp.client.api.consumer.ConsumerAPI) – A Pulp ConsumerAPI object. If none is passed, one will be instantiated. Returns: dict - the consumer. Returns None on failure (including if there is no existing Pulp consumer for this client.
-
build_extra_structures
(*args, **kwargs)[source]¶ Add additional entries to the
<Independent/>
section of the final configuration. This adds several kinds of entries:- For GPG keys, adds a
Package
entry that describes the version and release of all expectedgpg-pubkey
packages; andPath
entries to copy all of the GPG keys to the appropriate place on the client filesystem. Calls_add_gpg_instances()
. - For Pulp Sources, adds a
Path
entry for the consumer certificate; andAction
entries to update the consumer-side Pulp config if the consumer is newly registered. Creates a new Pulp consumer from the Bcfg2 server as necessary.
Parameters: independent (lxml.etree._Element) – The XML tag to add extra entries to. This is modified in place. - For GPG keys, adds a
-
cachefile
= None¶ Define a unique cache file for this collection to use for cached yum metadata
-
cachefiles
¶ A list of the full path to all cachefiles used by this collection.
-
call_helper
(*args, **kwargs)[source]¶ Make a call to bcfg2-yum-helper. The yum libs have horrific memory leaks, so apparently the right way to get around that in long-running processes it to have a short-lived helper. No, seriously – check out the yum-updatesd code. It’s pure madness.
Parameters: - command (string) – The bcfg2-yum-helper command to call.
- inputdata (Any JSON-encodable data structure.) – The input to pass to
bcfg2-yum-helper
on stdin. If this is None, no input will be given at all.
Returns: Varies depending on the return value of the
bcfg2-yum-helper
command.
-
cfgfile
= None¶ The path to the server-side config file used when resolving packages with the Python yum libraries
-
cmd
= None¶ A
Bcfg2.Utils.Executor
object to use to run external commands
-
complete
(*args, **kwargs)[source]¶ Build a complete list of all packages and their dependencies.
When using the Python yum libraries, this defers to the bcfg2-yum-helper; when using the builtin yum parser, this defers to
Bcfg2.Server.Plugins.Packages.Collection.Collection.complete()
.Parameters: packagelist (set of strings, but see Conversion Between Package Objects and XML Entries) – Set of initial packages computed from the specification. Returns: tuple of sets - The first element contains a set of strings (but see Conversion Between Package Objects and XML Entries) describing the complete package list, and the second element is a set of symbols whose dependencies could not be resolved.
-
get_arch
()[source]¶ If ‘arch’ for each source is the same, return that arch, otherwise None.
This helps bcfg2-yum-helper when the client arch is incompatible with the bcfg2 server’s arch.
In case multiple arches are found, punt back to the default behavior.
-
get_config
(raw=False)[source]¶ Get the yum configuration for this collection.
Parameters: raw (bool) – Return a ConfigParser.SafeConfigParser
object representing the configuration instead of a string. This is useful if you need to modify the config before writing it (aswrite_config()
does in order to produce a server-specific configuration).Returns: string or ConfigParser.SafeConfigParser
-
get_groups
(*args, **kwargs)[source]¶ If using the yum libraries, given a list of package group names, return a dict of
<group name>: <list of packages>
. This is much faster than implementingBcfg2.Server.Plugins.Packages.Collection.Collection.get_group()
, since we have to make a call to the bcfg2 Yum helper, and each time we do that we make another call to yum, which means we set up yum metadata from the cache (hopefully) each time. So resolving ten groups once is much faster than resolving one group ten times.If you are using the builtin yum parser, this raises a warning and returns an empty dict.
Parameters: grouplist (list of strings - group names) – The list of groups to query Returns: dict of <group name>: <list of packages>
In this implementation the packages may be strings or tuples. See Package Objects for more information.
-
get_new_packages
(initial, complete)[source]¶ Compute the difference between the complete package list (as returned by
complete()
) and the initial package list computed from the specification, allowing for package tuples. See Package Objects and Conversion Between Package Objects and XML Entries for more information on this process.Parameters: - initial (set of strings, but see Conversion Between Package Objects and XML Entries) – The initial package list
- complete (set of strings, but see Conversion Between Package Objects and XML Entries) – The final package list
Returns: set of tuples
-
has_pulp_sources
¶ True if there are any Pulp sources to handle, False otherwise
-
helper
¶ The full path to
bcfg2-yum-helper
. First, we check in the config file to see if it has been explicitly specified; next we see if it’s in $PATH; finally we default to /usr/sbin, the default location.
-
option_blacklist
= ['use_yum_libraries', 'helper']¶ Options that are included in the [packages:yum] section of the config but that should not be included in the temporary yum.conf we write out
-
packages_from_entry
(entry)[source]¶ When using the Python yum libraries, convert a Package entry to a list of package tuples. See Package Objects and Conversion Between Package Objects and XML Entries for more information on this process.
Parameters: entry (lxml.etree._Element) – The Package entry to convert Returns: list of tuples
-
packages_to_entry
(pkglist, entry)[source]¶ When using the Python yum libraries, convert a list of package tuples to a Package entry. See Package Objects and Conversion Between Package Objects and XML Entries for more information on this process.
If pkglist contains only one package, then its data is converted to a single
BoundPackage
entry that is added as a subelement ofentry
. If pkglist contains more than one package, then a parentBoundPackage
entry is created and childInstance
entries are added to it.Parameters: - pkglist (list of tuples) – A list of package tuples to convert to an XML Package entry
- entry (lxml.etree._Element) – The base XML entry to add Package entries to. This is modified in place.
Returns: None
-
pulp_cert_set
= None¶ PulpCertificateSet
object used to handle Pulp certs
-
setup_data
(force_update=False)[source]¶ Do any collection-level data setup tasks. This is called when sources are loaded or reloaded by
Bcfg2.Server.Plugins.Packages.Packages
.If the builtin yum parsers are in use, this defers to
Bcfg2.Server.Plugins.Packages.Collection.Collection.setup_data()
. If using the yum Python libraries, this cleans up cached yum metadata, regenerates the server-side yum config (in order to catch any new sources that have been added to this server), then regenerates the yum cache.Parameters: force_update (bool) – Ignore all local cache and setup data from its original upstream sources (i.e., the package repositories)
-
use_yum
¶ True if we should use the yum Python libraries, False otherwise
-
write_config
(*args, **kwargs)[source]¶ Write the server-side config file to
cfgfile
based on the data fromget_config()
-
-
class
Bcfg2.Server.Plugins.Packages.Yum.
YumSource
(basepath, xsource)[source]¶ Bases:
Bcfg2.Server.Plugins.Packages.Source.Source
Handle yum sources
Parameters: - basepath (string) – The base filesystem path under which cache data for this source should be stored
- xsource – The XML tag that describes this source
Raises: -
filter_unknown
(unknown)[source]¶ After
Bcfg2.Server.Plugins.Packages.Collection.Collection.complete()
, filter out packages that appear in the list of unknown packages but should not be presented to the user.unknown_filter
is called to assess whether or not a package is expected to be unknown.Parameters: unknown (set of strings) – A set of unknown packages. The set should be modified in place.
-
get_group
(metadata, group, ptype=None)[source]¶ Get the list of packages of the given type in a package group.
Parameters: - group (string) – The name of the group to query
- ptype (string) – The type of packages to get, for backends that support multiple package types in package groups (e.g., “recommended,” “optional,” etc.)
Returns: list of strings - package names
-
get_repo_name
(url_map)[source]¶ Try to find a sensible name for a repository. First use a repository’s Pulp ID, if it has one; if not, then defer to
Bcfg2.Server.Plugins.Packages.Source.Source.get_repo_name
Parameters: url_map (dict) – A single url_map
dict, i.e., any single element ofurl_map
.Returns: string - the name of the repository.
-
get_vpkgs
(metadata)[source]¶ Get a list of all virtual packages provided by all sources.
Returns: list of strings
-
is_package
(metadata, package)[source]¶ Return True if a package is a package, False otherwise.
Parameters: package (string) – The name of the package Returns: bool
-
load_state
()[source]¶ If using the builtin yum parser, load saved state from
cachefile
. If using the Python yum libraries, yum handles caching and state and this method is a no-op.
-
ptype
= 'yum'¶ YumSource sets the
type
on Package entries to “yum”
-
read_files
(*args, **kwargs)[source]¶ When using the builtin yum parser, read and parse locally downloaded metadata files. This diverges from the stock
Bcfg2.Server.Plugins.Packages.Source.Source.read_files()
quite a bit.
-
save_state
()[source]¶ If using the builtin yum parser, save state to
cachefile
. If using the Python yum libraries, yum handles caching and state and this method is a no-op.
-
setup_data
(force_update=False)[source]¶ setup_data
is only used by the builtin yum parser. Perform all data fetching and setup tasks.For most backends, this involves downloading all metadata from the repository, parsing it, and caching the parsed data locally. The order of operations is:
- Call
load_state()
to try to load data from the local cache. - If that fails, call
read_files()
to read and parse the locally downloaded metadata files. - If that fails, call
update()
to fetch the metadata, thenread_files()
to parse it.
Obviously with a backend that leverages repo access libraries to avoid downloading all metadata, many of the functions called by
setup_data
can be no-ops (or nearly so).Parameters: force_update (bool) – Ignore all locally cached and downloaded data and fetch the metadata anew from the upstream repository. - Call
-
unknown_filter
(package)[source]¶ By default,
Bcfg2.Server.Plugins.Packages.Source.Source
filters out unknown packages that start with “choice”, but that doesn’t mean anything to Yum or RPM. Instead, we filter out unknown packages that start with “rpmlib”, although this is likely legacy behavior; that would seem to indicate that a package required some RPM feature that isn’t provided, which is a bad thing. This should probably go away at some point.Parameters: package (string) – The name of a package that was unknown to the backend Returns: bool
-
urls
¶ A list of URLs to the base metadata file for each repository described by this source.
-
use_yum
¶ True if we should use the yum Python libraries, False otherwise
APT¶
APT backend for Bcfg2.Server.Plugins.Packages
-
class
Bcfg2.Server.Plugins.Packages.Apt.
AptCollection
(metadata, sources, cachepath, basepath, debug=False)[source]¶ Bases:
Bcfg2.Server.Plugins.Packages.Collection.Collection
Handle collections of APT sources. This is a no-op object that simply inherits from
Bcfg2.Server.Plugins.Packages.Collection.Collection
, overrides nothing, and defers all operations toPacSource
Parameters: - metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata for this collection
- sources (list of
Bcfg2.Server.Plugins.Packages.Source.Source
objects) – A list of all sources known to the server that will be used to generate the list of sources that apply to this client - cachepath (string) – The filesystem path where cache and other temporary data will be stored
- basepath (string) – The filesystem path to the Packages plugin directory, where more permanent data can be stored
- debug (bool) – Enable debugging output
-
class
Bcfg2.Server.Plugins.Packages.Apt.
AptSource
(basepath, xsource)[source]¶ Bases:
Bcfg2.Server.Plugins.Packages.Source.Source
Handle APT sources
Parameters: - basepath (string) – The base filesystem path under which cache data for this source should be stored
- xsource – The XML tag that describes this source
Raises: -
ptype
= 'deb'¶ AptSource sets the
type
on Package entries to “deb”
-
read_files
()[source]¶ Read and parse locally downloaded metadata files and populates
Bcfg2.Server.Plugins.Packages.Source.Source.pkgnames
. Should callBcfg2.Server.Plugins.Packages.Source.Source.process_files()
as its final step.
-
urls
¶ A list of URLs to the base metadata file for each repository described by this source.
Pacman¶
Pacman backend for Bcfg2.Server.Plugins.Packages
-
class
Bcfg2.Server.Plugins.Packages.Pac.
PacCollection
(metadata, sources, cachepath, basepath, debug=False)[source]¶ Bases:
Bcfg2.Server.Plugins.Packages.Collection.Collection
Handle collections of Pacman sources. This is a no-op object that simply inherits from
Bcfg2.Server.Plugins.Packages.Collection.Collection
, overrides nothing, and defers all operations toPacSource
Parameters: - metadata (Bcfg2.Server.Plugins.Metadata.ClientMetadata) – The client metadata for this collection
- sources (list of
Bcfg2.Server.Plugins.Packages.Source.Source
objects) – A list of all sources known to the server that will be used to generate the list of sources that apply to this client - cachepath (string) – The filesystem path where cache and other temporary data will be stored
- basepath (string) – The filesystem path to the Packages plugin directory, where more permanent data can be stored
- debug (bool) – Enable debugging output
-
class
Bcfg2.Server.Plugins.Packages.Pac.
PacSource
(basepath, xsource)[source]¶ Bases:
Bcfg2.Server.Plugins.Packages.Source.Source
Handle Pacman sources
Parameters: - basepath (string) – The base filesystem path under which cache data for this source should be stored
- xsource – The XML tag that describes this source
Raises: -
get_group
(metadata, group, ptype=None)[source]¶ Get the list of packages of the given type in a package group.
Parameters: - group (string) – The name of the group to query
- ptype (string) – The type of packages to get, for backends that support multiple package types in package groups (e.g., “recommended,” “optional,” etc.)
Returns: list of strings - package names
-
load_state
()[source]¶ Load saved state from
cachefile
. If caching and state is handled by the package library, then this function does not need to be implemented.Raises: OSError - If the saved data cannot be read Raises: cPickle.UnpicklingError - If the saved data is corrupt
-
ptype
= 'pacman'¶ PacSource sets the
type
on Package entries to “pacman”
-
read_files
()[source]¶ Read and parse locally downloaded metadata files and populates
Bcfg2.Server.Plugins.Packages.Source.Source.pkgnames
. Should callBcfg2.Server.Plugins.Packages.Source.Source.process_files()
as its final step.
-
save_state
()[source]¶ Save state to
cachefile
. If caching and state is handled by the package library, then this function does not need to be implemented.
-
urls
¶ A list of URLs to the base metadata file for each repository described by this source.