Пример #1
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to application object; passed to all entities.
     :arg config: reference to configuration; passed to all entities.
     :arg str mount: API URL mount point; passed to all entities."""
     
     RESTApi.__init__(self, app, config, mount)
     
     cherrypy.log("ReqMgr entire configuration:\n%s" % Configuration.getInstance())    
     cherrypy.log("ReqMgr REST hub configuration subset:\n%s" % config)
     
     self.db_handler = ReqMgrCouch(config) 
     # Makes raw format as default
     #self.formats.insert(0, ('application/raw', RawFormat()))
     self._add({"hello": HelloWorld(self, app, config, mount),
                "about": Info(app, self, config, mount),
                "info": Info(app, self, config, mount),
                "request": Request(app, self, config, mount),
                "group": Group(app, self, config, mount),
                "team": Team(app, self, config, mount),
                "software": Software(app, self, config, mount),
                "status": RequestStatus(app, self, config, mount),
                "type": RequestType(app, self, config, mount),
                "spec_template": RequestSpec(self, app, config, mount),
                "wmstats_info":WMStatsInfo(self, app, config, mount)
               })
Пример #2
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("WMStats entire configuration:\n%s" %
                     Configuration.getInstance())
        cherrypy.log("WMStats REST hub configuration subset:\n%s" % config)
        # only allows json format for return value
        self.formats = [('application/json', JSONFormat())]
        self._add({
            "info":
            ServerInfo(app, self, config, mount),
            "teams":
            TeamInfo(app, self, config, mount),
            "request":
            RequestInfo(app, self, config, mount),
            "isfinished":
            FinishedStatusInfo(app, self, config, mount),
            "jobdetail":
            JobDetailInfo(app, self, config, mount),
            "requestcache":
            ActiveRequestJobInfo(app, self, config, mount)
        })
Пример #3
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to application object; passed to all entities.
     :arg config: reference to configuration; passed to all entities.
     :arg str mount: API URL mount point; passed to all entities."""
     
     RESTApi.__init__(self, app, config, mount)
     
     cherrypy.log("ReqMgr entire configuration:\n%s" % Configuration.getInstance())    
     cherrypy.log("ReqMgr REST hub configuration subset:\n%s" % config)
     
     self.db_handler = ReqMgrCouch(config) 
     # Makes raw format as default
     #self.formats.insert(0, ('application/raw', RawFormat()))
     self._add({"about": Info(app, self, config, mount),
                "info": Info(app, self, config, mount),
                "request": Request(app, self, config, mount),
                "group": Group(app, self, config, mount),
                "team": Team(app, self, config, mount),
                "software": Software(app, self, config, mount),
                "status": RequestStatus(app, self, config, mount),
                "type": RequestType(app, self, config, mount),
                "spec_template": RequestSpec(self, app, config, mount),
                "workload_config": WorkloadConfig(self, app, config, mount),
                "splitting": WorkloadSplitting(self, app, config, mount),
                "wmstats_info":WMStatsInfo(self, app, config, mount)
               })
Пример #4
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("ReqMgr entire configuration:\n%s" % Configuration.getInstance())
        cherrypy.log("ReqMgr REST hub configuration subset:\n%s" % config)

        # Makes raw format as default
        # self.formats.insert(0, ('application/raw', RawFormat()))
        self._add({"about": Info(app, IndividualCouchManager(config), config, mount),
                   "info": Info(app, IndividualCouchManager(config), config, mount),
                   "app_config": ReqMgrConfigData(app, IndividualCouchManager(config), config, mount),
                   "request": Request(app, IndividualCouchManager(config), config, mount),
                   "cmsswversions": CMSSWVersions(app, IndividualCouchManager(config), config, mount),
                   "wmagentconfig": WMAgentConfig(app, IndividualCouchManager(config), config, mount),
                   "permissions": PermissionsConfig(app, IndividualCouchManager(config), config, mount),
                   "campaignconfig": WMAgentConfig(app, IndividualCouchManager(config), config, mount),
                   "unifiedconfig": UnifiedConfig(app, IndividualCouchManager(config), config, mount),
                   "status": RequestStatus(app, IndividualCouchManager(config), config, mount),
                   "type": RequestType(app, IndividualCouchManager(config), config, mount),
                   "spec_template": RequestSpec(app, IndividualCouchManager(config), config, mount),
                   "workload_config": WorkloadConfig(app, IndividualCouchManager(config), config, mount),
                   "splitting": WorkloadSplitting(app, IndividualCouchManager(config), config, mount),
                   "wmstats_info": WMStatsInfo(app, IndividualCouchManager(config), config, mount),
                   "proc_status": ProcessMatrix(app, self, config, mount)
                  })
