• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rhnLog.initLOG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spacewalk.common.rhnLog.initLOG函数的典型用法代码示例。如果您正苦于以下问题:Python initLOG函数的具体用法?Python initLOG怎么用?Python initLOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了initLOG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: headerParserHandler

 def headerParserHandler(self, req):
     log_setreq(req)
     # init configuration options with proper component
     options = req.get_options()
     # if we are initializing out of a <Location> handler don't
     # freak out
     if not options.has_key("RHNComponentType"):
         # clearly nothing to do
         return apache.OK
     initCFG(options["RHNComponentType"])
     initLOG(CFG.LOG_FILE, CFG.DEBUG)
     if req.method == 'GET':
         # This is the ping method
         return apache.OK
     self.servers = rhnImport.load("upload_server/handlers",
         interface_signature='upload_class')
     if not options.has_key('SERVER'):
         log_error("SERVER not set in the apache config files!")
         return apache.HTTP_INTERNAL_SERVER_ERROR
     server_name = options['SERVER']
     if not self.servers.has_key(server_name):
         log_error("Unable to load server %s from available servers %s" %
             (server_name, self.servers))
         return apache.HTTP_INTERNAL_SERVER_ERROR
     server_class = self.servers[server_name]
     self.server = server_class(req)
     return self._wrapper(req, "headerParserHandler")
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:27,代码来源:apacheUploadServer.py


示例2: sync

    def sync(self, channels=None):
        # If no channels specified, sync already synced channels
        if not channels:
            channels = self.synced_channels

        # Check channel availability before doing anything
        not_available = []
        for channel in channels:
            if any(channel not in d for d in
                   [self.channel_metadata, self.channel_to_family,  self.content_source_mapping]):
                not_available.append(channel)

        if not_available:
            raise ChannelNotFoundError("  " + "\n  ".join(not_available))

        # Need to update channel metadata
        self._update_channels_metadata(channels)

        # Finally, sync channel content
        total_time = datetime.timedelta()
        for channel in channels:
            cur_time = self._sync_channel(channel)
            total_time += cur_time
            # Switch back to cdnsync log
            rhnLog.initLOG(self.log_path, self.log_level)
            log2disk(0, "Sync of channel completed.")

        log(0, "Total time: %s" % str(total_time).split('.')[0])
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:28,代码来源:cdnsync.py


示例3: setup_config

    def setup_config(self, config, force=0):
        # Figure out the log level
        debug_level = self.options.verbose
        if debug_level is None:
            debug_level = CFG.debug
        self.debug_level = debug_level
        logfile = self.options.logfile
        if logfile is None or logfile == '':
            logfile = CFG.log_file
        initLOG(level=debug_level, log_file=logfile)

        # Get the ssl cert
        ssl_cert = CFG.osa_ssl_cert
        try:
            self.check_cert(ssl_cert)
        except jabber_lib.InvalidCertError:
            e = sys.exc_info()[1]
            log_error("Invalid SSL certificate:", e)
            return 1

        self.ssl_cert = ssl_cert

        rhnSQL.initDB()

        self._username = 'rhn-dispatcher-sat'
        self._password = self.get_dispatcher_password(self._username)
        if not self._password:
            self._password = self.create_dispatcher_password(32)
        self._resource = 'superclient'
        js = config.get('jabber_server')
        self._jabber_servers = [ idn_ascii_to_puny(js) ]
开发者ID:m47ik,项目名称:uyuni,代码行数:31,代码来源:osa_dispatcher.py


示例4: main

