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
def __init__(self, log_settings={}, is_cobblerd=False): """ Constructor """ self.__dict__ = BootAPI.__shared_state self.log_settings = log_settings self.perms_ok = False if not BootAPI.__has_loaded: # 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 = self.__setup_logger("api") 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() self.acl_engine = acls.AclEngine() 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" ) self.kickgen = kickgen.KickGen(self._config) self.yumgen = yumgen.YumGen(self._config) self.pxegen = pxegen.PXEGen(self._config) self.logger.debug("API handle initialized") self.perms_ok = True