Пример #5
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("ReqMgr entire configuration:\n%s" %
                     Configuration.getInstance())
        cherrypy.log("ReqMgr REST hub configuration subset:\n%s" % config)

        # Makes raw format as default
        # self.formats.insert(0, ('application/raw', RawFormat()))
        self._add({
            "about":
            Info(app, IndividualCouchManager(config), config, mount),
            "info":
            Info(app, IndividualCouchManager(config), config, mount),
            "app_config":
            ReqMgrConfigData(app, IndividualCouchManager(config), config,
                             mount),
            "request":
            Request(app, IndividualCouchManager(config), config, mount),
            "cmsswversions":
            CMSSWVersions(app, IndividualCouchManager(config), config, mount),
            "wmagentconfig":
            WMAgentConfig(app, IndividualCouchManager(config), config, mount),
            "permissions":
            PermissionsConfig(app, IndividualCouchManager(config), config,
                              mount),
            "campaignconfig":
            CampaignConfig(app, IndividualCouchManager(config), config, mount),
            "unifiedconfig":
            UnifiedConfig(app, IndividualCouchManager(config), config, mount),
            "transferinfo":
            TransferInfo(app, IndividualCouchManager(config), config, mount),
            "status":
            RequestStatus(app, IndividualCouchManager(config), config, mount),
            "type":
            RequestType(app, IndividualCouchManager(config), config, mount),
            "spec_template":
            RequestSpec(app, IndividualCouchManager(config), config, mount),
            "workload_config":
            WorkloadConfig(app, IndividualCouchManager(config), config, mount),
            "splitting":
            WorkloadSplitting(app, IndividualCouchManager(config), config,
                              mount),
            "wmstats_info":
            WMStatsInfo(app, IndividualCouchManager(config), config, mount),
            "proc_status":
            ProcessMatrix(app, self, config, mount),
            "parentlocks":
            ParentLocks(app, IndividualCouchManager(config), config, mount)
        })
Пример #6
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("WMArchive entire configuration:\n%s" % Configuration.getInstance())
        cherrypy.log("WMArchive REST configuration subset:\n%s" % config)

        self._add({"data": WMAData(app, self, config, mount)})
Пример #7
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("MicroService entire configuration:\n%s" % Configuration.getInstance())
        cherrypy.log("MicroService REST configuration subset:\n%s" % config)

        self._add({"data": Data(app, self, config, mount)})
Пример #8
0
    def testG_testStaticReferenceToConfigurationInstance(self):
        """
        test Configuration.getInstance() which returns reference
        to the Configuration object instance.

        """
        config = Configuration()
        instance = Configuration.getInstance()
        self.assertFalse(hasattr(instance, "testsection"))
        config.section_("testsection")
        self.assertTrue(hasattr(instance, "testsection"))
        config.testsection.var = 10
        self.assertEquals(instance.testsection.var, 10)
Пример #9
0
def getPredefinedAlert(**args):
    preAlert = Alert(**args)
    config = Configuration.getInstance()
    # try fill in some values from configuration to identify the source
    # of alerts down the alerts framework processing chain
    if config:
        agentConfig = getattr(config, "Agent", None)
        if agentConfig:
            preAlert["HostName"] = getattr(agentConfig, "hostName", None)
            preAlert["Contact"] = getattr(agentConfig, "contact", None) 
            preAlert["TeamName"] = getattr(agentConfig, "teamName", None) 
            preAlert["AgentName"] = getattr(agentConfig, "agentName", None)
    return preAlert 
