Example #1
0
    def __init__(self, cfg, server, nodeInfo, chroots, messageBusInfo=None):
        # Create a nodeType describing this client that will be passed
        # to the message bus and made available to interested listeners
        # (like the dispatcher)
        node = nodetypes.WorkerNode(name=cfg.name,
                                    host=cfg.hostName,
                                    slots=cfg.slots,
                                    jobTypes=cfg.jobTypes,
                                    buildFlavors=cfg.buildFlavors,
                                    loadThreshold=cfg.loadThreshold,
                                    nodeInfo=nodeInfo,
                                    chroots=chroots,
                                    chrootLimit=cfg.chrootLimit)

        # grab the message bus location from the rmake server.
        rmakeClient = client.rMakeClient(cfg.rmakeUrl)
        if not messageBusInfo:
            messageBus = None
            while not messageBus:
                try:
                    messageBus = rmakeClient.getMessageBusInfo()
                except errors.UncatchableExceptionClasses, e:
                    raise
                except Exception, e:
                    server.error(
                        'Could not contact rmake server at %r - waiting 5 seconds and retrying.',
                        cfg.rmakeUrl)
                if not messageBus:
                    time.sleep(5)
Example #2
0
    def __init__(self, cfg, server, nodeInfo, chroots, messageBusInfo=None):
        # Create a nodeType describing this client that will be passed
        # to the message bus and made available to interested listeners
        # (like the dispatcher)
        node = nodetypes.WorkerNode(name=cfg.name,
                                    host=cfg.hostName,
                                    slots=cfg.slots,
                                    jobTypes=cfg.jobTypes,
                                    buildFlavors=cfg.buildFlavors,
                                    loadThreshold=cfg.loadThreshold,
                                    nodeInfo=nodeInfo, chroots=chroots,
                                    chrootLimit=cfg.chrootLimit)

        # grab the message bus location from the rmake server.
        rmakeClient = client.rMakeClient(cfg.rmakeUrl)
        if not messageBusInfo:
            messageBus = None
            while not messageBus:
                try:
                    messageBus = rmakeClient.getMessageBusInfo()
                except errors.UncatchableExceptionClasses, e:
                    raise
                except Exception, e:
                    server.error('Could not contact rmake server at %r - waiting 5 seconds and retrying.', cfg.rmakeUrl)
                if not messageBus:
                    time.sleep(5)
Example #3
0
 def _setAndCheckPassword(self, cfg, passwd):
     old = cfg.rmakeUser
     cfg.rmakeUser = (old[0], passwd)
     cli = client.rMakeClient(cfg.getServerUri())
     try:
         cli.ping(seconds=0.01)
     except errors.InsufficientPermission:
         cfg.rmakeUser = old
         return False
     else:
         return True
Example #4
0
 def _setAndCheckPassword(self, cfg, passwd):
     old = cfg.rmakeUser
     cfg.rmakeUser = (old[0], passwd)
     cli = client.rMakeClient(cfg.getServerUri())
     try:
         cli.ping(seconds=0.01)
     except errors.InsufficientPermission:
         cfg.rmakeUser = old
         return False
     else:
         return True
Example #5
0
    def testMultipleContexts(self):
        config = """
[nossl]
buildFlavor !ssl
"""
        repos = self.openRepository()
        trv = self.addComponent('testcase:source', '1.0-1', '',
                                [('testcase.recipe', 
                                  basicRecipe + '\tif Use.ssl:pass')])

        self.openRmakeRepository()
        self.writeFile(self.workDir + '/config', config)
        self.buildCfg.read(self.workDir + '/config')

        uri = 'unix://%s/socket' % self.rootDir
        self.buildCfg.strictMode = True
        srv = server.rMakeServer(#None,
                    uri,
                    self.rmakeCfg,
                    None, quiet=True)

        rmakeClient = client.rMakeClient(uri)

        pid = os.fork()
        if pid:
            srv._close()
            try:
                helper = self.getRmakeHelper(rmakeClient.uri)
                troveSpec = '%s=%s[%s]' % trv.getNameVersionFlavor()
                troveSpec2 = '%s=%s[%s]{nossl}' % trv.getNameVersionFlavor()
                jobId = helper.buildTroves([troveSpec, troveSpec2])
                buildCfg = rmakeClient.getJobConfig(jobId)
                self.assertEquals(buildCfg.buildTroveSpecs, [cmdline.parseTroveSpec(troveSpec)])
                helper.waitForJob(jobId)
                job = helper.getJob(jobId)
                # make sure a trove can actually be found
                if job.isFailed():
                    raise RuntimeError('Job Failed: %s' % job.getFailureReason())
                trvs = job.findTrovesWithContext(None, 
                                        [('testcase:source', None, None, None)])
                assert(len(trvs) == 1)
                self.assertEquals(len(trvs.values()[0]), 2)
            finally:
                os.kill(pid, signal.SIGTERM)
                self.waitThenKill(pid)
        else:
            try:
                sys.stdin = open('/dev/null')
                lf = logfile.LogFile(self.rootDir + '/srv.log')
                lf.redirectOutput()
                srv.serve_forever()
            finally:
                os._exit(1)