def main():
    global debug, verbose
    parser = OptionParser(option_list=options_table)

    (options, args) = parser.parse_args()

    if args:
        for arg in args:
            sys.stderr.write("Not a valid option ('%s'), try --help\n" % arg)
        sys.exit(-1)

    if options.verbose:
        initLOG("stdout", options.verbose or 0)
        verbose = 1

    if options.debug:
        initLOG(CFG.LOG_FILE, options.debug or 0)
        debug = 1

    rhnSQL.initDB()

    if options.update_filer:
        process_package_data()

    if options.update_sha256:
        process_sha256_packages()

    if options.update_kstrees:
        process_kickstart_trees()

    if options.update_package_files:
        process_package_files()

    if options.update_changelog:
        process_changelog()
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:35,代码来源:updatePackages.py


示例5: cleanupHandler

 def cleanupHandler(self, req):
     self._timer()
     retval = self._wrapper(req, self._cleanupHandler)
     self._cleanup()
     # Reset the logger to stderr
     initLOG()
     return retval
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:7,代码来源:satexport.py


示例6: sync

    def sync(self, channels=None):
        # If no channels specified, sync already synced channels
        if not channels:
            channels = self.synced_channels

        # Check channel availability before doing anything
        not_available = []
        for channel in channels:
            if any(channel not in d for d in
                   [self.channel_metadata, self.channel_to_family]) or (
                       not self.cdn_repository_manager.check_channel_availability(channel, self.no_kickstarts)):
                not_available.append(channel)

        if not_available:
            raise ChannelNotFoundError("  " + "\n  ".join(not_available))

        # Need to update channel metadata
        self._update_channels_metadata(channels)

        # Finally, sync channel content
        error_messages = []
        total_time = datetime.timedelta()
        for channel in channels:
            cur_time, ret_code = self._sync_channel(channel)
            if ret_code != 0:
                error_messages.append("Problems occurred during syncing channel %s. Please check "
                                      "/var/log/rhn/cdnsync/%s.log for the details\n" % (channel, channel))
            total_time += cur_time
            # Switch back to cdnsync log
            rhnLog.initLOG(self.log_path, self.log_level)
            log2disk(0, "Sync of channel completed.")
        log(0, "Total time: %s" % str(total_time).split('.')[0])
        return error_messages
开发者ID:shastah,项目名称:spacewalk,代码行数:33,代码来源:cdnsync.py


示例7: sync

    def sync(self, channels=None):
        # If no channels specified, sync already synced channels
        if not channels:
            channels = list(self.synced_channels)

        # Check channel availability before doing anything
        not_available = []
        available = []
        for channel in channels:
            if not self._is_channel_available(channel):
                not_available.append(channel)
            else:
                available.append(channel)

        channels = available

        error_messages = []

        # if we have not_available channels log the error immediately
        if not_available:
            msg = "ERROR: these channels either do not exist or are not available:\n  " + "\n  ".join(not_available)
            error_messages.append(msg)

            # BZ 1434913 - let user know satellite may not be activated if all channels are in not_available
            if not available:
                msg = "WARNING: Is your Red Hat Satellite activated for CDN?\n"
                msg += "(to see details about currently used SSL certificates for accessing CDN:"
                msg += " /usr/bin/cdn-sync --cdn-certs)"
                error_messages.append(msg)

        # Need to update channel metadata
        self._update_channels_metadata([ch for ch in channels if ch in self.channel_metadata])
        # Make sure custom channels are properly connected with repos
        for channel in channels:
            if channel in self.synced_channels and self.synced_channels[channel]:
                self.cdn_repository_manager.assign_repositories_to_channel(channel)

        reposync.clear_ssl_cache()

        # Finally, sync channel content
        total_time = timedelta()
        for channel in channels:
            cur_time, failed_packages = self._sync_channel(channel)
            if failed_packages < 0:
                error_messages.append("Problems occurred during syncing channel %s. Please check "
                                      "/var/log/rhn/cdnsync/%s.log for the details\n" % (channel, channel))
            if failed_packages > 0:
                error_messages.append("%d packages in channel %s failed to sync. Please check "
                                      "/var/log/rhn/cdnsync/%s.log for the details\n" % (failed_packages, channel,
                                                                                         channel))
            total_time += cur_time
            # Switch back to cdnsync log
            rhnLog.initLOG(self.log_path, self.log_level)
            log2disk(0, "Sync of channel completed.")

        log(0, "Total time: %s" % str(total_time).split('.')[0])

        return error_messages