Пример #10
0
def getPredefinedAlert(**args):
    preAlert = Alert(**args)
    config = Configuration.getInstance()
    # try fill in some values from configuration to identify the source
    # of alerts down the alerts framework processing chain
    if config:
        agentConfig = getattr(config, "Agent", None)
        if agentConfig:
            preAlert["HostName"] = getattr(agentConfig, "hostName", None)
            preAlert["Contact"] = getattr(agentConfig, "contact", None)
            preAlert["TeamName"] = getattr(agentConfig, "teamName", None)
            preAlert["AgentName"] = getattr(agentConfig, "agentName", None)
    return preAlert
Пример #11
0
    def testG_testStaticReferenceToConfigurationInstance(self):
        """
        test Configuration.getInstance() which returns reference
        to the Configuration object instance.

        """
        config = Configuration()
        instance = Configuration.getInstance()
        self.assertFalse(hasattr(instance, "testsection"))
        config.section_("testsection")
        self.assertTrue(hasattr(instance, "testsection"))
        config.testsection.var = 10
        self.assertEqual(instance.testsection.var, 10)
Пример #12
0
 def __init__(self, app, config, mount):
     """
     :arg app: reference to application object; passed to all entities.
     :arg config: reference to configuration; passed to all entities.
     :arg str mount: API URL mount point; passed to all entities."""
     
     RESTApi.__init__(self, app, config, mount)
     
     cherrypy.log("WMStats entire configuration:\n%s" % Configuration.getInstance())    
     cherrypy.log("WMStats REST hub configuration subset:\n%s" % config)
     # only allows json format for return value
     self.formats =  [('application/json', JSONFormat())]
     self._add({"info": ServerInfo(app, self, config, mount),
                "request": RequestInfo(app, self, config, mount),
                "requestcache": ActiveRequestJobInfo(app, self, config, mount)
               })
Пример #13
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("ReqMgr entire configuration:\n%s" %
                     Configuration.getInstance())
        cherrypy.log("ReqMgr REST hub configuration subset:\n%s" % config)

        # Makes raw format as default
        # self.formats.insert(0, ('application/raw', RawFormat()))
        self._add({
            "about":
            Info(app, IndividualCouchManager(config), config, mount),
            "info":
            Info(app, IndividualCouchManager(config), config, mount),
            "app_config":
            ReqMgrConfigData(app, IndividualCouchManager(config), config,
                             mount),
            "request":
            Request(app, IndividualCouchManager(config), config, mount),
            "software":
            Software(app, IndividualCouchManager(config), config, mount),
            "status":
            RequestStatus(app, IndividualCouchManager(config), config, mount),
            "type":
            RequestType(app, IndividualCouchManager(config), config, mount),
            "spec_template":
            RequestSpec(IndividualCouchManager(config), app, config, mount),
            "workload_config":
            WorkloadConfig(IndividualCouchManager(config), app, config, mount),
            "splitting":
            WorkloadSplitting(IndividualCouchManager(config), app, config,
                              mount),
            "wmstats_info":
            WMStatsInfo(IndividualCouchManager(config), app, config, mount)
        })
Пример #14
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("WMStats entire configuration:\n%s" %
                     Configuration.getInstance())
        cherrypy.log("WMStats REST hub configuration subset:\n%s" % config)
        # only allows json format for return value
        self.formats = [('application/json', JSONFormat())]
        self._add({
            "info":
            ServerInfo(app, self, config, mount),
            "teams":
            TeamInfo(app, self, config, mount),
            "request":
            RequestInfo(app, self, config, mount),
            "isfinished":
            FinishedStatusInfo(app, self, config, mount),
            "jobdetail":
            JobDetailInfo(app, self, config, mount),
            "requestcache":
            ActiveRequestJobInfo(app, self, config, mount),
            "filtered_requests":
            FilteredActiveRequestJobInfo(app, self, config, mount),
            "protectedlfns":
            ProtectedLFNList(app, self, config, mount),
            "protectedlfns_final":
            ProtectedLFNListOnlyFinalOutput(app, self, config, mount),
            "globallocks":
            GlobalLockList(app, self, config, mount),
            "parentlocks":
            ParentLockList(app, self, config, mount),
            "proc_status":
            ProcessMatrix(app, self, config, mount)
        })
