minitrino.core.cluster.resource module#
Minitrino resource management.
This module provides classes and functions to manage Docker resources (containers, volumes, images, networks). All Docker objects are associated with a cluster name except for images, which are global.
- class minitrino.core.cluster.resource.ClusterResourceManager(ctx: MinitrinoContext)[source][source]#
Bases:
objectExpose cluster resources operations.
- Parameters:
ctx (MinitrinoContext) – An instantiated MinitrinoContext object with user input and context.
- resources(addl_labels: list[str] | None = None)[source][source]#
Collects Docker objects (containers, volumes, images, networks) for the current cluster or all clusters if the context’s cluster name is “all”.
- unfiltered_resources()[source][source]#
Collects all Docker objects associated with Minitrino. Unlike the resources() method, this method does not group resources by cluster or take additional labels to filter by.
- compose_project_name(cluster_name: str = '')[source][source]#
Computes the Docker Compose project name for a cluster.
- fq_container_name(container_name: str)[source][source]#
Constructs a fully qualified Docker container name by appending the active cluster name to a base container name.
- container(fq_container_name: str)[source][source]#
Retrieves a Docker container object by fully qualified name.
- resources(addl_labels: list[str] | None = None) MinitrinoResourcesView[source][source]#
Fetch Docker objects for the current context.
- Parameters:
addl_labels (list[str], optional) – A list of additional labels to filter resources by. All Docker objects must match all labels in the list to be included in the result. If not provided, resource retrieval is limited only to the root label ROOT_LABEL (org.minitrino.root=true).
- Returns:
An object that exposes grouped and typed access to resources by cluster and type. Images are grouped under a separate global key.
- Return type:
Notes
If the context’s cluster name is “all”, resources for all clusters are returned.
- unfiltered_resources() dict[str, list[MinitrinoContainer | MinitrinoVolume | MinitrinoNetwork | MinitrinoImage]][source][source]#
Collect all Docker objects associated with Minitrino.
- Returns:
Dictionary containing the following keys and corresponding Docker objects.
- Return type:
dict[str, list[MinitrinoDockerObject]]
Examples
>>> { "containers": [Container("foo"), ...], "volumes": [Volume("bar"), ...], "images": [Image("baz"), ...], "networks": [Network("qux"), ...], }
Notes
Unlike the resources() method, this method does not group resources by cluster or take additional labels to filter by. Fetch containers, volumes, images, and networks that are tagged with the global label ROOT_LABEL (org.minitrino.root=true).
- cluster_containers() list[MinitrinoContainer][source][source]#
Fetch coordinator and workers for the active cluster.
- Returns:
List of cluster containers.
- Return type:
list[MinitrinoContainer]
- compose_project_name(cluster_name: str = '') str[source][source]#
Compute the Docker Compose project name for a cluster.
- Parameters:
cluster_name (str, optional) – A specific cluster name. If omitted, uses the current cluster name.
- Returns:
The composed project name.
- Return type:
str
- fq_container_name(name: str = '') str[source][source]#
Construct and return a fully-qualified Docker container name.
- Parameters:
name (str) – The base container name.
- Returns:
Fully-qualified container name.
- Return type:
str
- container(fq_container_name: str = '') MinitrinoContainer[source][source]#
Retrieve a MinitrinoContainer by fully-qualified name.
- Parameters:
fq_container_name (str) – Fully-qualified container name to fetch.
- Returns:
The matching container object, wrapped with cluster metadata.
- Return type:
- class minitrino.core.cluster.resource.MinitrinoResourcesView(resources: dict[str, list[MinitrinoContainer | MinitrinoVolume | MinitrinoNetwork | MinitrinoImage]])[source][source]#
Bases:
objectProvide structured access to Docker resources grouped by type.
- Parameters:
resources (dict[str, list[MinitrinoDockerObject]]) – A dictionary of Docker resources grouped by type.
Notes
This class is returned by the resources() method and exposes convenient accessors for retrieving all containers, volumes, networks, or images. Each object tracks its cluster internally via the injected cluster_name.
Initialize a view of Docker resources grouped by type.
- Parameters:
resources (dict[str, list[MinitrinoDockerObject]]) – Docker objects grouped by type.
- containers() list[MinitrinoContainer][source][source]#
Return a list of MinitrinoContainer objects.
- Returns:
List of Minitrino-wrapped Docker Container objects.
- Return type:
list[MinitrinoContainer]
- volumes() list[MinitrinoVolume][source][source]#
Return a list of MinitrinoVolume objects.
- Returns:
List of Minitrino-wrapped Docker Volume objects.
- Return type:
list[MinitrinoVolume]
- networks() list[MinitrinoNetwork][source][source]#
Return a list of MinitrinoNetwork objects.
- Returns:
List of Minitrino-wrapped Docker Network objects.
- Return type:
list[MinitrinoNetwork]
- images() list[MinitrinoImage][source][source]#
Return a list of MinitrinoImage objects.
- Returns:
List of Minitrino-wrapped Docker Image objects.
- Return type:
list[MinitrinoImage]
- raw() dict[str, list[MinitrinoContainer | MinitrinoVolume | MinitrinoNetwork | MinitrinoImage]][source][source]#
Return raw grouped Docker resources.
- Returns:
A dictionary mapping resource types to lists of Docker objects.
- Return type:
dict[str, list[MinitrinoDockerObject]]