当前位置: 首页>>代码示例>>Python>>正文


Python common.log_error函数代码示例

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


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

示例1: __getXmlrpcServer

    def __getXmlrpcServer(self):
        """ get an xmlrpc server object
        
            WARNING: if CFG.USE_SSL is off, we are sending info
                     in the clear. 
        """
        log_debug(3)

        # build the URL
        url = CFG.RHN_PARENT or ''
        url = string.split(parseUrl(url)[1], ':')[0]
        if CFG.USE_SSL:
            url = 'https://' + url  + '/XMLRPC'
        else:
            url = 'http://' + url  + '/XMLRPC'
        log_debug(3, 'server url: %s' % url)

        if CFG.HTTP_PROXY:
            serverObj = rpclib.Server(url,
                                      proxy=CFG.HTTP_PROXY,
                                      username=CFG.HTTP_PROXY_USERNAME,
                                      password=CFG.HTTP_PROXY_PASSWORD)
        else:
            serverObj = rpclib.Server(url)
        if CFG.USE_SSL and CFG.CA_CHAIN:
            if not os.access(CFG.CA_CHAIN, os.R_OK):
                log_error('ERROR: missing or cannot access (for ca_chain): %s' % CFG.CA_CHAIN)
                raise rhnFault(1000,
                          _("RHN Proxy error (file access issues). "
                            "Please contact your system administrator. "
                            "Please refer to RHN Proxy logs."))
            serverObj.add_trusted_cert(CFG.CA_CHAIN)
        serverObj.add_header('X-RHN-Client-Version', 2)
        return serverObj
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:34,代码来源:rhnProxyAuth.py

示例2: getPackagePath

    def getPackagePath(self, pkgFilename):
        """ OVERLOADS getPackagePath in common/rhnRepository.
            Returns complete path to an RPM file.
        """

        log_debug(3, pkgFilename)
        mappingName = "package_mapping:%s:" % self.channelName
        pickledMapping = self._cacheObj(mappingName, self.channelVersion, self.__channelPackageMapping, ())

        mapping = cPickle.loads(pickledMapping)

        # If the file name has parameters, it's a different kind of package.
        # Determine the architecture requested so we can construct an
        # appropriate filename.
        if type(pkgFilename) == types.ListType:
            arch = pkgFilename[3]
            if isSolarisArch(arch):
                pkgFilename = "%s-%s-%s.%s.pkg" % (pkgFilename[0], pkgFilename[1], pkgFilename[2], pkgFilename[3])

        if not mapping.has_key(pkgFilename):
            log_error("Package not in mapping: %s" % pkgFilename)
            raise rhnFault(17, _("Invalid RPM package requested: %s") % pkgFilename)
        filePath = "%s/%s" % (CFG.PKG_DIR, mapping[pkgFilename])
        log_debug(4, "File path", filePath)
        if not os.access(filePath, os.R_OK):
            log_debug(4, "Package not found locally: %s" % pkgFilename)
            raise NotLocalError(filePath, pkgFilename)
        return filePath
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:28,代码来源:rhnRepository.py

示例3: token_server_groups

def token_server_groups(server_id, tokens_obj):
    assert(isinstance(tokens_obj, ActivationTokens))
    h = rhnSQL.prepare(_query_token_server_groups)
    server_groups = {}
    for token in tokens_obj.tokens:
        token_id = token['token_id']
        h.execute(token_id=token_id)
        while 1:
            row = h.fetchone_dict()
            if not row:
                break
            server_group_id = row['server_group_id']
            server_groups[server_group_id] = row

    # Now try to subscribe server to group
    ret = []
    for server_group_id, sg in server_groups.items():
        log_debug(4, "token server group", sg)
        
        try:
            join_server_group(server_id, server_group_id)
        except rhnSQL.SQLError, e:
            log_error("Failed to add server to group", server_id,
                      server_group_id, sg["name"])
            raise rhnFault(80, _("Failed to add server to group %s") % 
                sg["name"])
        else:
            ret.append("Subscribed to server group '%s'" % sg["name"])
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:28,代码来源:server_token.py

