libioc.Config.Jail.BaseConfig module

The common base of jail configurations.

class libioc.Config.Jail.BaseConfig.BaseConfig(logger=None)[source]

Bases: dict

Model a plain iocage jail configuration.

A jail configuration can be loaded from various formats that were used by different versions of libioc. Technically it is possible to store set properties in deprecated formats, but this might break when using newer features than the legacy version of iocage supports. It is recommended to use the reading capabilities to migrate to the JSON config format.

Supported Configuration Formats:

JSON: (current)

Since the Python 3 implementation iocage stored jail configs in a file called config.json within the jail’s root dataset

ZFS:

iocage-legacy written in Bash used to save jail configurations as ZFS properties on the jail’s root dataset. Due to poor performance and easier readability this format later was replaced with a file based config storage. Even though it is a deprecated format, libiocage is compatible to read a jail config from ZFS.

UCL:

Yet another deprecated configuration format, that libiocage also supports reading from. A legacy version of iocage used this format.

Special Properties:

Special properties are

property all_properties

Return a list of config object attributes.

Return type

List[str]

attach_special_property(name, special_property)[source]

Attach a special property to the configuration.

Return type

None

clone(data, skip_on_error=False)[source]

Apply data from a data dictionary to the JailConfig.

Existing jail configuration is not emptied using.

Parameters
  • data (dict) – Dictionary containing the configuration to apply

  • skip_on_error (bool) – Passed to __setitem__

Return type

None

property data

Return the data object.

Return type

Data

get(key, *args)[source]

Return the config value or its given default.

Return type

Any

get_raw(key)[source]

Return the raw data value.

Return type

Any

get_string(key)[source]

Get the stringified value of a configuration property.

Return type

str

is_known_property(key, explicit)[source]

Return True when the key is a known config property.

Return type

bool

static is_user_property(key)[source]

Return whether the given key belongs to a custom user property.

Return type

bool

items()[source]

Return the combined config properties.

Return type

Itemsview[str, Any]

keys()[source]

Return the available configuration keys.

Return type

Keysview[str]

read(data, skip_on_error=False)[source]

Read the input data.

Various versions of iocage had a different understanding of a jail identifier. This method removes all identifiers from the input data when a normalized id is already set.

Return type

None

set(key, value, skip_on_error=False, explicit=False)[source]

Set a JailConfig property.

Parameters
  • key (str) – The jail config property name

  • value (Any) – Value to set the property to

  • skip_on_error (bool) – This argument is passed through to __setitem__

Returns

True if the JailConfig was changed

Return type

bool

set_dict(data, skip_on_error=False, explicit=True)[source]

Set a dict of jail config properties.

Returns a list of updated properties.

Return type

Set[str]

stringify(value)[source]

Stringify user supplied values.

Return type

str

property unknown_config_parameters

Yield unknown config parameters already stored in the config.

Return type

Iterator[str]

update_special_property(name)[source]

Triggered when a special property was updated.

Return type

None

values()[source]

Return all config values.

Return type

Valuesview[Any]

class libioc.Config.Jail.BaseConfig.JailConfigList(data=[], delimiter=' ')[source]

Bases: list

Jail configuration property in form of a list.