linux.base_objects

This Model Component provides some basic functionality common to all Linux hosts, such as setting the hostname and configuring IP addresses.

Model Component Dependencies:

Available Objects

class linux.base_objects.LinuxHost(*args, **kwargs)[source]

Bases: object

A class with functionality common to all Linux Hosts.

__init__(*args, **kwargs)
add_root_profiles()[source]

Adds default ssh keys, .bashrc, .vimrc, etc. for the root user.

change_password(start_time, username, password)[source]

Wrapper to change passwords for Linux VMs.

Parameters:
  • start_time (int) – The schedule time to configure the VM’s password.

  • username (str) – The username whose password should change.

  • password (str) – The new password.

cleanup(start_time=1)[source]

Clean up the FIREWHEEL artifacts from the VM (e.g. the /var/launch folder).

Parameters:

start_time (int) – The start time to remove the artifacts. Default is 1.

configure_ips(start_time=-200)[source]

Configure the IP addresses of the VM

Parameters:

start_time (int) – The start time to configure the VM’s hostname (default=-200)

Returns:

True if successful, False otherwise.

Return type:

bool

increase_ulimit(fd_limit=102400)[source]

This helps users adjust common ulimit parameters that typically impact experiments.

Depending on how a process was created, the limit which impacts that process differs therefore, it is sometimes difficult to discern how to properly increase limits. Users whom are logged in via the PAM module might see a limit set by limits.conf whereas system services have a different limit altogether. This method is a best effort to increase the limits in various locations. Currently, we only increase the number of file descriptors open, but this method can be extended in the future for other ulimit parameters.

Parameters:

fd_limit (int) – The maximum number of open file descriptors. Defaults to 102400.

set_hostname(start_time=-250)[source]

Wrapper to run the vm_resource that sets the hostname of the VM

Parameters:

start_time (int, optional) – The start time to configure the VM’s hostname (default=-250)

unpack_tar(time, archive, options='-xzf', directory=None, vm_resource=False)[source]

Unpack the tar archive.

This unpacks the tar archive, optionally into a specified directory. By default, the archive will be unpacked using the '-xzf' set of options, reading from the file given as the archive argument. Other option combinations can be passed directly to the tar executable via the options parameter, or indirectly via the other method parameters.

Parameters:
  • time (int) – The schedule time (positive or negative) at which the tarball will be unpacked.

  • archive (str, pathlib.Path) – The location of the archive file to be unpacked on the VM (or, if vm_resource is True, the name of the VM resource). Unless vm_resource is True, it is safest to specify the absolute path of the archive on the VM.

  • options (str) – The set of options to be passed to the tar executable. This string must begin with '-x' and end with 'f' (or '-f') since this method only performs extractions of named archives.

  • directory (str or pathlib.Path, optional) – A directory where the archiving utility will move before unpacking the archive. Specifying a directory is recommended when running with vm_resource set to True.

  • vm_resource (bool, optional) – A flag indicating whether the archive is a VM resource and needs to be loaded onto the VM before it is unpacked. Defaults to False.

Raises:

ValueError – If the provided options are unsupported.

class linux.base_objects.LinuxNetplanHost(*args, **kwargs)[source]

Bases: object

A class that implements functionality for Linux machines that use Netplan

__init__(*args, **kwargs)
_conflict_handlers = [<function configure_ip_conflict_handler>]
configure_ips(start_time=-200)[source]

Configure the IP addresses of the VM using netplan

Parameters:

start_time (int) – The start time to configure the VM’s hostname (default=-200)

Returns:

True if successful, False otherwise.

Return type:

bool

linux.base_objects.configure_ip_conflict_handler(entry_name, _decorator_value, _current_instance_value)[source]

The conflict handler for functions overwritten in LinuxNetplanHost that are also implemented in LinuxHost, i.e. the configure_ips function.

Parameters:
  • entry_name (str) – A string describing the attribute that has a conflict

  • _decorator_value (any) – The value of the attribute from the class that it is trying to be decorated by

  • _current_instance_value (any) – The current value of the conflicting attribute

Returns:

A function to be used as the configure_ips function for Netplan-enabled hosts

Return type:

function

Raises:

IncorrectConflictHandlerError – If the conflicting function is not "configure_ips".