开发者ID:lhellebr,项目名称:spacewalk,代码行数:58,代码来源:cdnsync.py


示例8: __init__

    def __init__(
        self,
        channel_label,
        repo_type,
        url=None,
        fail=False,
        quiet=False,
        filters=None,
        no_errata=False,
        sync_kickstart=False,
        latest=False,
    ):
        self.regen = False
        self.fail = fail
        self.quiet = quiet
        self.filters = filters or []
        self.no_errata = no_errata
        self.sync_kickstart = sync_kickstart
        self.latest = latest

        initCFG("server")
        rhnSQL.initDB()

        # setup logging
        log_filename = channel_label + ".log"
        rhnLog.initLOG(default_log_location + log_filename)
        # os.fchown isn't in 2.4 :/
        os.system("chgrp apache " + default_log_location + log_filename)

        self.log_msg("\nSync started: %s" % (time.asctime(time.localtime())))
        self.log_msg(str(sys.argv))

        self.channel_label = channel_label
        self.channel = self.load_channel()
        if not self.channel or not rhnChannel.isCustomChannel(self.channel["id"]):
            self.print_msg("Channel does not exist or is not custom.")
            sys.exit(1)

        if not url:
            # TODO:need to look at user security across orgs
            h = rhnSQL.prepare(
                """select s.id, s.source_url, s.label
                                  from rhnContentSource s,
                                       rhnChannelContentSource cs
                                 where s.id = cs.source_id
                                   and cs.channel_id = :channel_id"""
            )
            h.execute(channel_id=int(self.channel["id"]))
            source_data = h.fetchall_dict()
            if source_data:
                self.urls = [(row["id"], row["source_url"], row["label"]) for row in source_data]
            else:
                self.error_msg("Channel has no URL associated")
                sys.exit(1)
        else:
            self.urls = [(None, u, None) for u in url]

        self.repo_plugin = self.load_plugin(repo_type)
开发者ID:jetsaredim,项目名称:spacewalk,代码行数:58,代码来源:reposync.py


示例9: cleanupHandler

 def cleanupHandler(self, req):
     if req.method == 'GET':
         # This is the ping method
         return apache.OK
     retval = self._wrapper(req, "cleanupHandler")
     # Reset the logger to stderr
     initLOG()
     self.server = None
     return retval
开发者ID:Kilian-Petsch,项目名称:spacewalk,代码行数:9,代码来源:apacheUploadServer.py


示例10: __init__

    def __init__(self, channel_label, repo_type, url=None, fail=False,
                 quiet=False, filters=None, no_errata=False, sync_kickstart=False, latest=False,
                 strict=0):
        self.regen = False
        self.fail = fail
        self.quiet = quiet
        self.filters = filters or []
        self.no_errata = no_errata
        self.sync_kickstart = sync_kickstart
        self.latest = latest

        initCFG('server.satellite')
        rhnSQL.initDB()

        # setup logging
        log_filename = channel_label + '.log'
        if CFG.DEBUG is not None:
            log_level = CFG.DEBUG

        rhnLog.initLOG(default_log_location + log_filename, log_level)
        # os.fchown isn't in 2.4 :/
        if isSUSE():
            os.system("chgrp www " + default_log_location + log_filename)
        else:
            os.system("chgrp apache " + default_log_location + log_filename)

        self.log_msg("\nSync started: %s" % (time.asctime(time.localtime())))
        self.log_msg(str(sys.argv))

        self.channel_label = channel_label
        self.channel = self.load_channel()
        if not self.channel:
            self.print_msg("Channel does not exist.")
            sys.exit(1)

        if not url:
            # TODO:need to look at user security across orgs
            h = rhnSQL.prepare("""select s.id, s.source_url, s.label, fm.channel_family_id
                                  from rhnContentSource s,
                                       rhnChannelContentSource cs,
                                       rhnChannelFamilyMembers fm
                                 where s.id = cs.source_id
                                   and cs.channel_id = fm.channel_id
                                   and cs.channel_id = :channel_id""")
            h.execute(channel_id=int(self.channel['id']))
            source_data = h.fetchall_dict()
            if source_data:
                self.urls = [(row['id'], row['source_url'], row['label'],
                              row['channel_family_id']) for row in source_data]
            else:
                self.error_msg("Channel has no URL associated")
                sys.exit(1)
        else:
            self.urls = [(None, u, None, None) for u in url]

        self.repo_plugin = self.load_plugin(repo_type)
        self.strict = strict