Пример #15
0
    def __init__(self, app, config, mount):
        """
        :arg app: reference to application object; passed to all entities.
        :arg config: reference to configuration; passed to all entities.
        :arg str mount: API URL mount point; passed to all entities."""

        RESTApi.__init__(self, app, config, mount)

        cherrypy.log("WMStats entire configuration:\n%s" % Configuration.getInstance())
        cherrypy.log("WMStats REST hub configuration subset:\n%s" % config)
        # only allows json format for return value
        self.formats = [('application/json', JSONFormat())]
        self._add({"info": ServerInfo(app, self, config, mount),
                   "teams": TeamInfo(app, self, config, mount),
                   "request": RequestInfo(app, self, config, mount),
                   "isfinished": FinishedStatusInfo(app, self, config, mount),
                   "jobdetail": JobDetailInfo(app, self, config, mount),
                   "requestcache": ActiveRequestJobInfo(app, self, config, mount),
                   "filtered_requests": FilteredActiveRequestJobInfo(app, self, config, mount),
                   "protectedlfns": ProtectedLFNList(app, self, config, mount),
                   "protectedlfns_final": ProtectedLFNListOnlyFinalOutput(app, self, config, mount),
                   "globallocks": GlobalLockList(app, self, config, mount)
                  })
Пример #16
0
  def __init__(self, app, config, mount):
    """
    :arg app: reference to application object; passed to all entities.
    :arg config: reference to configuration; passed to all entities.
    :arg str mount: API URL mount point; passed to all entities."""

    RESTApi.__init__(self, app, config, mount)

    cherrypy.log("ReqMgr entire configuration:\n%s" % Configuration.getInstance())    
    cherrypy.log("ReqMgr REST hub configuration subset:\n%s" % config)
    
    db_handler = ReqMgrCouch(config) 
    
    # Makes raw format as default
    #self.formats.insert(0, ('application/raw', RawFormat()))
    self._add({"hello": HelloWorld(self, app, config, mount),
               "about": Info(app, self, config, mount, db_handler),
               "info": Info(app, self, config, mount, db_handler),
               "request": Request(app, self, config, mount, db_handler),
               "group": Group(app, self, config, mount, db_handler),
               "team": Team(app, self, config, mount, db_handler),
               "sw": Software(app, self, config, mount, db_handler),
              })