示例4: _handleServerResponse

    def _handleServerResponse(self, status):
        """ This method can be overridden by subclasses who want to handle server
            responses in their own way.  By default, we will wrap all the headers up
            and send them back to the client with an error status.  This method
            should return apache.OK if everything went according to plan.
        """
        if (status != apache.HTTP_OK) and (status != apache.HTTP_PARTIAL_CONTENT):
            # Non 200 response; have to treat it differently
            log_debug(2, "Forwarding status %s" % status)
            # Copy the incoming headers to err_headers_out
            headers = self.responseContext.getHeaders()
            if headers is not None:
                for k in headers.keys():
                    rhnLib.setHeaderValue(self.req.err_headers_out, k,
                        self._get_header(k))
            else:
                log_error('WARNING? - no incoming headers found!')
            # And that's that
            return status

        if (status == apache.HTTP_PARTIAL_CONTENT):
            return apache.HTTP_PARTIAL_CONTENT
        else:
            # apache.HTTP_OK becomes apache.OK.
            return apache.OK
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:25,代码来源:rhnShared.py

示例5: guest_registered

    def guest_registered(self, host_sid, guest_sid):
        host_system_slots = server_lib.check_entitlement(host_sid)
        host_system_slots = host_system_slots.keys()

        try:
            host_system_slots.remove("virtualization_host")
        except ValueError:
            pass
        try:
            host_system_slots.remove("virtualization_host_platform")
        except ValueError:
            pass

        guest_system_slots = server_lib.check_entitlement(guest_sid)
        guest_system_slots = guest_system_slots.keys()

        for entitlement in host_system_slots:
            if entitlement not in guest_system_slots:
                try:
                    procedure.rhn_entitlements.entitle_server(guest_sid,
                            entitlement)
                except rhnSQL.SQLError, e:
                    log_error("Error adding entitlement %s: %s"
                            % (entitlement, str(e)))
                    # rhnSQL.rollback()
                    return
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:26,代码来源:rhnVirtualization.py

示例6: _transformKickstartRequestForBroker

    def _transformKickstartRequestForBroker(self, req):

        # Get the checksum for the requested resource from the satellite.

        (status, checksum) = self._querySatelliteForChecksum(req)
        if status != apache.OK or not checksum:
            return status

        # If we got this far, we have the checksum.  Create a new URI based on
        # the checksum.

        newURI = self._generateCacheableKickstartURI(req.uri, checksum)
        if not newURI:
            # Couldn't create a cacheable URI, log an error and revert to 
            # BZ 158236 behavior.

            log_error('Could not create cacheable ks URI from "%s"' % req.uri)
            return apache.OK

        # Now we must embed the old URI into a header in the original request
        # so that the SSL Redirect has it available if the resource has not 
        # been cached yet.  We will also embed a header that holds the new URI,
        # so that the content handler can use it later.

        log_debug(3, "Generated new kickstart URI: %s" % newURI)
        req.headers_in.add(HEADER_ACTUAL_URI, req.uri)
        req.headers_in.add(HEADER_EFFECTIVE_URI, newURI)

        return apache.OK
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:29,代码来源:apacheHandler.py

