def run(api, args, logger): if not logger: logger = clogger.Logger() logger.info("sync_post_tftp_proxies started") settings = api.settings() # test if proxies are configured: try: p = settings.proxies except: # not configured - so we return return 0 tftpbootdir = "/srv/tftpboot" syncstart = os.stat(tftpbootdir).st_mtime find_delete_from_proxies(tftpbootdir, settings, logger=logger) for root, dirs, files in os.walk(tftpbootdir): for fname in files: path = os.path.join(root, fname) if '.link_cache' in path: continue check_push(path, tftpbootdir, settings, logger=logger) return 0
def __init__(self,api,config,mirror,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None,breed=None,os_version=None,logger=None): """ Performs an import of a install tree (or trees) from the given mirror address. The prefix of the distro is to be specified by mirror name. For instance, if FC-6 is given, FC-6-xen-i386 would be a potential distro that could be created. For content available on external servers via a known nfs:// or ftp:// or http:// path, we can import without doing rsync mirorring to cobbler's http directory. This is explained in more detail in the manpage. Leave network_root to None if want mirroring. """ self.api = api self.config = config self.mirror = mirror self.mirror_name = mirror_name self.network_root = network_root self.distros = config.distros() self.profiles = config.profiles() self.systems = config.systems() self.settings = config.settings() self.kickstart_file = kickstart_file self.rsync_flags = rsync_flags self.arch = arch self.breed = breed self.os_version = os_version if logger is None: logger = clogger.Logger() self.logger = logger
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,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")
def __init__(self, config, logger): self.logger = logger if self.logger is None: self.logger = clogger.Logger() self.config = config self.systems = config.systems() self.templar = templar.Templar(config)
def __init__(self, hostname): """Constructor. Requires a Cobbler API handle.""" self.hostname = hostname self.handle = capi.BootAPI() self.system = self.handle.find_system(hostname=self.hostname) self.host_vars = self.get_cobbler_resource('ks_meta') self.logger = clogger.Logger("/var/log/cobbler/cobbler.log") self.mgmtclasses = self.get_cobbler_resource('mgmt_classes')
def __init__(self, collection_mgr, logger=None): """ Constructor """ self.collection_mgr = collection_mgr self.settings = collection_mgr.settings() if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, config, logger=None): """ Constructor """ self.config = config self.settings = config.settings() if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, collection_mgr, mode, logger=None): """ Constructor """ self.collection_mgr = collection_mgr self.settings = collection_mgr.settings() self.ip_data = {} self.mode = mode if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, config, mode, logger=None): """ Constructor """ self.config = config self.settings = config.settings() self.ip_data = {} self.mode = mode if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, config, system, api, logger=None): """ Log library constructor requires a cobbler system object. """ self.system = system self.config = config self.settings = config.settings() self.api = api if logger is None: logger = clogger.Logger() self.logger = logger
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"
def __init__(self, config, logger=None): """ Constructor """ self.config = config self.settings = config.settings() self.api = config.api self.remote = None self.uri = None if logger is None: logger = clogger.Logger() self.logger = logger
def load_modules(module_path=mod_path, blacklist=None): logger = clogger.Logger() #识别可能的module文件 filenames = glob.glob("%s/*.py" % module_path) filenames += glob.glob("%s/*.pyc" % module_path) filenames += glob.glob("%s/*.pyo" % module_path) mods = set() #跳过__init__.py,重复名称 for fn in filenames: basename = os.path.basename(fn) if basename == "__init__.py": continue if basename[-3:] == ".py": modname = basename[:-3] elif basename[-4:] in [".pyc", ".pyo"]: modname = basename[:-4] # No need to try importing the same module over and over if # we have a .py, .pyc, and .pyo if modname in mods: continue mods.add(modname) try: #载入模块 blip = __import__("modules.%s" % (modname), globals(), locals(), [modname]) if not hasattr(blip, "register"): if not modname.startswith("__init__"): #非预期的文件,报错 errmsg = _( "%(module_path)s/%(modname)s is not a proper module") print errmsg % { 'module_path': module_path, 'modname': modname } continue #注册module category = blip.register() if category: MODULE_CACHE[modname] = blip if category not in MODULES_BY_CATEGORY: MODULES_BY_CATEGORY[category] = {} MODULES_BY_CATEGORY[category][modname] = blip except Exception: logger.info('Exception raised when loading module %s' % modname) log_exc(logger) #返回载入的所有module,按分类划分module return (MODULE_CACHE, MODULES_BY_CATEGORY)
def __init__(self, collection_mgr, logger=None): """ Constructor """ self.collection_mgr = collection_mgr self.settings = collection_mgr.settings() self.api = collection_mgr.api self.remote = None self.uri = None if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, config, logger=None): """ Constructor """ self.config = config self.api = config.api self.settings = config.settings() self.last_errors = [] if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self,config,system,api,force_user=None,force_pass=None,logger=None): """ Power library constructor requires a cobbler system object. """ self.system = system self.config = config self.settings = config.settings() self.api = api self.logger = self.api.logger self.force_user = force_user self.force_pass = force_pass if logger is None: logger = clogger.Logger() self.logger = logger
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()
def __init__(self, collection_mgr, logger): """ Constructor """ self.logger = logger if self.logger is None: self.logger = clogger.Logger() self.collection_mgr = collection_mgr self.templar = templar.Templar(collection_mgr) self.settings_file = "/etc/xinetd.d/tftp" self.tftpgen = tftpgen.TFTPGen(collection_mgr, self.logger) self.systems = collection_mgr.systems() self.bootloc = utils.tftpboot_location()
def __init__(self, api, collection_mgr, logger=None): """ Constructor @param CobblerAPI api Cobbler API @param CollectionManager collection_mgr collection manager @param Logger logger logger """ self.collection_mgr = collection_mgr self.settings = collection_mgr.settings() self.api = api if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, config, logger=None): """ Constructor """ self.config = config self.settings = config.settings() self.api = config.api self.report_type = None self.report_what = None self.report_name = None self.report_fields = None self.report_noheaders = None self.array_re = re.compile('([^[]+)\[([^]]+)\]') if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, collection_mgr, logger=None): """ Constructor """ self.collection_mgr = None self.settings = None if collection_mgr: self.collection_mgr = collection_mgr self.settings = collection_mgr.settings() self.last_errors = [] if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self,config,verbose=False,logger=None): """ Constructor """ self.verbose = verbose self.config = config self.api = config.api self.distros = config.distros() self.profiles = config.profiles() self.systems = config.systems() self.distros = config.distros() self.distmap = {} self.distctr = 0 self.source = "" if logger is None: logger = clogger.Logger() self.logger = logger
def __init__(self, config, verbose=False, logger=None): """ Constructor """ self.verbose = verbose self.config = config self.distros = config.distros() self.profiles = config.profiles() self.systems = config.systems() self.images = config.images() self.settings = config.settings() self.repos = config.repos() if logger is None: logger = clogger.Logger() self.logger = logger self.sync = config.api.get_sync(verbose, logger=self.logger) self.sync.make_tftpboot()
def __init__(self, collection_mgr, logger=None): """ Constructor """ # self.collection_mgr = collection_mgr # self.api = collection_mgr.api # self.settings = collection_mgr.settings() if logger is None: logger = clogger.Logger() self.logger = logger self.family = utils.get_family() if self.family == "debian": self.hardlink = "/usr/bin/hardlink" self.hardlink_args = "-f -p -o -t -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror" else: self.hardlink = "/usr/sbin/hardlink" self.hardlink_args = "-c -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror" self.hardlink_cmd = "%s %s" % (self.hardlink, self.hardlink_args)
def __init__(self, collection_mgr, logger): """ Constructor """ self.logger = logger if self.logger is None: self.logger = clogger.Logger() self.collection_mgr = collection_mgr self.api = collection_mgr.api self.distros = collection_mgr.distros() self.profiles = collection_mgr.profiles() self.systems = collection_mgr.systems() self.settings = collection_mgr.settings() self.repos = collection_mgr.repos() self.templar = templar.Templar(collection_mgr) self.settings_file = utils.namedconf_location(self.api) self.zonefile_base = utils.zonefile_base(self.api)
def __init__(self, config, logger=None): """ Constructor """ #self.config = config #self.api = config.api #self.settings = config.settings() if logger is None: logger = clogger.Logger() self.logger = logger self.distro = utils.check_dist() if self.distro == "ubuntu" or self.distro == "debian": self.hardlink = "/usr/bin/hardlink" self.hardlink_args = "-f -p -o -t -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror" else: self.hardlink = "/usr/sbin/hardlink" self.hardlink_args = "-c -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror" self.hardlink_cmd = "%s %s" % (self.hardlink, self.hardlink_args)
def __init__(self, collection_mgr, verbose=False, logger=None): """ Constructor """ self.verbose = verbose self.collection_mgr = collection_mgr self.distros = collection_mgr.distros() self.profiles = collection_mgr.profiles() self.systems = collection_mgr.systems() self.images = collection_mgr.images() self.settings = collection_mgr.settings() self.repos = collection_mgr.repos() if logger is None: logger = clogger.Logger() self.logger = logger self.tftpd = module_loader.get_module_from_file( "tftpd", "module", "in_tftpd").get_manager(collection_mgr, logger) self.sync = collection_mgr.api.get_sync(verbose, logger=self.logger) self.sync.make_tftpboot()
def __init__(self, collection_mgr, tries=1, nofail=False, logger=None): """ Constructor """ self.verbose = True self.api = collection_mgr.api self.collection_mgr = collection_mgr self.distros = collection_mgr.distros() self.profiles = collection_mgr.profiles() self.systems = collection_mgr.systems() self.settings = collection_mgr.settings() self.repos = collection_mgr.repos() self.rflags = self.settings.reposync_flags self.tries = tries self.nofail = nofail self.logger = logger if logger is None: self.logger = clogger.Logger() self.logger.info("hello, reposync")
def __init__(self, config, verbose=False, logger=None): """ Constructor """ self.verbose = verbose self.config = config self.settings = config.settings() self.api = config.api self.distros = config.distros() self.profiles = config.profiles() self.systems = config.systems() self.distros = config.distros() self.distmap = {} self.distctr = 0 self.source = "" if logger is None: logger = clogger.Logger() self.logger = logger # grab the header from buildiso.header file header_src = open(os.path.join(self.settings.iso_template_dir, "buildiso.template")) self.iso_template = header_src.read() header_src.close()