diff options
Diffstat (limited to 'pyenc/enc.py')
-rw-r--r-- | pyenc/enc.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pyenc/enc.py b/pyenc/enc.py new file mode 100644 index 0000000..7ec3a8e --- /dev/null +++ b/pyenc/enc.py @@ -0,0 +1,25 @@ + +import click +from flask import current_app, g +from flask.cli import with_appcontext +from .db import db +from . import model + +import yaml + +@click.command('enc') +@click.option('--fqdn', help='Node to get data for') +@with_appcontext +def run_enc(fqdn): + 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)) + +def init_app(app): + app.cli.add_command(run_enc) |