示例7: entitle

    def entitle(self, server_id, history, virt_type = None):
        """
        Entitle a server according to the entitlements we have configured.
        """
        log_debug(3, self.entitlements)

        entitle_server = rhnSQL.Procedure("rhn_entitlements.entitle_server")
        # TODO: entitle_server calls can_entitle_server, so we're doing this
        # twice for each successful call. Is it necessary for external error
        # handling or can we ditch it?
        can_entitle_server = rhnSQL.Function(
                "rhn_entitlements.can_entitle_server", rhnSQL.types.NUMBER())

        can_ent = None

        history["entitlement"] = ""

        # Do a quick check to see if both virt entitlements are present. (i.e.
        # activation keys stacked together) If so, give preference to the more
        # powerful virtualization platform and remove the regular virt 
        # entitlement from the list.
        found_virt = False
        found_virt_platform = False
        for entitlement in self.entitlements:
            if entitlement[0] == VIRT_ENT_LABEL:
                found_virt = True
            elif entitlement[0] == VIRT_PLATFORM_ENT_LABEL:
                found_virt_platform = True
          
        for entitlement in self.entitlements:
            if virt_type is not None and entitlement[0] in \
                    (VIRT_ENT_LABEL, VIRT_PLATFORM_ENT_LABEL):
                continue

            # If both virt entitlements are present, skip the least powerful:
            if found_virt and found_virt_platform and entitlement[0] == VIRT_ENT_LABEL:
                log_debug(1, "Virtualization and Virtualization Platform " +
                        "entitlements both present.")
                log_debug(1, "Skipping Virtualization.")
                continue

            try:
                 can_ent = can_entitle_server(server_id, entitlement[0])
            except rhnSQL.SQLSchemaError, e:
                 can_ent = 0

            try:
                # bugzilla #160077, skip attempting to entitle if we cant
                if can_ent:
                    entitle_server(server_id, entitlement[0])
            except rhnSQL.SQLSchemaError, e:
                log_error("Token failed to entitle server", server_id,
                          self.get_names(), entitlement[0], e.errmsg)
                if e.errno == 20220:
                    #ORA-20220: (servergroup_max_members) - Server group membership
                    #cannot exceed maximum membership
                    raise rhnFault(91, 
                        _("Registration failed: RHN Software Management service entitlements exhausted"))
                #No idea what error may be here...
                raise rhnFault(90, e.errmsg)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:60,代码来源:server_token.py

示例8: reload

 def reload(self, server, reload_all = 0):
     log_debug(4, server, "reload_all = %d" % reload_all)
     
     if not self.server.load(int(server)):
         log_error("Could not find server record for reload", server)
         raise rhnFault(29, "Could not find server record in the database")
     self.cert = None
     # it is lame that we have to do this
     h = rhnSQL.prepare("""
     select label from rhnServerArch where id = :archid
     """)
     h.execute(archid = self.server["server_arch_id"])
     data = h.fetchone_dict()
     if not data:
         raise rhnException("Found server with invalid numeric "
                            "architecture reference",
                            self.server.data)
     self.archname = data['label']
     # we don't know this one anymore (well, we could look for, but
     # why would we do that?)
     self.user = None
     
     # XXX: Fix me
     if reload_all:
         if not self.reload_packages_byid(self.server["id"]) == 0:
             return -1
         if not self.reload_hardware_byid(self.server["id"]) == 0:
             return -1       
     return 0
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:29,代码来源:server_class.py

示例9: process

    def process(self):
        log_debug(3)
        # nice thing that req has a read() method, so it makes it look just
        # like an fd
        try:
            fd = self.input.decode(self.req)
        except IOError: # client timed out
            return apache.HTTP_BAD_REQUEST

        # Read the data from the request
        _body = fd.read()
        fd.close()

        # In this case, we talk to a client (maybe through a proxy)
        # make sure we have something to decode
        if _body is None or len(_body) == 0:
            return apache.HTTP_BAD_REQUEST

        # Decode the request; avoid logging crappy responses
        try:
            params, method = self.decode(_body)
        except rpclib.ResponseError:
            log_error("Got bad XML-RPC blob of len = %d" % len(_body))
            return apache.HTTP_BAD_REQUEST
        else:
            if params is None:
                params = ()
        # make the actual function call and return the result
        return self.call_function(method, params)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:29,代码来源:apacheRequest.py

