waft.configuration.config_file.config_writer module

class waft.configuration.config_file.config_writer.ConfigWriter(config_file_path: Path | str | None = None, auto_create: bool | None = None)

Bases: ConfigBase

Class that allows for writing data to the config file.

ALLOWED_FIELDS = {'auto_delete', 'cloud_provider', 'description', 'hostname', 'name', 'proxy', 'resource_group', 'username', 'vm_spec'}
add_group(group_name: str, system_names: list[str]) None

Adds a group to the configuration.

Parameters:
  • group_name (str) – Name of the group.

  • system_names (list[str]) – List of system names to include in the group.

Raises:
  • ValueError – If the system names list is empty.

  • RuntimeError – If the group already exists or any of the systems do not exist.

Returns:

None

add_proxy(proxy_name: str, hostname: str, username: str, force: bool = False) None

Adds a new proxy to the configuration.

Parameters:
  • proxy_name (str) – Name of the proxy.

  • hostname (str) – Hostname of the proxy.

  • username (str) – Username for accessing the proxy.

  • force (bool) – Whether to force replacement of an existing proxy.

Returns:

None

add_system(system_name: str, hostname: str, username: str, proxy: str | None = None) None

Adds a new system to the configuration.

Parameters:
  • system_name (str) – Name of the system.

  • hostname (str) – Hostname of the system.

  • username (str) – Username for accessing the system.

  • proxy (Optional[str]) – Name of the proxy to use. Defaults to None.

Raises:

RuntimeError – If the system already exists or the proxy does not exist.

Returns:

None

add_vm_system(system: UserConfiguredSystem) None

Adds a new VM system to the configuration.

Parameters:

system – User configured system specification

Raises:

RuntimeError – If system already exists or proxy doesn’t exist

apply_terraform_output(system: UserConfiguredSystem, terraform_outputs: Dict[str, Any]) None

Extract and apply Terraform deployment details to the config.

Parameters:
  • system – System to update

  • terraform_outputs – Terraform outputs dictionary

Returns:

None

edit_system(system: UserConfiguredSystem) None

Edits an existing system in the configuration by replacing it entirely.

Parameters:

system – The updated system object.

Raises:

RuntimeError – If the system does not exist.

Returns:

None

remove_group(group_name: str) None

Removes a group from the configuration.

Parameters:

group_name (str) – Name of the group to remove.

Returns:

None

remove_proxy(proxy_name: str, force: bool = False) None

Remove a proxy from the configuration.

Parameters:
  • proxy_name (str) – Name of the proxy to remove.

  • force (bool) – Whether to force removal even if systems are using it.

Raises:

RuntimeError – If the proxy does not exist or is in use and force is False.

Returns:

None

remove_system(system_name: str, force: bool = False) None

Removes a system from the configuration.

Parameters:
  • system_name (str) – Name of the system to remove.

  • force (bool) – If True, bypass validation that prevents removing VMs with hostnames.

Raises:

RuntimeError – If the system does not exist or is a VM that must be deleted first (unless force=True).

Returns:

None

write_config(config_data: ConfigInfo | None = None, config_file: str | None = None) None

Writes the configuration data to the file.

Parameters:
  • config_data (Optional[ConfigInfo]) – Configuration data to write. Defaults to current config data.

  • config_file (Optional[str]) – Path to the config file. Defaults to the current config file.

Returns:

None