开发者ID:u-s-p,项目名称:spacewalk,代码行数:57,代码来源:reposync.py


示例11: setup_config

    def setup_config(self, config):
        # Figure out the log level
        debug_level = self.options.verbose
        if debug_level is None:
            debug_level = CFG.debug
        self.debug_level = debug_level
        initLOG(level=debug_level, log_file=CFG.log_file)

        # Get the ssl cert
        ssl_cert = CFG.osa_ssl_cert
        try:
            self.check_cert(ssl_cert)
        except jabber_lib.InvalidCertError, e:
            log_error("Invalid SSL certificate:", e)
            return 1
开发者ID:mantel,项目名称:spacewalk,代码行数:15,代码来源:osa_dispatcher.py


示例12: headerParserHandler

    def headerParserHandler(self, req):

        log_setreq(req)
        # We need to init CFG and Logging
        options = req.get_options()
        # if we are initializing out of a <Location> handler don't
        # freak out
        if not options.has_key("RHNComponentType"):
            # clearly nothing to do
            return apache.OK
        initCFG(options["RHNComponentType"])
        initLOG(CFG.LOG_FILE, CFG.DEBUG)

        """ parse the request, init database and figure out what can we call """
        log_debug(2, req.the_request)
        # call method from inherited class
        ret = apacheSession.headerParserHandler(self, req)
        if ret != apache.OK:
            return ret
        # make sure we have DB connection
        if not CFG.SEND_MESSAGE_TO_ALL:
            try:
                rhnSQL.initDB()
            except rhnSQL.SQLConnectError:
                rhnTB.Traceback(mail=1, req=req, severity="schema")
                return apache.HTTP_INTERNAL_SERVER_ERROR
        else:
            # If in outage mode, close the DB connections
            rhnSQL.closeDB()

        # Store client capabilities
        client_cap_header = 'X-RHN-Client-Capability'
        if req.headers_in.has_key(client_cap_header):
            client_caps = req.headers_in[client_cap_header]
            client_caps = filter(None,
                                 map(string.strip, string.split(client_caps, ","))
                                 )
            rhnCapability.set_client_capabilities(client_caps)

        # Enabling the input header flags associated with the redirects/newer clients
        redirect_support_flags = ['X-RHN-Redirect', 'X-RHN-Transport-Capability']
        for flag in redirect_support_flags:
            if req.headers_in.has_key(flag):
                rhnFlags.set(flag, str(req.headers_in[flag]))

        return apache.OK
开发者ID:flavio,项目名称:spacewalk,代码行数:46,代码来源:apacheHandler.py


