Metadata-Version: 2.1
Name: swarm-regulator
Version: 0.1.1
Summary: The regulator of your Docker Swarm cluster
License: MIT
Author: Paris Kasidiaris
Author-email: paris@sourcelair.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: aiodocker (>=0.17.0,<0.18.0)
Requires-Dist: pytest-asyncio (>=0.10.0,<0.11.0)
Description-Content-Type: text/markdown

# Swarm Regulator

Regulate your Docker Swarm cluster, with YOUR rules.

TBD

## Requirements

- Docker Swarm Mode cluster

## Install

TBD

## Run

TBD

## Example

### `regulator.py`
```py
from swarm_regulator import consumer


def _extract_constraints(service_spec):
    return service_spec["TaskTemplate"]["Placement"].get("Constraints", [])


def has_not_constraints(service_spec) -> bool:
    constraints = _extract_constraints(service_spec)
    return not len(constraints)


async def do_not_schedule_on_gpu(service_spec):
    constraints = _extract_constraints(service_spec) + ["node.labels.gpu!=true"]
    service_spec["TaskTemplate"]["Placement"]["Constraints"] = constraints
    return service_spec


consumer.register_rule(
    "service", has_not_constraints, do_not_schedule_on_gpu,
)

consumer.run()
```

### Run

```console
python regulator.py
```

