1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# automato
## Paradigm
___
#### Endpoint
Object to group *States*, *Commands* and *Transports*.
Endpoints can be seen as a *Transport Domain*, commands and states can only use the ones of their endpoint.
In most cases this would be a logical host, like a Raspberry, PC or VM.
#### State
A (numeric) value, or set of values, describing the current state of an *endpoint*.
They are collected on demand and cached for a specific time set by the `ttl` parameter.
A State is addressed via `<endpoint>.<state>`,
some states allow passing of keys to select from multiple values by a dot followed by the key: `<endpoint>.<state>.<key>`
#### Command
A way of manipulating an *endpoint*.
A State is addressed via `<endpoint>.<command>` and can accept additional arguments upon invocation.
#### Transport
Communication channel to the *endpoint* used by *commands* and *states*.
A transport can only be used by *commands* and *states* of its *endpoint* and thus is just referenced by its name.
#### Trigger
regularily checked conditions used to trigger *actions*.
Triggers are re-evaluated in an interval set by the `interval` parameter.
*Actions* hold instances of triggers, which can have their own settings,
but still inherit the globally set ones.
#### Action
An *If-This-Then-That* style set of *triggers* and *commands*.
If all *triggers* are in a triggered state, the commands are executed.
If `repeat` is `False`, the evaluation must cycle through `False` to run again.
`cooldown` specifies the time in seconds the action will wait after running again,
even if conditions are met.
Both `repeat` and `cooldown` are optional and their defaults are `True` and `0`.
## Configuration
___
automato is configured in three `yml`-files
`endpoints.yml`
```yaml
host1:
transports:
ssh:
class: automato.transport.SshTransport
hostname: 'localhost'
username: 'jonas'
commands:
notify:
class: automato.command.NotifyCommand
transport: ssh
states:
user:
class: automato.state.UserSessionState
transport: ssh
ttl: 30
```
`triggers.yml`
```yaml
conditional:
class: automato.trigger.ConditionalTrigger
```
`actions.yml`
```yaml
send-hello:
repeat: False
cooldown: 30
trigger:
- conditional:
interval: 30
when:
- host1.user.jonas > 0
- True
then:
- host1.notify:
msg: Hello
- host1.notify:
msg: World!
```
|