示例13: headerParserHandler

    def headerParserHandler(self, req):
        # pylint: disable=W0201
        log_setreq(req)
        self.start_time = time.time()
        # init configuration options with proper component
        options = req.get_options()
        # if we are initializing out of a <Location> handler don't
        # freak out
        if "RHNComponentType" not in options:
            # clearly nothing to do
            return apache.OK
        initCFG(options["RHNComponentType"])
        initLOG(CFG.LOG_FILE, CFG.DEBUG)
        # short-circuit everything if sending a system-wide message.
        if CFG.SEND_MESSAGE_TO_ALL:
            # Drop the database connection
            # pylint: disable=W0702
            try:
                rhnSQL.closeDB()
            except:
                pass

            # Fetch global message being sent to clients if applicable.
            msg = open(CFG.MESSAGE_TO_ALL).read()
            log_debug(3, "Sending message to all clients: %s" % msg)
            return self._send_xmlrpc(req, rhnFault(-1,
                                                   _("IMPORTANT MESSAGE FOLLOWS:\n%s") % msg, explain=0))

        rhnSQL.initDB()
        self.server = options['SERVER']

        self.server_classes = rhnImport.load("satellite_exporter/handlers")

        if self.server not in self.server_classes:
            # XXX do something interesting here
            log_error("Missing server", self.server)
            return apache.HTTP_NOT_FOUND

        return self._wrapper(req, self._headerParserHandler)
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:39,代码来源:satexport.py


示例14: __call__

    def __call__(self, req):
        # NOTE: all imports done here due to required initialization of
        #       of the configuration module before all others.
        #       Initialization is dependent on RHNComponentType in the
        #       req object.

        if self.__init:
            from apacheHandler import getComponentType
            # We cannot trust the config files to tell us if we are in the
            # broker or in the redirect because we try to always pass
            # upstream all requests
            componentType = getComponentType(req)
            initCFG(componentType)
            initLOG(CFG.LOG_FILE, CFG.DEBUG)
            log_debug(1, 'New request, component %s' % (componentType, ))

        # Instantiate the handlers
        if HandlerWrap.svrHandlers is None:
            HandlerWrap.svrHandlers = self.get_handler_factory(req)()

        if self.__init:
            # Set the component type
            HandlerWrap.svrHandlers.set_component(componentType)

        try:
            log_setreq(req)
            if hasattr(HandlerWrap.svrHandlers, self.__name):
                f = getattr(HandlerWrap.svrHandlers, self.__name)
                ret = f(req)
            else:
                raise Exception("Class has no attribute %s" % self.__name)
        # pylint: disable=W0702
        except:
            Traceback(self.__name, req, extra="Unhandled exception type",
                      severity="unhandled")
            return apache.HTTP_INTERNAL_SERVER_ERROR
        else:
            return ret
开发者ID:jdobes,项目名称:spacewalk,代码行数:38,代码来源:apacheServer.py


示例15: main

