Beispiel #1
0
    def __init__(self, is_cobblerd=False):
        """
        Constructor
        """

        # FIXME: this should be switchable through some simple system

        self.__dict__ = BootAPI.__shared_state
        self.perms_ok = False
        if not BootAPI.__has_loaded:

            if os.path.exists("/etc/cobbler/use.couch"):
                self.use_couch = True
            else:
                self.use_couch = False

            # NOTE: we do not log all API actions, because
            # a simple CLI invocation may call adds and such
            # to load the config, which would just fill up
            # the logs, so we'll do that logging at CLI
            # level (and remote.py web service level) instead.

            random.seed()
            self.is_cobblerd = is_cobblerd

            try:
                self.logger = clogger.Logger("/var/log/cobbler/cobbler.log")
            except CX:
                # return to CLI/other but perms are not valid
                # perms_ok is False
                return

            # FIMXE: conslidate into 1 server instance

            self.selinux_enabled = utils.is_selinux_enabled()
            self.dist = utils.check_dist()
            self.os_version = utils.os_release()

            BootAPI.__has_loaded = True

            module_loader.load_modules()

            self._config = config.Config(self)
            self.deserialize()

            self.authn = self.get_module_from_file("authentication", "module",
                                                   "authn_configfile")
            self.authz = self.get_module_from_file("authorization", "module",
                                                   "authz_allowall")

            # FIXME: pass more loggers around, and also see that those
            # using things via tasks construct their own kickgen/yumgen/
            # pxegen versus reusing this one, which has the wrong logger
            # (most likely) for background tasks.

            self.kickgen = kickgen.KickGen(self._config)
            self.yumgen = yumgen.YumGen(self._config)
            self.pxegen = pxegen.PXEGen(self._config, logger=self.logger)
            self.logger.debug("API handle initialized")
            self.perms_ok = True
Beispiel #2
0
 def __init__(self, config, logger=None):
     """
     Constructor
     """
     self.config = config
     self.settings = config.settings()
     self.kickgen = kickgen.KickGen(config)
     if logger is None:
         logger = clogger.Logger()
     self.logger = logger
 def __init__(self, collection_mgr, logger=None):
     """
     Constructor
     """
     self.collection_mgr = collection_mgr
     self.settings = collection_mgr.settings()
     self.kickgen = kickgen.KickGen(collection_mgr)
     if logger is None:
         logger = clogger.Logger()
     self.logger = logger