Example #6
0
    def testBasic(self):
        repos = self.openRepository()
        trv = self.addComponent('testcase:source', '1.0-1', '',
                                [('testcase.recipe', basicRecipe)])


        self.openRmakeRepository()
        uri = 'unix://%s/socket' % self.rootDir
        srv = server.rMakeServer(#None,
                uri,
                self.rmakeCfg,
                None, quiet=True)
        self.buildCfg.uuid = self.genUUID('foo')
        self.buildCfg.strictMode = True
        #client = server.rMakeClient(srv)
        #client = server.rMakeClient('http://*****:*****@local:linux', None),
                                self.buildCfg.flavor)
            finally:
                os.kill(pid, signal.SIGTERM)
                self.waitThenKill(pid)
        else:
            try:
                sys.stdin = open('/dev/null')
                lf = logfile.LogFile(self.rootDir + '/srv.log')
                lf.redirectOutput()
                srv.serve_forever()
            finally:
                os._exit(1)
Example #7
0
 def _failJob(self, jobId, reason):
     pid = self._fork('Fail job %s' % jobId)
     if pid:
         self.debug('Fail job %s forked pid %d' % (jobId, pid))
         return
     try:
         from rmake.server.client import rMakeClient
         client = rMakeClient(self.uri)
         # make sure the main process is up and running before we
         # try to communicate w/ it
         client.ping()
         job = self.db.getJob(jobId)
         self._subscribeToJob(job)
         publisher = job.getPublisher()
         job.own()
         job.jobFailed(reason)
         os._exit(0)
     except:
         self.exception('Error stopping job %s' % jobId)
         os._exit(1)
Example #8
0
 def _failJob(self, jobId, reason):
     pid = self._fork('Fail job %s' % jobId)
     if pid:
         self.debug('Fail job %s forked pid %d' % (jobId, pid))
         return
     try:
         from rmake.server.client import rMakeClient
         client = rMakeClient(self.uri)
         # make sure the main process is up and running before we 
         # try to communicate w/ it
         client.ping()
         job = self.db.getJob(jobId)
         self._subscribeToJob(job)
         publisher = job.getPublisher()
         job.own()
         job.jobFailed(reason)
         os._exit(0)
     except:
         self.exception('Error stopping job %s' % jobId)
         os._exit(1)
Example #9
0
 def _failCurrentJobs(self, jobs, reason):
     if self.uri is None:
         self.warning('Cannot fail current jobs without a URI')
         return False
     from rmake.server.client import rMakeClient
     pid = self._fork('Fail current jobs')
     if pid:
         self.debug('Fail current jobs forked pid %d' % pid)
         return
     try:
         client = rMakeClient(self.uri)
         # make sure the main process is up and running before we
         # try to communicate w/ it
         client.ping()
         for job in jobs:
             self._subscribeToJob(job)
             publisher = job.getPublisher()
             job.jobFailed(reason)
         os._exit(0)
     except:
         self.exception('Error stopping current jobs')
         os._exit(1)
Example #10
0
 def _failCurrentJobs(self, jobs, reason):
     if self.uri is None:
         self.warning('Cannot fail current jobs without a URI')
         return False
     from rmake.server.client import rMakeClient
     pid = self._fork('Fail current jobs')
     if pid:
         self.debug('Fail current jobs forked pid %d' % pid)
         return
     try:
         client = rMakeClient(self.uri)
         # make sure the main process is up and running before we 
         # try to communicate w/ it
         client.ping()
         for job in jobs:
             self._subscribeToJob(job)
             publisher = job.getPublisher()
             job.jobFailed(reason)
         os._exit(0)
     except:
         self.exception('Error stopping current jobs')
         os._exit(1)
Example #11
0
    def __init__(self, uri=None, rmakeConfig=None, buildConfig=None, root='/',
                 plugins=None, configureClient=True,
                 clientCert=None, promptPassword=False):
        if rmakeConfig:
            log.warning('rmakeConfig parameter is now deprecated')
        if not buildConfig:
            buildConfig = buildcfg.BuildConfiguration(True, root)

        if configureClient:
            if clientCert is None:
                clientCert = buildConfig.clientCert
            if uri is None:
                if (promptPassword and buildConfig.rmakeUser
                        and buildConfig.rmakeUser[0]
                        and not buildConfig.rmakeUser[1]
                        and not clientCert):
                    self._promptPassword(buildConfig)
                uri = buildConfig.getServerUri()

            self.client = client.rMakeClient(uri, clientCert)

        self.buildConfig = buildConfig
        self.plugins = plugins
Example #12
0
    def __init__(self, uri=None, rmakeConfig=None, buildConfig=None, root='/',
                 plugins=None, configureClient=True,
                 clientCert=None, promptPassword=False):
        if rmakeConfig:
            log.warning('rmakeConfig parameter is now deprecated')
        if not buildConfig:
            buildConfig = buildcfg.BuildConfiguration(True, root)

        if configureClient:
            if clientCert is None:
                clientCert = buildConfig.clientCert
            if uri is None:
                if (promptPassword and buildConfig.rmakeUser
                        and buildConfig.rmakeUser[0]
                        and not buildConfig.rmakeUser[1]
                        and not clientCert):
                    self._promptPassword(buildConfig)
                uri = buildConfig.getServerUri()

            self.client = client.rMakeClient(uri, clientCert)

        self.buildConfig = buildConfig
        self.plugins = plugins