def main(options):
    xmlrpc = RemoteApi(options.server, options.username, options.password)
    db = DBApi()
    initCFG('server')
    rhnLog.initLOG(LOG_LOCATION)

    cleansed = vars(options)
    cleansed["password"] = "*****"
    log_clean(0, "")
    log_debug(0, "Started spacewalk-clone-by-date")
    log_clean(0, pprint.pformat(cleansed))

    print "Reading repository information."
    if options.use_update_date:
        options.use_update_date = 'update_date'
    else:
        options.use_update_date = 'issue_date'
    print "Using %s." % options.use_update_date

    cloners = []
    needed_channels = []
    errata = None
    if options.errata:
        errata = set(options.errata)
    for channel_list in options.channels:
        parents = None
        if options.parents:
            # if only the dest parent is specified, look up the src parent
            if len(options.parents) == 1:
                src_parent = xmlrpc.get_original(options.parents[0])
                if not src_parent:
                    print ("Channel %s is not a cloned channel." % options.parents[0])
                    sys.exit(1)
                print "Looking up the original channel for %s, %s found" % (
                    options.parents[0], src_parent)
                options.parents = [src_parent] + options.parents
            # options.parents is only set by command line, this must be the
            # only channel tree
            parents = options.parents

        # Handle the new-style channel specification that uses
        # key value pairs. Transform into channel / parent setup that
        # ChannelTreeCloner expects. This code has to be here now that you can
        # specify parents for multiple trees.
        # TODO: the channel / parents structure needs to be cleaned up throught
        # clone-by-date. Probably best thing would to make everywhere use the
        # dict structure instead of the list structure.
        for src_channel in channel_list.keys():
            dest_channel = channel_list[src_channel]
            # new-style config file channel specification
            if type(dest_channel) == dict:
                if 'label' not in dest_channel:
                    raise UserError("You must specify a label for the clone of %s" % src_channel)
                label = dest_channel['label']
                if 'name' in dest_channel:
                    name = dest_channel['name']
                else:
                    name = label
                if 'summary' in dest_channel:
                    summary = dest_channel['summary']
                else:
                    summary = label
                if 'description' in dest_channel:
                    description = dest_channel['description']
                else:
                    description = label
                # This is the options.parents equivalent for config files.
                # Add channels to parents option and remove from channels.
                if ('existing-parent-do-not-modify' in dest_channel
                        and dest_channel['existing-parent-do-not-modify']):
                    parents = [src_channel, label]
                    del channel_list[src_channel]
                else:  # else tranform channel_list entry to the list format
                    channel_list[src_channel] = [label, name, summary,
                                                 description]

        # before we start make sure we can get repodata for all channels
        # involved.
        channel_labels = channel_list.keys()
        for label in channel_labels:
            if not os.path.exists(repodata(label)):
                raise UserRepoError(label)
        # ensure the parent's channel metadata is available
        if parents:
            for label in parents:
                if not os.path.exists(repodata(label)):
                    raise UserRepoError(label)

        # if cloning specific errata validate that they actually exist
        # in the original channels
        if options.errata:
            for channel in channel_labels:
                channel_errata = set(xmlrpc.list_errata(channel))
                if len(errata - channel_errata) != 0:
                    print ("Error: all errata specified with --errata must "
                           + "exist in every original channel cloned in "
                           + "this operation.")
                    print ("Channel %s does not contain these errata: %s" %
                           (channel, errata - channel_errata))
                    sys.exit(1)
#.........这里部分代码省略.........
开发者ID:mantel,项目名称:spacewalk,代码行数:101,代码来源:cloneByDate.py


示例16: __init__

 def __init__(self):
     # Init log to stderr
     initLOG()
     self.start_time = 0
     self._cleanup()
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:5,代码来源:satexport.py


示例17: len

#
import sys

if len(sys.argv) != 3:
    print "Usage: %s server_id action_id" % sys.argv[0]
    sys.exit(1)

system_id = sys.argv[1]
action_id = sys.argv[2]

from spacewalk.common.rhnLog import initLOG
from spacewalk.server import rhnSQL

from spacewalk.server.action_extra_data import packages

initLOG("stderr", 4)
rhnSQL.initDB("rhnuser/[email protected]")

