Boats Core
chaos.lib.boats.base
Base definitions and abstrac) -> list[dict[str, str | intoat resource provisioner plugins.
Boat
Bases: ABC
Abstract base class representing a generic boat.
Notes
A boat represents a dynamic provider for the fleet management system. This means that each boat has to implement methods to manage its lifecycle which include: connecting to an external inventory provider (e.g., ec2) getting the current state of the fleet creating new instances returning instances to the pool to list of fleets.
A boat is configured in a Ch-obolo file like so:
fleet:
parallelism: x<=5
boats:
- provider: {name of this boat}
config:
{config parameters specific to this boat}
hosts:
- host1:
ssh_user: user1
ssh_key: /path/to/key1.pem
The 'provider' name is used to find the corresponding Boat class, and the 'config' block is passed to its constructor.
name
abstractmethod
property
The name of the boat provider, used to match against the Ch-obolo configuration.
__init__(config)
Initializes the Boat with its specific configuration block from the Ch-obolo file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DictConfig
|
A DictConfig object containing the configuration for this boat. |
required |
check_connection()
abstractmethod
Checks if the connection to the external provider is active.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the connection is successfully verified. |
get_fleet(old_state)
Orchestrates the process of fetching and merging dynamic fleet configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_state
|
DictConfig
|
The existing OmegaConf configuration state. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DictConfig |
DictConfig
|
A new state with the dynamic hosts merged in. |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
If the boat fails to connect to its provider. |
ValueError
|
If mapping properties returned fall out of bounds representation rules. |
get_fleet_config()
abstractmethod
Handles the retrieval of the fleet configuration from the external provider.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
A dictionary representing the fleet configuration parameters. |
handle_boat_logic(fleet_config)
abstractmethod
Handles any boat-specific logic for managing the fleet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fleet_config
|
dict
|
The current extracted parameters detailing external fleet state representation. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
dict | list: Processed structured mapped objects (like hosts arrays) needed to inject back to original state maps. |