puppet node classifier
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.0 KiB

  1. import ZODB
  2. import ZODB.FileStorage
  3. import persistent
  4. import persistent.list
  5. import persistent.mapping
  6. import BTrees.OOBTree
  7. def plist():
  8. return persistent.list.PersistentList()
  9. def pmap():
  10. return persistent.mapping.PersistentMapping()
  11. class NObject(persistent.Persistent):
  12. def __init__(self, fqdn, body):
  13. self.fqdn = fqdn
  14. self.parents = plist()
  15. self.classes = pmap()
  16. self.body = body
  17. class NClass(persistent.Persistent):
  18. def __init__(self, name):
  19. self.name = name
  20. class NClassAttachment(persistent.Persistent):
  21. def __init__(self, cls, conf):
  22. self.cls = cls
  23. self.conf = conf
  24. class NodeOps(object):
  25. def __init__(self, db_path):
  26. self.storage = ZODB.FileStorage.FileStorage(db_path)
  27. self.db = ZODB.DB(self.storage)
  28. with self.db.transaction() as c:
  29. if "nodes" not in c.root():
  30. c.root.nodes = BTrees.OOBTree.BTree()
  31. if "classes" not in c.root():
  32. c.root.classes = BTrees.OOBTree.BTree()