try:
    packages.verify(system_id, action_id, {
        'verify_info': [
            [['up2date', '2.9.1', '1.2.1AS', '', 'i386'], [
                'SM5..UGT c /etc/sysconfig/rhn/up2date',
                '..?..... c /etc/sysconfig/rhn/up2date-keyring.gpg',
                'S.5....T   /usr/share/rhn/up2date_client/bootloadercfg.pyc',
                'S.5....T   /usr/share/rhn/up2date_client/capabilities.pyc',
                'S.5....T   /usr/share/rhn/up2date_client/checkbootloader.pyc',
                'S.5....T   /usr/share/rhn/up2date_client/clap.pyc',
                'S.5....T   /usr/share/rhn/up2date_client/clientCaps.pyc',
                'SM5....T   /usr/share/rhn/up2date_client/config.pyc',
                'S.5....T   /usr/share/rhn/up2date_client/depSolver.pyc',
开发者ID:flavio,项目名称:spacewalk,代码行数:31,代码来源:test_action_rpm_verify_extra_data.py


示例18: __init__

    def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False,
                 log_level=None, mount_point=None, consider_full=False):

        self.cdn_repository_manager = CdnRepositoryManager(mount_point)
        self.no_packages = no_packages
        self.no_errata = no_errata
        self.no_rpms = no_rpms
        self.no_kickstarts = no_kickstarts
        if log_level is None:
            log_level = 0
        self.log_level = log_level

        if mount_point:
            self.mount_point = "file://" + mount_point
            self.consider_full = consider_full
        else:
            self.mount_point = CFG.CDN_ROOT
            self.consider_full = True

        CFG.set('DEBUG', log_level)
        rhnLog.initLOG(self.log_path, self.log_level)
        log2disk(0, "Command: %s" % str(sys.argv))

        rhnSQL.initDB()
        initCFG('server.satellite')

        verify_mappings()

        f = None
        # try block in try block - this is hack for python 2.4 compatibility
        # to support finally
        try:
            try:
                # Channel families mapping to channels
                f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r')
                self.families = json.load(f)
                f.close()

                # Channel metadata
                f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r')
                self.channel_metadata = json.load(f)
                f.close()

                # Dist/Release channel mapping
                f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r')
                self.channel_dist_mapping = json.load(f)
                f.close()

                # Kickstart metadata
                f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r')
                self.kickstart_metadata = json.load(f)
                f.close()
            except IOError:
                e = sys.exc_info()[1]
                raise CdnMappingsLoadError("Problem with loading file: %s" % e)
        finally:
            if f is not None:
                f.close()

        # Map channels to their channel family
        self.channel_to_family = {}
        for family in self.families:
            for channel in self.families[family]['channels']:
                self.channel_to_family[channel] = family

        # Set already synced channels
        h = rhnSQL.prepare("""
            select label from rhnChannel where org_id is null
        """)
        h.execute()
        channels = h.fetchall_dict() or []
        self.synced_channels = [ch['label'] for ch in channels]
开发者ID:shastah,项目名称:spacewalk,代码行数:72,代码来源:cdnsync.py


示例19: main

def main(options):
    xmlrpc = RemoteApi(options.server, options.username, options.password)
    db = DBApi()
    initCFG('server')
    rhnLog.initLOG(LOG_LOCATION)

    cleansed = vars(options)
    cleansed["password"] = "*****"
    log_clean(0, "")
    log_debug(0, "Started spacewalk-clone-by-date")
    log_clean(0, pprint.pformat(cleansed))


    print "Reading repository information."
    if options.use_update_date:
        options.use_update_date = 'update_date'
    else:
        options.use_update_date = 'issue_date'
    print "Using %s." % options.use_update_date

    cloners = []
    needed_channels = []
    errata = None
    if options.errata:
        errata = set(options.errata)
    for channel_list in options.channels:
        # before we start make sure we can get repodata for all channels
        # involved.
        channel_labels = channel_list.keys()
        for label in channel_labels:
            if not os.path.exists(repodata(label)):
                raise UserRepoError(label)

        # if cloning specific errata validate that they actually exist
        # in the original channels
        if options.errata:
            for channel in channel_labels:
                channel_errata = set(xmlrpc.list_errata(channel))
                if len(errata - channel_errata) != 0:
                    print ("Error: all errata specified with --errata must "
                            + "exist in every original channel cloned in "
                            + "this operation.")
                    print ("Channel %s does not contain these errata: %s" %
                            (channel, errata - channel_errata))
                    sys.exit(1)

        if options.parents:
            tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db,
                    options.to_date, options.blacklist,
                    options.removelist, options.background,
                    options.security_only, options.use_update_date,
                    options.no_errata_sync, errata, options.parents)
        else:
            tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db,
                    options.to_date, options.blacklist,
                    options.removelist, options.background,
                    options.security_only,options.use_update_date,
                    options.no_errata_sync, errata)

        cloners.append(tree_cloner)
        needed_channels += tree_cloner.needing_create().values()


    if options.validate:
        if len(needed_channels) > 0:
            raise UserError("Cannot validate channels that do not exist %s" %
                    ', '.join(map(str, needed_channels)))
        for channel_list in options.channels:
            validate(channel_list.values())
        return


    if len(needed_channels) > 0:
        print "\nBy continuing the following channels will be created: "
        print ", ".join(needed_channels)
        confirm("\nContinue with channel creation (y/n)?", options)
        for cloner in cloners:
            cloner.create_channels(options.skip_depsolve)

    for tree_cloner in cloners:
        tree_cloner.prepare()

    print "\nBy continuing the following will be cloned:"
    total = 0
    for cloner in cloners:
        cloner.pre_summary()
        total += cloner.pending()

    if total == 0:
        print ("\nNo errata to clone, checking removelist.")
        for cloner in cloners:
            cloner.remove_packages()
        sys.exit(0)

    confirm("\nContinue with clone (y/n)?", options)
    for cloner in cloners:
        cloner.clone(options.skip_depsolve)
        cloner.remove_packages()
开发者ID:cesan3,项目名称:spacewalk,代码行数:98,代码来源:cloneByDate.py


示例20: __init__

    def __init__(self, channel_label, repo_type, url=None, fail=False,
                 filters=None, no_errata=False, sync_kickstart=False, latest=False,
                 metadata_only=False, strict=0, excluded_urls=None, no_packages=False,
                 log_dir="reposync", log_level=None):
        self.regen = False
        self.fail = fail
        self.filters = filters or []
        self.no_packages = no_packages
        self.no_errata = no_errata
        self.sync_kickstart = sync_kickstart
        self.latest = latest
        self.metadata_only = metadata_only
        self.ks_tree_type = 'externally-managed'
        self.ks_install_type = 'generic_rpm'

        initCFG('server.satellite')
        rhnSQL.initDB()

        # setup logging
        log_filename = channel_label + '.log'
        log_path = default_log_location + log_dir + '/' + log_filename
        if log_level is None:
            log_level = 0
        CFG.set('DEBUG', log_level)
        rhnLog.initLOG(log_path, log_level)
        # os.fchown isn't in 2.4 :/
        if isSUSE():
            os.system("chgrp www " + log_path)
        else:
            os.system("chgrp apache " + log_path)

        log2disk(0, "Command: %s" % str(sys.argv))
        log2disk(0, "Sync of channel started.")

        self.channel_label = channel_label
        self.channel = self.load_channel()
        if not self.channel:
            log(0, "Channel %s does not exist." % channel_label)

        if not url:
            # TODO:need to look at user security across orgs
            h = rhnSQL.prepare("""select s.id, s.source_url, s.label, fm.channel_family_id
                                  from rhnContentSource s,
                                       rhnChannelContentSource cs,
                                       rhnChannelFamilyMembers fm
                                 where s.id = cs.source_id
                                   and cs.channel_id = fm.channel_id
                                   and cs.channel_id = :channel_id""")
            h.execute(channel_id=int(self.channel['id']))
            source_data = h.fetchall_dict()
            self.urls = []
            if excluded_urls is None:
                excluded_urls = []
            if source_data:
                for row in source_data:
                    if row['source_url'] not in excluded_urls:
                        self.urls.append((row['id'], row['source_url'], row['label'], row['channel_family_id']))
        else:
            self.urls = [(None, u, None, None) for u in url]

        if not self.urls:
            log2stderr(0, "Channel %s has no URL associated" % channel_label)

        self.repo_plugin = self.load_plugin(repo_type)
        self.strict = strict
        self.all_packages = []
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:66,代码来源:reposync.py



注:本文中的spacewalk.common.rhnLog.initLOG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rhnLog.log_clean函数代码示例发布时间:2022-05-27
下一篇:
Python rhnLib.timestamp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap