blob: 3f7a0b2b90914ae63e3b559cebc9431294cfff37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
"""
Command line entry point for Puppet External Node Classifier (enc).
"""
import yaml
from . import model
def run_enc(fqdn):
"""
Run the puppet node classifier.
Runs the node clasifier for puppet, return the data as yaml.
"""
host = model.Host.query.where(model.Host.fqdn == fqdn).first()
if not host:
print(f"No host with name {fqdn}")
return 1
out = {
'environment': host.environment.name,
'classes': [cls.class_name for cls in host.classes],
}
print(yaml.dump(out))
return 0
|