Пример #17
0
    def _doComponentsPoller(self, thresholdToTest, level, config,
                            pollerClass, expected = 0):
        """
        Components pollers have array of Measurements and ProcessDetails
        which make it more difficult to factory with test methods from the
        utils module.
        
        """
        handler, receiver = utils.setUpReceiver(self.generator.config.Alert.address,
                                                self.generator.config.Alert.controlAddr)
        
        # need some real process to poll, give itself
        pid = os.getpid()
        # the input configuration doesn't have component work directories set right, rectify:
        # the configuration will have, see with what _doComponentsPoller is called
        # two components: AlertGenerator and AlertProcessor defined
        configInstance = Configuration.getInstance()
        for comp in Configuration.getInstance().listComponents_():
            compDir = getattr(configInstance, comp).componentDir
            compDir = os.path.join(compDir, comp)
            setattr(getattr(configInstance, comp), "componentDir", compDir)
            os.makedirs(compDir)
            f = open(os.path.join(compDir, "Daemon.xml"), 'w')
            f.write(utils.daemonXmlContent % dict(PID_TO_PUT = pid))
            f.close()
   
        numMeasurements = config.period / config.pollInterval
        poller = pollerClass(config, self.generator)
        # inject own input sample data provider
        # there is in fact input argument in this case which needs be ignored
        poller.sample = lambda proc_: random.randint(thresholdToTest, thresholdToTest + 10)
        
        # the poller will run upon components (as defined in the configuration)
        # and poll them. the PID, etc will be run from the compomentsDir
        poller.start()
        self.assertTrue(poller.is_alive())

        if expected != 0:
            # watch so that the test can't take for ever, fail in 2mins
            timeLimitExceeded = False
            startTime = datetime.datetime.now()
            limitTime = 2 * 60 # seconds
            while len(handler.queue) == 0:
                time.sleep(config.pollInterval / 5)
                if (datetime.datetime.now() - startTime).seconds > limitTime:
                    timeLimitExceeded = True
                    break                
        else:
            time.sleep(config.period * 2)
            
        poller.terminate()
        receiver.shutdown()
        self.assertFalse(poller.is_alive())
        
        if expected != 0:
            if timeLimitExceeded:
                self.fail("No alert received in %s seconds." % limitTime)            
            # there should be just one alert received, poller should have the
            # change to send a second
            self.assertEqual(len(handler.queue), expected)
            a = handler.queue[0]
            # soft threshold - alert should have 'soft' level
            self.assertEqual(a["Level"], level)
            self.assertEqual(a["Component"], self.generator.__class__.__name__)
            self.assertEqual(a["Source"], poller.__class__.__name__)
Пример #18
0
    def _doComponentsPoller(self,
                            thresholdToTest,
                            level,
                            config,
                            pollerClass,
                            expected=0):
        """
        Components pollers have array of Measurements and ProcessDetails
        which make it more difficult to factory with test methods from the
        utils module.

        """
        handler, receiver = utils.setUpReceiver(
            self.generator.config.Alert.address,
            self.generator.config.Alert.controlAddr)

        # need some real process to poll, give itself
        pid = os.getpid()
        # the input configuration doesn't have component work directories set right, rectify:
        # the configuration will have, see with what _doComponentsPoller is called
        # two components: AlertGenerator and AlertProcessor defined
        configInstance = Configuration.getInstance()
        for comp in Configuration.getInstance().listComponents_():
            compDir = getattr(configInstance, comp).componentDir
            compDir = os.path.join(compDir, comp)
            setattr(getattr(configInstance, comp), "componentDir", compDir)
            os.makedirs(compDir)
            f = open(os.path.join(compDir, "Daemon.xml"), 'w')
            f.write(utils.daemonXmlContent % dict(PID_TO_PUT=pid))
            f.close()

        numMeasurements = config.period / config.pollInterval
        poller = pollerClass(config, self.generator)
        # inject own input sample data provider
        # there is in fact input argument in this case which needs be ignored
        poller.sample = lambda proc_: random.randint(thresholdToTest,
                                                     thresholdToTest + 10)

        # the poller will run upon components (as defined in the configuration)
        # and poll them. the PID, etc will be run from the compomentsDir
        poller.start()
        self.assertTrue(poller.is_alive())

        if expected != 0:
            # watch so that the test can't take for ever, fail in 2mins
            timeLimitExceeded = False
            startTime = datetime.datetime.now()
            limitTime = 2 * 60  # seconds
            while len(handler.queue) == 0:
                time.sleep(config.pollInterval / 5)
                if (datetime.datetime.now() - startTime).seconds > limitTime:
                    timeLimitExceeded = True
                    break
        else:
            time.sleep(config.period * 2)

        poller.terminate()
        receiver.shutdown()
        self.assertFalse(poller.is_alive())

        if expected != 0:
            if timeLimitExceeded:
                self.fail("No alert received in %s seconds." % limitTime)
            # there should be just one alert received, poller should have the
            # change to send a second
            self.assertEqual(len(handler.queue), expected)
            a = handler.queue[0]
            # soft threshold - alert should have 'soft' level
            self.assertEqual(a["Level"], level)
            self.assertEqual(a["Component"], self.generator.__class__.__name__)
            self.assertEqual(a["Source"], poller.__class__.__name__)