libioc.Config.Jail.File.Fstab module

Manage fstab files.

class libioc.Config.Jail.File.Fstab.Fstab(logger=None, host=None, file='/etc/fstab')[source]

Bases: collections.abc.MutableSequence

Fstab configuration file wrapper.

This object allows to read, programatically edit and write fstab files. Bound to an iocage resource, the location of the /etc/fstab file is relative to the resource’s root_dataset <resource>/root.

AUTO_COMMENT_IDENTIFIER = 'iocage-auto'
add_line(line, skip_existing=False, replace=False, auto_create_destination=False, auto_mount_jail=True)[source]

Directly append a FstabLine type.

Use save() to write changes to the fstab file.

Return type

Union[FstabLine, FstabCommentLine, FstabAutoPlaceholderLine]

index(line, start=None, end=None)[source]

Find the index position of a FstabLine in the Fstab instance.

Return type

int

insert(index, value)[source]

Insert a line at a given position.

Parameters
Return type

None

new_line(source, destination, type='nullfs', options='ro', freq=0, passno=0, comment=None, replace=False, auto_create_destination=False, auto_mount_jail=True)[source]

Append a new line to the fstab file.

Use save() to write changes to the fstab file.

Return type

Union[FstabLine, FstabCommentLine, FstabAutoPlaceholderLine]

parse_lines(input_text, ignore_auto_created=True, skip_destinations=[])[source]

Parse the content of a fstab file.

Parameters
  • input_text (str) – The text content of an existing fstab file

  • ignore_auto_created (bool) – Skips reading entries that were created by iocage

  • exclude_destinations – List of destination strings that is skipped

Return type

None

property path

Absolute fstab file path.

This is the file read from and written to.

Return type

str

read_file()[source]

Read the fstab file.

Return type

None

replace_path(pattern, replacement)[source]

Replace a path in all fstab entries (source or destination).

Return type

None

save()[source]

Update or create the fstab file.

Return type

None

update_and_save()[source]

Read file and then write changes.

Return type

None

class libioc.Config.Jail.File.Fstab.FstabAutoPlaceholderLine(data={})[source]

Bases: dict

A placeholder for auto-created fstab lines.

class libioc.Config.Jail.File.Fstab.FstabBasejailLine(data)[source]

Bases: libioc.Config.Jail.File.Fstab.FstabLine

Model a fstab line automatically created by a NullFS basejail.

class libioc.Config.Jail.File.Fstab.FstabCommentLine(data)[source]

Bases: dict

Model a fstab comment line (beginning with #).

class libioc.Config.Jail.File.Fstab.FstabFsSpec(sequence)[source]

Bases: libioc.Types.AbsolutePath

Enforces an AbsolutePath or special device name.

PATTERN = re.compile('^[A-Za-z][A-Za-z0-9]*$')
class libioc.Config.Jail.File.Fstab.FstabLine(data)[source]

Bases: dict

Model a line of an fstab file.

class libioc.Config.Jail.File.Fstab.FstabMaintenanceLine(data)[source]

Bases: libioc.Config.Jail.File.Fstab.FstabLine

Model a fstab line automatically created for jail launch scripts.

class libioc.Config.Jail.File.Fstab.JailFstab(jail, logger=None, host=None, file='fstab')[source]

Bases: libioc.Config.Jail.File.Fstab.Fstab

Fstab file abstraction of a Jails fstab file.

The jails fstab file is stored in its main dataset.

add_line(line, skip_existing=False, replace=False, auto_create_destination=False, auto_mount_jail=True)[source]

Directly append a FstabLine type.

Use save() to write changes to the fstab file.

Return type

Union[FstabLine, FstabCommentLine, FstabAutoPlaceholderLine]

mount(event_scope=None)[source]

Mount all fstab entries to the jail.

Return type

Generator[MountFstab, None, None]

parse_lines(input_text, ignore_auto_created=True, skip_destinations=[])[source]

Parse the content of a fstab file.

Parameters
  • input_text (str) – The text content of an existing fstab file

  • ignore_auto_created (bool) – Skips reading entries that were created by iocage

  • exclude_destinations – List of destination strings that is skipped

Return type

None

property path

Absolute fstab file path.

This is the file read from and written to.

When the path begins with a / it is assumed to be absolute, so that the jails dataset mountpoint is not used as path prefix. This is useful when moving around jail backups.

Return type

str

unmount(event_scope=None)[source]

Unmount all fstab entries from the jail.

Return type

Generator[MountFstab, None, None]

update_release(release=None)[source]

Set a new release and save the updated file.

Return type

None