fliswarm Reference¶
Actor¶
- class fliswarm.actor.FLISwarmActor(*args, **kwargs)[source]¶
Bases:
LegacyActorFLISwarm actor.
- parser = <CluGroup command-parser>¶
Node¶
- class fliswarm.node.Node(name: str, addr: str, category: str | None = None, daemon_addr: str | None = None, registry: str | None = None)[source]¶
Bases:
objectA client to handle a computer node.
- Parameters:
name – The name associated with this node.
addr – The address to the node.
category – A category to use as a filter.
daemon_addr – The address to the Docker daemon. If
None, defaults totcp://node:portwhereportis the default Docker daemon port.registry – The path to the Docker registry.
- async create_volume(name: str, driver: str = 'local', opts: Dict[str, Any] = {}, force: bool = False, command: Command | FakeCommand | None = None)[source]¶
Creates a volume in the node Docker engine.
- Parameters:
name – The name of the volume to create.
driver – The driver to use.
opts – A dict of key-values with the options to pass to the volume when creating it.
force – If
True, and the volume already exists, removes it and creates it anew.command – A command to which output messages.
- Returns:
The volume object.
Examples
To create an NFS volume pointing to
/dataonsdss-hubnuc.create_volume('data', driver='local' opts=['type=nfs', 'o=nfsvers=4,addr=sdss-hub,rw', 'device=:/data'])
- async report_status(command: Command, volumes: bool = True, containers: bool = True)[source]¶
Reports the status of the node to an actor.
- Parameters:
command – The command that is requesting the status.
volumes – Whether to report the volumes connected to the node Docker engine.
containers – Whether to report the containers running. Only reports running containers whose ancestor matches the
config['image'].
Notes
Outputs the
nodekeyword, with formatnode={node_name, addr, daemon_addr, node_alive, docker_alive}. Ifcontainers=True, outputs thecontainerkeyword with formatcontainer={node_name, container_short_id}. Ifvolumes=True, reports thevolumekeyword with formatvolume={node_name, volume, ping, docker_client}
- async run_container(name: str, image: str, volumes: List[Any] = [], privileged: bool = False, registry: Any | None = None, envs: Dict[str, Any] = {}, ports: List[int] | Dict[str, Tuple[str, int]] = [], force: bool = False, command: Command | FakeCommand | None = None) bool[source]¶
Runs a container in the node, in detached mode.
- Parameters:
name – The name to assign to the container.
image – The image to run.
volumes – Names of the volumes to mount. The mount point in the container will match the original device. The volumes must already exist in the node Docker engine.
privileged – Whether to run the container in privileged mode.
registry – The registry from which to pull the image, if it doesn’t exist locally.
envs – A dictionary of environment variable to value to pass to the container.
ports – Ports to bind inside the container. The format must be
{'2222/tcp': 3333}which will expose port 2222 inside the container as port 3333 on the node. Also accepted is a list of integers; each integer port will be exposed in the container and bound to the same port in the node.force – If
True, removes any running containers of the same name, or any container with the same image as ancestor.command – A command to which output messages.
- Returns:
The container object.
- async stop_container(name: str, image: str, force: bool = False, command: Command | FakeCommand | None = None)[source]¶
Stops and removes the container.
- Parameters:
name – The name to assign to the container.
image – The image to run.
force – If
True, removes any stopped containers of the same name or with the same image as ancestor.command – A command to which output messages.
Tools¶
- class fliswarm.tools.FakeCommand[source]¶
Bases:
objectA fake
Commandobject that doesn’t do anything.
- class fliswarm.tools.IDPool[source]¶
Bases:
objectAn ID pool that allows to return values to be reused.
- fliswarm.tools.select_nodes(nodes: Dict[str, Any], category: str | None = None, names: str | List[str] | None = None) Set[Node][source]¶
Filters the nodes to command.
- Parameters:
nodes – A dictionary of
Nodeinstances to be filtered, keyed by node name.category – A category on which to filter.
names – A list or comma-separated string of node names on which to filter.
- Returns:
A
setof enabledNodeinstances that match the providedcategoryornames. If neithercategoryornamesare defined, returns all thenodes.
- async fliswarm.tools.subprocess_run_async(*args, shell=False)[source]¶
Runs a command asynchronously.
If
shell=Truethe command will be executed through the shell. In that case the argument must be a single string with the full command. Otherwise, must receive a list of program arguments. Returns the output of stdout.