""" 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