コード例 #1
0
        def create_glideinFrontendElement(m_AttrsDescript, m_GroupSignatureDescript, m_ParamsDescript, m_ElementMergedDescript):
            m_AttrsDescript.return_value = self.attrDescript
            m_GroupSignatureDescript.return_value = self.groupSignatureDescript
            m_ParamsDescript.return_value = self.paramsDescript
            m_ElementMergedDescript.return_value = self.elementDescript

            self.gfe = glideinFrontendElement.glideinFrontendElement(1, '', 'group1', '')
            self.gfe.elementDescript = self.elementDescript
コード例 #2
0
def shouldHibernate(frontendDescript, work_dir, ha, mode, groups):
    """
    Check if the frontend is running in HA mode. If run in master mode never
    hibernate. If run in slave mode, hiberate if master is active.

    @rtype: bool
    @return: True if we should hibernate else False
    """

    servicePerformance.startPerfMetricEvent('frontend', 'ha_check')
    if mode == 'slave':
        master_frontend_name = str(
            ha.get('ha_frontends')[0].get('frontend_name'))

        for group in groups:
            element = glideinFrontendElement(os.getpid(), work_dir, group,
                                             "run")
            # Set environment required to query factory collector
            set_frontend_htcondor_env(work_dir, frontendDescript, element)

            for factory_pool in element.factory_pools:
                try:
                    factory_pool_node = factory_pool[0]
                    master_classads = glideinFrontendInterface.findMasterFrontendClassads(
                        factory_pool_node, master_frontend_name)

                    if master_classads:
                        # Found some classads in one of the collectors
                        # Cleanup the env and return True
                        clean_htcondor_env()
                        servicePerformance.endPerfMetricEvent(
                            'frontend', 'ha_check')
                        return True
                except RuntimeError:
                    # Failed to talk
                    if not factory_pool_node:
                        factory_pool_node = ''
                    msg = "Failed to talk to the factory_pool %s to get the status of Master frontend %s" % (
                        factory_pool_node, master_frontend_name)
                    logSupport.log.warn(msg)
                    msg = "Exception talking to the factory_pool %s to get the status of Master frontend %s: " % (
                        factory_pool_node, master_frontend_name)
                    logSupport.log.exception(msg)

        # Cleanup the env
        clean_htcondor_env()

        # NOTE:
        # If we got this far with no errors then we could not find
        # active master frontend. We should not hibernate as slave
        # However, if there were errors checking with factory pool
        # then the master frontend could be down so its safe to wake
        # up and start advertising.

    servicePerformance.endPerfMetricEvent('frontend', 'ha_check')
    return False
コード例 #3
0
        def create_glideinFrontendElement(m_AttrsDescript,
                                          m_GroupSignatureDescript,
                                          m_ParamsDescript,
                                          m_ElementMergedDescript):
            m_AttrsDescript.return_value = self.attrDescript
            m_GroupSignatureDescript.return_value = self.groupSignatureDescript
            m_ParamsDescript.return_value = self.paramsDescript
            m_ElementMergedDescript.return_value = self.elementDescript

            self.gfe = glideinFrontendElement.glideinFrontendElement(
                1, '', 'group1', '')
            self.gfe.elementDescript = self.elementDescript
コード例 #4
0
def shouldHibernate(frontendDescript, work_dir, ha, mode, groups):
    """
    Check if the frontend is running in HA mode. If run in master mode never
    hibernate. If run in slave mode, hiberate if master is active.

    @rtype: bool
    @return: True if we should hibernate else False
    """

    servicePerformance.startPerfMetricEvent('frontend', 'ha_check')
    if mode == 'slave':
        master_frontend_name = str(ha.get('ha_frontends')[0].get('frontend_name'))

        for group in groups:
            element = glideinFrontendElement(os.getpid(), work_dir,
                                             group, "run")
            # Set environment required to query factory collector
            set_frontend_htcondor_env(work_dir, frontendDescript, element)

            for factory_pool in element.factory_pools:
                try:
                    factory_pool_node = factory_pool[0]
                    master_classads = glideinFrontendInterface.findMasterFrontendClassads(factory_pool_node, master_frontend_name)

                    if master_classads:
                        # Found some classads in one of the collectors
                        # Cleanup the env and return True
                        clean_htcondor_env()
                        servicePerformance.endPerfMetricEvent(
                            'frontend', 'ha_check')
                        return True
                except RuntimeError:
                    # Failed to talk
                    if not factory_pool_node:
                        factory_pool_node = ''
                    msg = "Failed to talk to the factory_pool %s to get the status of Master frontend %s" % (factory_pool_node, master_frontend_name)
                    logSupport.log.warn(msg)
                    msg = "Exception talking to the factory_pool %s to get the status of Master frontend %s: " % (factory_pool_node, master_frontend_name)
                    logSupport.log.exception(msg )

        # Cleanup the env
        clean_htcondor_env()

        # NOTE:
        # If we got this far with no errors then we could not find
        # active master frontend. We should not hibernate as slave
        # However, if there were errors checking with factory pool
        # then the master frontend could be down so its safe to wake
        # up and start advertising.

    servicePerformance.endPerfMetricEvent('frontend', 'ha_check')
    return False
コード例 #5
0
def set_frontend_htcondor_env(work_dir, frontendDescript, element=None):
    # Collector DN is only in the group's mapfile. Just get first one.
    groups = frontendDescript.data['Groups'].split(',')
    if groups:
        if element is None:
            element = glideinFrontendElement(os.getpid(), work_dir,
                                             groups[0], "run")
        htc_env = {
            'CONDOR_CONFIG': frontendDescript.data['CondorConfig'],
            'X509_USER_PROXY': frontendDescript.data['ClassAdProxy'],
            '_CONDOR_CERTIFICATE_MAPFILE':  element.elementDescript.element_data['MapFile']
        }
        set_env(htc_env)
コード例 #6
0
def set_frontend_htcondor_env(work_dir, frontendDescript, element=None):
    # Collector DN is only in the group's mapfile. Just get first one.
    groups = frontendDescript.data['Groups'].split(',')
    if groups:
        if element is None:
            element = glideinFrontendElement(os.getpid(), work_dir,
                                             groups[0], "run")
        htc_env = {
            'CONDOR_CONFIG': frontendDescript.data['CondorConfig'],
            'X509_USER_PROXY': frontendDescript.data['ClassAdProxy'],
            '_CONDOR_CERTIFICATE_MAPFILE':  element.elementDescript.element_data['MapFile']
        }
        set_env(htc_env)
コード例 #7
0
 def setUp(self):
     parent_pid = 0
     work_dir = 'fixtures/frontend'
     group_name = 'group1'
     action = 'yada yada'
     condorMonitor.USE_HTCONDOR_PYTHON_BINDINGS = False
     condorMonitor.LocalScheddCache.iGetEnv = mock.Mock()
     #condorExe.exe_cmd = mock.Mock()
     #condorExe.exe_cmd.side_effect = condor_side_effect
     glideinwms.frontend.glideinFrontendLib.logSupport.log = FakeLogger()
     self.gfe = glideinFrontendElement(os.getpid(), work_dir, group_name,
                                       action)
     self.gfe.frontend_name = 'Frontend-master-v1_0'
     #self.gfe.configure()
     init_factory_stats_arr()
     self.verbose = os.environ.get('DEBUG_OUTPUT')
     self.gfe.get_condor_q = mock.Mock()
     self.gfe.get_condor_q.side_effect = condor_q_side_effect
     self.gfe.get_condor_status = mock.Mock()
     self.gfe.get_condor_status.side_effect = condor_status_side_effect