target¶
- exception gonto.target.MissingImage¶
- class gonto.target.SCRIPT_TYPE(*values)¶
Types of scripts for a Gonto target.
- AFTER_SCRIPT = 'after_script'¶
- BEFORE_SCRIPT = 'before_script'¶
- SCRIPT = 'script'¶
- class gonto.target.Target(target_name: str, config: dict)¶
Actions that can be run on a Gonto target.
- Parameters:
target_name – The requested target name.
config – The final Gonto configuration (containing all targets and main settings).
- Raises:
TargetDoesNotExist – if the requested target does not exist in the given config.
- download_missing_images(callback: Callable[[int, int, str, float], None] | None = None) None¶
Download missing disk images from the repository.
- Parameters:
callback –
A callable called to track the progress of the download (default:
None).Callback definition:
def callback(currentdl: int, dlcount: int, image_name: str, progress: float) -> None: pass
- has_script(script_type: SCRIPT_TYPE) bool¶
Checks if the target contains the given script type.
- Parameters:
script_type – The type of script.
- list_missing_images() Iterator[dict[str, Any]]¶
List required images that are not available in the cache.
- Returns:
the uncached images.
Image definition:
{ "path": "foobar/foobar_v1.2.3_win64.vhd", "name": "foobar", "version": "1.2.3", "platform": "win64", "format": "vhd", "mount_point": "", "env": {}, "reg": [], }
- list_required_images() Iterator[dict[str, Any]]¶
Lists target’s required disk image.
- Returns:
The required images.
Image definition:
{ "path": "foobar/foobar_v1.2.3_win64.vhd", "name": "foobar", "version": "1.2.3", "platform": "win64", "format": "vhd", "mount_point": "", "env": {}, "reg": [], }
- mount_images(permanent: bool = False) None¶
Mount disk images required for the target.
- Parameters:
permanent – Defines whether the mount is permanent or not (persisted after Gonto exit).
- Raises:
MissingImage – If an image is missing from the cache.
VolumeNotMounted – If the assignation of the drive letter failed.
VolumeNotReady – The disk image was not attached in time or contains no volumes.
- run_script(script_type: SCRIPT_TYPE) None¶
Run a target script with proper environment.
- Parameters:
script_type – The type of script.
- Raises:
subprocess.CalledProcessError – when a command of the script failed.
- umount_images() None¶
Umount all disk images of the target.
- exception gonto.target.TargetDoesNotExist¶
- exception gonto.target.VolumeNotMounted¶
- exception gonto.target.VolumeNotReady¶
- gonto.target.requirement_to_image_path(requirement: dict)¶
Returns the image path from a Gonto requirement definition.
- Parameters:
requirement – A Gonto requirement definition.
- Returns:
The image path.
>>> requirement_to_image_path({"name": "foobar", "version": "1.2.3"}) 'foobar/foobar_v1.2.3_win64.vhd' >>> requirement_to_image_path( ... {"name": "foobar", "version": "42", "platform": "multi", "format": "vhdx"} ... ) 'foobar/foobar_v42_multi.vhdx'