/usr/lib/python2.7/dist-packages/Bcfg2/Server/Plugins/Decisions.py is in bcfg2-server 1.4.0~pre2+git141-g6d40dace6358-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | """ The Decisions plugin provides a flexible method to whitelist or
blacklist certain entries. """
import os
import Bcfg2.Server.Plugin
import Bcfg2.Server.FileMonitor
class DecisionFile(Bcfg2.Server.Plugin.StructFile):
""" Representation of a Decisions XML file """
def get_decisions(self, metadata):
""" Get a list of whitelist or blacklist tuples """
if self.xdata is None:
# no white/blacklist has been read yet, probably because
# it doesn't exist
return []
return [(x.get('type'), x.get('name'))
for x in self.XMLMatch(metadata).xpath('.//Decision')]
class Decisions(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Decision):
""" Decisions plugin """
__author__ = 'bcfg-dev@mcs.anl.gov'
def __init__(self, core):
Bcfg2.Server.Plugin.Plugin.__init__(self, core)
Bcfg2.Server.Plugin.Decision.__init__(self)
self.whitelist = DecisionFile(os.path.join(self.data, "whitelist.xml"),
should_monitor=True)
self.blacklist = DecisionFile(os.path.join(self.data, "blacklist.xml"),
should_monitor=True)
def GetDecisions(self, metadata, mode):
return getattr(self, mode).get_decisions(metadata)
|