libioc.Resource module¶
ioc Resource module.
-
class
libioc.Resource.
DefaultResource
(dataset=None, dataset_name=None, config_type='auto', config_file=None, logger=None, zfs=None)[source]¶ Bases:
libioc.Resource.Resource
The resource storing the default configuration.
-
DEFAULT_JSON_FILE
= 'defaults.json'¶
-
DEFAULT_UCL_FILE
= 'defaults'¶
-
DEFAULT_ZFS_DATASET_SUFFIX
= '/.defaults'¶
-
-
class
libioc.Resource.
Resource
(dataset=None, dataset_name=None, config_type='auto', config_file=None, logger=None, zfs=None)[source]¶ Bases:
object
Representation of an iocage resource.
An iocage resource is the representation of a jail, release or base release
File Structure:
<ZFSDataset>/root:
This dataset contains the root filesystem of a jail or release.
In case of a ZFS basejail resource it hosts a tree of child datasets that may be cloned into an existing target dataset.
<ZFSDataset>/config.json:
The resource configuration in JSON format
<ZFSDataset>/config:
The resource configuration in ucl format used by former versions of iocage
<ZFSDataset>.properties:
iocage legacy used to store resource configuration in ZFS properties on the resource dataset
-
CONFIG_TYPES
= ('json', 'ucl', 'zfs', 'auto')¶
-
DEFAULT_JSON_FILE
= 'config.json'¶
-
DEFAULT_UCL_FILE
= 'config'¶
-
DEFAULT_ZFS_DATASET_SUFFIX
= None¶
-
abspath
(relative_path)[source]¶ Return the absolute path of a path relative to the resource.
- Return type
str
-
property
config_file
¶ Return the relative path of the resource config file.
- Return type
Optional
[str
]
-
property
config_handler
¶ Return the config handler according to the detected config_type.
- Return type
-
property
config_json
¶ Return and memoize the resources JSON config handler.
- Return type
-
property
config_type
¶ Return the resources config type (JSON, UCL or ZFS).
- Return type
Optional
[str
]
-
property
config_ucl
¶ Return and memoize the resources UCL config handler.
- Return type
-
property
config_zfs
¶ Return and memoize the resources ZFS property config handler.
- Return type
-
property
dataset
¶ Return the resources dataset.
- Return type
ZFSDataset
-
property
dataset_name
¶ Return the name of the resources dataset.
- Return type
str
-
abstract
destroy
(force=False)[source]¶ Destroy the resource.
- Return type
Generator
[IocEvent
,None
,None
]
-
property
exists
¶ Return True if the resource exists on the filesystem.
- Return type
bool
-
get_dataset
(name)[source]¶ Get the ZFSDataset relative to the resource datasets name.
- Return type
ZFSDataset
-
get_or_create_dataset
(name)[source]¶ Get or create a child dataset.
- Returns
Existing or newly created ZFS Dataset
- Return type
libzfs.ZFSDataset
-
getstring
(key)[source]¶ Get any resource property as string or ‘-‘.
- Parameters
key (string) – Name of the jail property to return
- Return type
str
-
is_path_relative
(filepath)[source]¶ Return whether the path is relative to the resource.
- Return type
bool
-
property
pool
¶ Return the ZFSPool of the resources dataset.
- Return type
ZFSPool
-
property
pool_name
¶ Return the name of the ZFSPool of the resources dataset.
- Return type
str
-
read_config
(skip_invalid=False)[source]¶ Read the configuration from disk.
- Return type
Dict
[str
,Any
]
-