コード例 #1
0
ファイル: satexport.py プロジェクト: pombredanne/spacewalk-1
 def cleanupHandler(self, req):
     self._timer()
     retval = self._wrapper(req, self._cleanupHandler)
     self._cleanup()
     # Reset the logger to stderr
     initLOG()
     return retval
コード例 #2
0
 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")
コード例 #3
0
 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
コード例 #4
0
    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
コード例 #5
0
ファイル: apacheHandler.py プロジェクト: bjmingyang/spacewalk
    def headerParserHandler(self, 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
コード例 #6
0
    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)
        except:
            Traceback(self.__name, req, extra = "Unhandled exception type",
                      severity="unhandled")
            return apache.HTTP_INTERNAL_SERVER_ERROR
        else:
            return ret
コード例 #7
0
ファイル: satexport.py プロジェクト: pombredanne/spacewalk-1
    def headerParserHandler(self, req):
        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 not options.has_key("RHNComponentType"):
            # 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
            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(CFG.DEFAULT_DB)
        self.server = options["SERVER"]

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

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

        return self._wrapper(req, self._headerParserHandler)
コード例 #8
0
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
# 
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation. 
#
from spacewalk.server import rhnSQL
from spacewalk.common import initCFG, initLOG
from spacewalk.server.xmlrpc import queue

initLOG("stderr", 4)
initCFG('server.xmlrpc')
rhnSQL.initDB('rhnuser/rhnuser@webdev')

q = queue.Queue()
if 1:
    systemid = open("../../test/backend/checks/systemid-farm06").read()
    print q.get(systemid, version=2)
else:
    q.server_id = 1003485791

    q._invalidate_failed_prereq_actions()

#rhnSQL.rollback()
rhnSQL.commit()
コード例 #9
0
ファイル: rhnPackage.py プロジェクト: bjmingyang/spacewalk
    else:
        h.execute(name = pkg[0], ver = pkg[1], rel = pkg[2], arch = pkg[4], epoch=pkg[3], label = channel_label)

    ret = h.fetchone_dict()
    if not ret:
        return None
    return ret['path']


def _none2emptyString(foo):
    if foo is None:
        return ""
    return str(foo)

if __name__ == '__main__':
    """Test code.
    """
    from spacewalk.common import initLOG
    initLOG("stdout", 1)
    rhnSQL.initDB('rhnuser/rhnuser@webqa')
    print
    # new client
    print get_package_path(1000463284, 'kernel-2.4.2-2.i686.rpm', 'redhat-linux-i386-7.1')
    print get_package_path_compat_arches(1000463284, ['kernel', '2.4.2', '2', ''], 'i686')
    print get_source_package_path(1000463284, 'kernel-2.4.2-2.i686.rpm', 'redhat-linux-i386-7.1')
    
    # old client
    print get_source_package_path_by_nvre(1000463284, ['kernel', '2.4.2', '2', ''])
    print get_source_package_path_by_name(1000463284, 'kernel-2.4.2-2.src.rpm')
    
コード例 #10
0
ファイル: satexport.py プロジェクト: pombredanne/spacewalk-1
 def __init__(self):
     # Init log to stderr
     initLOG()
     self.start_time = 0
     self._cleanup()
コード例 #11
0
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
from spacewalk.common import CFG, initCFG, initLOG
from spacewalk.server import rhnSQL
from syncCache import SyncCache
from syncContainerHandlers import processErrata


initCFG("server.satellite")
initLOG(CFG.LOG_FILE, CFG.DEBUG)
rhnSQL.initDB("satuser/satuser@satdev")

cache = SyncCache().init()
cache.addChannelsState(["redhat-linux-i386-8.0"])
cache.setChannelState("redhat-linux-i386-8.0")
# print cache.getCurrentChannelState()
# print cache.getChannelsState()
# print cache._sat_shtPkgCache.keys()
# print cache.getChnEids(cache.getCurrentChannelState())
processErrata()