blob: e0f3f8d28a8df4583aa125d5e2dbf7f86177bdf8 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
"""
Command line entry point for Puppet External Node Classifier (enc).
"""
import click
import yaml
# from flask import current_app, g
# from flask.cli import with_appcontext, AppGroup
from flask.cli import AppGroup
# from .db import db
from . import model
app_group = AppGroup('user', help="Testt")
@app_group.command('enc')
@click.argument('fqdn')
# @with_appcontext
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
def init_app(app):
"""Add puppet enc click to current flask app."""
app.cli.add_command(app_group)
|