From 4ef9765933475e089f4f58d4d45019faab92646e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 3 Mar 2022 00:30:59 +0100 Subject: Remove cruft from model file. --- pyenc/model.py | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/pyenc/model.py b/pyenc/model.py index 1999d9d..be491ee 100644 --- a/pyenc/model.py +++ b/pyenc/model.py @@ -40,35 +40,3 @@ class PuppetClass(db.Model): hosts = db.relationship('Host', back_populates='classes', secondary=host_classes) - - -################################################## -# Everything below should be removed - - -def import_from_puppetdb(): - payload = {'query': 'nodes {}'} - r = requests.post('http://busting.adrift.space:8080/pdb/query/v4', - data=json.dumps(payload)) - for item in r.json(): - db.session.add( - Host(fqdn=item['certname'], - environment=item['catalog_environment'])) - db.session.commit() - -def import_more(): - with open('/usr/local/puppet/nodes.yaml') as f: - data = yaml.full_load(f) - for fqdn, val in data.items(): - h = Host.query.where(Host.fqdn==fqdn).first() - print(h) - if not h: continue - # print(h) - classes = data[h.fqdn]['classes'] - if type(classes) == dict: - classes = classes.keys() - cls = PuppetClass.query.where(PuppetClass.class_name.in_(classes)).all() - print(cls) - for c in cls: - h.classes.append(c) - db.session.commit() -- cgit v1.2.3