示例10: auth_system

 def auth_system(self, system_id):
     """ System authentication. We override the standard function because
         we need to check additionally if this system_id is entitled for
         proxy functionality.
     """
     log_debug(3)        
     server = rhnHandler.auth_system(self, system_id)
     # if it did not blow up, we have a valid server. Check proxy
     # entitlement.
     # XXX: this needs to be moved out of the rhnServer module,
     # possibly in here
     h = rhnSQL.prepare("""
     select 1
     from rhnProxyInfo pi
     where pi.server_id = :server_id
     """)
     h.execute(server_id = self.server_id)
     row = h.fetchone_dict()
     if not row:
         # we require entitlement for this functionality
         log_error("Server not entitled for Proxy", self.server_id)
         raise rhnFault(1002, _(
             'RHN Proxy service not enabled for server profile: "%s"')
                        % server.server["name"])
     # we're fine...
     return server
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:26,代码来源:proxy.py

示例11: _init_request_processor

 def _init_request_processor(self, req):
     log_debug(3)
     # Override the parent class's behaviour
     # figure out what kind of request handler we need to instantiate
     if req.method == "POST":
         self._req_processor = apachePOST(self.clientVersion, req)
         return apache.OK
     if req.method == "GET":
         try:
             self._req_processor = apacheGET(self.clientVersion, req)
         except HandlerNotFoundError, e:
             log_error("Unable to handle GET request for server %s" %
                 (e.args[0], ))
             return apache.HTTP_METHOD_NOT_ALLOWED
         # We want to give the request processor the ability to override
         # the default behaviour of calling _setSessionToken
         # XXX This is a but kludgy - misa 20040827
         if hasattr(self._req_processor, 'init_request'):
             if not self._req_processor.init_request():
                 return apache.HTTP_METHOD_NOT_ALLOWED
             # Request initialized
             return apache.OK
         token = self._setSessionToken(req.headers_in)
         if token is None:
             return apache.HTTP_METHOD_NOT_ALLOWED
         return apache.OK
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:26,代码来源:apacheHandler.py

示例12: _connectToParent

    def _connectToParent(self):
        """ Handler part 1
            Should not return an error code -- simply connects.
        """

        scheme, host, port, self.uri = self._parse_url(self.rhnParent)
        self.responseContext.setConnection(self._create_connection())

        if not self.uri:
            self.uri = '/'

        log_debug(3, 'Scheme:', scheme)
        log_debug(3, 'Host:', host)
        log_debug(3, 'Port:', port)
        log_debug(3, 'URI:', self.uri)
        log_debug(3, 'HTTP proxy:', self.httpProxy)
        log_debug(3, 'HTTP proxy username:', self.httpProxyUsername)
        log_debug(3, 'HTTP proxy password:', "<password>")
        log_debug(3, 'CA cert:', self.caChain)

        try:
            self.responseContext.getConnection().connect()
        except socket.error, e:
            log_error("Error opening connection", self.rhnParent, e)
            Traceback(mail=0)
            raise rhnFault(1000,
              _("RHN Proxy could not successfully connect its RHN parent. "
                "Please contact your system administrator."))
开发者ID:pombredanne,项目名称:spacewalk-1,代码行数:28,代码来源:rhnShared.py

示例13: guest_migrated

 def guest_migrated(self, old_host_sid, new_host_sid, guest_sid, guest_uuid):
     try:
         procedure.rhn_entitlements.repoll_virt_guest_entitlements(new_host_sid)
     except rhnSQL.SQLError, e:
         log_error("Error adding entitlement: %s" %str(e))
         # rhnSQL.rollback()
         return
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:7,代码来源:rhnVirtualization.py

示例14: 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:bjmingyang,项目名称:spacewalk,代码行数:27,代码来源:apacheUploadServer.py

示例15: check_connection

 def check_connection(self):
     try:
         c = self.prepare("select 1")
         c.execute()
     except: # try to reconnect, that one MUST WORK always
         log_error("DATABASE CONNECTION TO '%s' LOST" % self.database,
                   "Exception information: %s" % sys.exc_info()[1])
         self.connect() # only allow one try
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:8,代码来源:driver_postgresql.py


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