blob: 8732af293f1725fb20040241da2dfde246fb5401 (
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,
'classes': [cls.class_name for cls in host.classes],
}
print(yaml.dump(out))
return 0
|