示例#1
0
 def __init__(self, server=None, req=None):
     self.server = server
     self.remote = None
     self.req = req
     self.collection_mgr = manager.CollectionManager(self)
     self.logger = None
     self.dlmgr = download_manager.DownloadManager(self.collection_mgr,
                                                   self.logger)
示例#2
0
    def __init__(self, server=None, req=None):
        """
        Default constructor which sets up everything to be ready.

        :param server: The domain to run at.
        :param req: This parameter is unused.
        """
        # ToDo: Remove req attribute.
        self.server = server
        self.remote = None
        self.req = req
        self.collection_mgr = manager.CollectionManager(self)
        self.dlmgr = download_manager.DownloadManager(self.collection_mgr)
示例#3
0
    def __init__(self, is_cobblerd=False):
        """
        Constructor
        """

        # FIXME: this should be switchable through some simple system

        self.__dict__ = CobblerAPI.__shared_state
        self.perms_ok = False
        if not CobblerAPI.__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 = clogger.Logger("/var/log/cobbler/cobbler.log")
            except CX:
                # return to CLI/other but perms are not valid
                # perms_ok is False
                return

            # FIXME: conslidate into 1 server instance

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

            CobblerAPI.__has_loaded = True

            # load the modules first, or nothing else works...
            module_loader.load_modules()

            self._collection_mgr = manager.CollectionManager(self)
            self.deserialize()

            # import signatures
            try:
                utils.load_signatures(self.settings().signature_path)
            except Exception as e:
                self.log("Failed to load signatures from %s: %s" %
                         (self.settings().signature_path, e))
                return

            self.log(
                "%d breeds and %d OS versions read from the signature file" %
                (len(utils.get_valid_breeds()),
                 len(utils.get_valid_os_versions())))

            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 yumgen/tftpgen
            # versus reusing this one, which has the wrong logger
            # (most likely) for background tasks.

            self.autoinstallgen = autoinstallgen.AutoInstallationGen(
                self._collection_mgr)
            self.yumgen = yumgen.YumGen(self._collection_mgr)
            self.tftpgen = tftpgen.TFTPGen(self._collection_mgr,
                                           logger=self.logger)
            self.power_mgr = power_manager.PowerManager(
                self, self._collection_mgr)
            self.logger.debug("API handle initialized")
            self.perms_ok = True