Exemplo n.º 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
Exemplo n.º 2
0
    def __init__(self,config,verbose=True,dhcp=None,dns=None,logger=None,tftpd=None):
        """
        Constructor
        """

        self.logger         = logger
        if logger is None:
            self.logger     = clogger.Logger()

        self.verbose      = verbose
        self.config       = config
        self.api          = config.api
        self.distros      = config.distros()
        self.profiles     = config.profiles()
        self.systems      = config.systems()
        self.settings     = config.settings()
        self.repos        = config.repos()
        self.templar      = templar.Templar(config, self.logger)
        self.pxegen       = pxegen.PXEGen(config, self.logger)
        self.dns          = dns
        self.dhcp         = dhcp
        self.tftpd        = tftpd
        self.bootloc      = utils.tftpboot_location()
        self.pxegen.verbose = verbose
        self.dns.verbose    = verbose
        self.dhcp.verbose   = verbose

        self.pxelinux_dir = os.path.join(self.bootloc, "pxelinux.cfg")
        self.grub_dir = os.path.join(self.bootloc, "grub")
        self.images_dir = os.path.join(self.bootloc, "images")
        self.yaboot_bin_dir = os.path.join(self.bootloc, "ppc")
        self.yaboot_cfg_dir = os.path.join(self.bootloc, "etc")
        self.s390_dir = os.path.join(self.bootloc, "s390x")
        self.rendered_dir = os.path.join(self.settings.webdir, "rendered")
Exemplo n.º 3
0
    def __init__(self,config,logger):
        """
        Constructor
        """
        self.logger        = logger
        if self.logger is None:
            self.logger = clogger.Logger()

        self.config        = config
        self.templar       = templar.Templar(config)
        self.settings_file = "/etc/xinetd.d/tftp"
        self.pxegen        = pxegen.PXEGen(config, self.logger)
        self.systems       = config.systems()
        self.bootloc       = utils.tftpboot_location()
Exemplo n.º 4
0
 def sync(self, verbose=True):
     """
     Write out files to /tftpdboot.  Mostly unused for the python server
     """
     self.logger.info("copying bootloaders")
     pxegen.PXEGen(self.config, self.logger).copy_bootloaders()