waft.configuration.config_file.config_writer module¶
- class waft.configuration.config_file.config_writer.ConfigWriter(config_file_path: str | Path | None = None)¶
Bases:
ConfigReaderClass 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, platform: 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.
platform (Optional[str]) – Platform type (‘linux’, ‘windows’, ‘macos’). If None, will be auto-detected.
- 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
- 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
- lock()¶
Lock, load, and yield, before writing updated configuration data to the file.
- 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
- save_system(system: UserConfiguredSystem) None¶
Save system deployment details to the configuration file.
- Parameters:
system – System to update
- Returns:
None
- validate_file_path() bool¶
Validate that the configuration file exists.
- Returns:
True if the configuration file exists, False otherwise.
- Return type:
bool