Esempio n. 1
0
 def test_vo_queues(self):
     os.environ['GIP_TESTING'] = '1'
     cp = config("test_configs/red.conf")
     vo_queues = Set(getVoQueues(cp))
     diff = vo_queues.symmetric_difference(example_queues)
     self.assertEquals(len(diff), 0, msg="The following VO-queues are " \
         "different between the expected and actual: %s" % str(diff))
Esempio n. 2
0
def main():
    """
    Main wrapper for the Condor batch system GIP information.
    """
    try:
        cp = config()
        condor_path = cp_get(cp, "condor", "condor_path", None)
	condor_location = cp_get(cp, "condor", "condor_location", None)
	condor_config = cp_get(cp, "condor", "condor_config", None)

        if condor_path != None:
		addToPath(condor_path)

	if condor_location != None:
		addToPath('%s/bin' % condor_location)
		if not condor_config:
			condor_config = '%s/etc/condor_config' % condor_location

	if condor_config:
		os.environ['CONDOR_CONFIG'] = condor_config

        #vo_map = VoMapper(cp)
        getLrmsInfo(cp) 
        print_CE(cp)
        print_VOViewLocal(cp)
    except Exception, e:
        log.exception(e)
        raise
Esempio n. 3
0
 def test_osg_check(self):
     """
     Make sure that the checkOsgConfigured function operates as desired.
     """
     cp = config()
     try:
         import tempfile
         file2 = tempfile.NamedTemporaryFile()
         filename2 = file2.name
     except:
         filename2 = '/tmp/config.ini'
         file2 = open(filename2, 'w')
     if not cp.has_section("gip"):
         cp.add_section("gip")
     cp.set("gip", "osg_config", filename2)
     cp.set("vo", "user_vo_map", "test_configs/red-osg-user-vo-map.txt")
     try:
         didFail = False
         try:
             gip_osg.checkOsgConfigured(cp)
         except Exception, e:
             raise
             didFail = True
             print >> sys.stderr, e
         self.failIf(didFail, "Failed on a 'valid' user-vo-map")
         cp.set("vo", "user_vo_map", "/foo/bar")
         didFail = False
         try:
             gip_osg.checkOsgConfigured(cp)
         except:
             didFail = True
         self.failUnless(didFail, "Did not fail on missing file.")
Esempio n. 4
0
def main():
    try:
        # Load up the site configuration
        cp = config()
        se_only = cp_getBoolean(cp, "gip", "se_only", False)
        if not se_only:
    
            # Get the timestamp in the two formats we wanted
            epoch = str(time.time())
            now = time.strftime("%a %b %d %T UTC %Y", time.gmtime())
    
            # Load up the template for GlueLocationLocalID
            # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
            template = getTemplate("GlueCluster", "GlueLocationLocalID")
            cluster_id = getClusterID(cp)
            for subClusterId in getSubClusterIDs(cp):
                # Dictionary of data to fill in for GlueLocationLocalID
                info = {'locationId':   'TIMESTAMP',
                        'subClusterId': subClusterId,
                        'clusterId':    cluster_id,
                        'locationName': 'TIMESTAMP',
                        'version':      epoch,
                        'path':         now,
                        }
    
                # Spit out our template, fill it with the appropriate info.
                printTemplate(template, info)

    except Exception, e:
        # Log error, then report it via stderr.
        log.exception(e)
        sys.stdout = sys.stderr
        raise
Esempio n. 5
0
def main():
    """
    The primary wrapper function for emitting GLUE for storage elements.
    """
    cp = config()

    # Handle full-fledged SEs
    found_se = False
    for section in cp.sections():
        # need to search for sections with "_" because if you are only
        # advertising a classic SE, then you do NOT want to run the
        # handle_SE function or you will get duplicate and incorrect info
        if section.lower().startswith("se_"):
            advertise_se = cp_getBoolean(cp, section, "advertise_se", True)
            if advertise_se:
                handle_SE(cp, section)
            found_se = True
    if found_se == False and 'se' in cp.sections():
        handle_SE(cp, 'se')

    # Handle the "classic" SE.
    se_only = cp_getBoolean(cp, "gip", "se_only", False)
    if not se_only:
        try:
            print_classicSE(cp)
        except Exception, e:
            log.exception(e)
Esempio n. 6
0
def main():
    """
    The main entry point for when the test is in standalone mode.
    """
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestGipFull, stream, per_site=False)
Esempio n. 7
0
def main():
    """
    The main entry point for when pbs_test is run in standalone mode.
    """
    cp = config("test_configs/red.conf")
    stream = streamHandler(cp)
    runTest(cp, TestPbsDynamic, stream, per_site=False)
Esempio n. 8
0
def main():
    try:
        # Load up the site configuration
        cp = config()
        se_only = cp_getBoolean(cp, "gip", "se_only", False)
        if not se_only:

            # Get the timestamp in the two formats we wanted
            epoch = str(time.time())
            now = time.strftime("%a %b %d %T UTC %Y", time.gmtime())

            # Load up the template for GlueLocationLocalID
            # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
            template = getTemplate("GlueCluster", "GlueLocationLocalID")
            cluster_id = getClusterID(cp)
            for subClusterId in getSubClusterIDs(cp):
                # Dictionary of data to fill in for GlueLocationLocalID
                info = {
                    'locationId': 'TIMESTAMP',
                    'subClusterId': subClusterId,
                    'clusterId': cluster_id,
                    'locationName': 'TIMESTAMP',
                    'version': epoch,
                    'path': now,
                }

                # Spit out our template, fill it with the appropriate info.
                printTemplate(template, info)

    except Exception, e:
        # Log error, then report it via stderr.
        log.exception(e)
        sys.stdout = sys.stderr
        raise
Esempio n. 9
0
def main():
    """
    The main entry point for when compare_bdii_cemon is run in standalone mode.
    """
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestCompareData, stream)
Esempio n. 10
0
def getTestConfig(*args):
    cp = config(args[1:])
    try:
        cp.readfp(open(os.path.expandvars('$GIP_LOCATION/etc/gip_tests.conf')))
    except:
        pass

    interpolateConfig(cp)

    section = "gip_tests"
    if not cp.has_section(section):
        cp.add_section(section)

    if py23:
        p = optparse.OptionParser()
        p.add_option('-c', '--config', dest='config', help='Configuration file.', default='gip.conf')
        p.add_option('-f', '--format', dest='format', help='Unittest output format', default='xml')
        (options, args) = p.parse_args()
        xml = options.format
    else:
        keywordOpts, passedOpts, givenOpts = parseOpts(args)
        if keywordOpts["format"]:
             xml = keywordOpts["format"]
        if keywordOpts["f"]:
             xml = keywordOpts["f"]

    try:
        if xml == "xml":
            cp.set(section, "use_xml", "True")
        else:
            cp.set(section, "use_xml", "False")
    except:
        cp.set(section, "use_xml", "False")

    return cp
Esempio n. 11
0
def main():
    try:
        # Load up the site configuration
        cp = config()
        se_only = cp_getBoolean(cp, "gip", "se_only", False)
        if not se_only:
            # Load up the template for GlueLocationLocalID
            # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
            template = getTemplate("GlueCluster", "GlueLocationLocalID")
            cluster_id = getClusterID(cp)
            osg_grid = cp_get(cp, "osg_dirs", "grid_dir", None)
    
            if not osg_grid:
                raise RuntimeError('grid_dir ($OSG_GRID) not defined!')
                
            for subClusterId in getSubClusterIDs(cp):
                # Dictionary of data to fill in for GlueLocationLocalID
                info = {'locationId':   'OSG_GRID',
                        'subClusterId': subClusterId,
                        'clusterId':    cluster_id,
                        'locationName': 'OSG_GRID',
                        'version':      1.0,
                        'path':         osg_grid,
                       }
        
                # Spit out our template, fill it with the appropriate info.
                printTemplate(template, info)
            
    except Exception, e:
        # Log error, then report it via stderr.
        log.error(e)
        sys.stdout = sys.stderr
        raise
Esempio n. 12
0
def main():
    try:
        # Load up the site configuration
        cp = config()
        se_only = cp_getBoolean(cp, "gip", "se_only", False)
        if not se_only:
            # Load up the template for GlueLocationLocalID
            # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
            template = getTemplate("GlueCluster", "GlueLocationLocalID")
            cluster_id = getClusterID(cp)
            osg_grid = cp_get(cp, "osg_dirs", "grid_dir", None)

            if not osg_grid:
                raise RuntimeError('grid_dir ($OSG_GRID) not defined!')

            for subClusterId in getSubClusterIDs(cp):
                # Dictionary of data to fill in for GlueLocationLocalID
                info = {
                    'locationId': 'OSG_GRID',
                    'subClusterId': subClusterId,
                    'clusterId': cluster_id,
                    'locationName': 'OSG_GRID',
                    'version': 1.0,
                    'path': osg_grid,
                }

                # Spit out our template, fill it with the appropriate info.
                printTemplate(template, info)

    except Exception, e:
        # Log error, then report it via stderr.
        log.error(e)
        sys.stdout = sys.stderr
        raise
Esempio n. 13
0
def main():
    """
    The main entry point for when compare_bdii_cemon is run in standalone mode.
    """
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestCompareData, stream)
Esempio n. 14
0
    def test_response(self):
        """
        Test a provider which goes above the response time.

        The response value is when the osg-info-wrapper starts killing its
        children.
        """
        cp = config("test_modules/timeout/config")
        cp.set("gip", "timeout", "50")
        cp.set("gip", "response", "5")
        cp.set("gip", "flush_cache", "True")
        t1 = time.time()
        entries = osg_info_wrapper.main(cp, return_entries=True)
        t1 = time.time() - t1
        has_ent_1 = False
        has_ent_2 = False
        for entry in entries:
            if entry.dn[0] == 'GlueVOInfoLocalID=osgedu':
                has_ent_1 = True
            if entry.dn[0] == 'GlueVOInfoLocalID=fmri':
                has_ent_2 = True
        self.assertEquals(has_ent_1, False, msg="Module timeout_15 was not" \
            " ignored quickly enough.")
        self.assertEquals(has_ent_2, False, msg="Module timeout_20 was not" \
            " ignored quickly enough.")
        self.assertEquals(t1 < 6, True, msg="Response was not handled " \
            "correctly.")
Esempio n. 15
0
def main():
    """
    The main entry point for testing the osg-info-wrapper implementation.
    """
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestOsgInfoWrapper, stream, per_site=False)
Esempio n. 16
0
    def test_response(self):
        """
        Test a provider which goes above the response time.

        The response value is when the osg-info-wrapper starts killing its
        children.
        """
        cp = config("test_modules/timeout/config")
        cp.set("gip", "timeout", "50")
        cp.set("gip", "response", "5")
        cp.set("gip", "flush_cache", "True")
        t1 = time.time()
        entries = osg_info_wrapper.main(cp, return_entries=True)
        t1 = time.time() - t1
        has_ent_1 = False
        has_ent_2 = False
        for entry in entries:
            if entry.dn[0] == 'GlueVOInfoLocalID=osgedu':
                has_ent_1 = True
            if entry.dn[0] == 'GlueVOInfoLocalID=fmri':
                has_ent_2 = True
        self.assertEquals(has_ent_1, False, msg="Module timeout_15 was not" \
            " ignored quickly enough.")
        self.assertEquals(has_ent_2, False, msg="Module timeout_20 was not" \
            " ignored quickly enough.")
        self.assertEquals(t1 < 6, True, msg="Response was not handled " \
            "correctly.")
Esempio n. 17
0
def main():
    """
    The main entry point for when sge_test is run in standalone mode.
    """
    cp = config("test_configs/pf-sge.conf")
    stream = streamHandler(cp)
    runTest(cp, TestSGEDynamic, stream, per_site=False)
Esempio n. 18
0
def main():
    """
    The primary wrapper function for emitting GLUE for storage elements.
    """
    cp = config()

    # Handle full-fledged SEs
    found_se = False
    for section in cp.sections():
        # need to search for sections with "_" because if you are only
        # advertising a classic SE, then you do NOT want to run the
        # handle_SE function or you will get duplicate and incorrect info
        if section.lower().startswith("se_"):
            advertise_se = cp_getBoolean(cp, section, "advertise_se", True)
            if advertise_se:
                handle_SE(cp, section)
            found_se = True
    if found_se == False and 'se' in cp.sections():
        handle_SE(cp, 'se')

    # Handle the "classic" SE.
    se_only = cp_getBoolean(cp, "gip", "se_only", False)
    if not se_only:
        try:
            print_classicSE(cp)
        except Exception, e:
            log.exception(e)
Esempio n. 19
0
def main():
    try:
        # Load up the site configuration
        cp = config()
        se_only = cp_getBoolean(cp, "gip", "se_only", False)
        if not se_only:
            # Load up the template for GlueService
            # To view its contents, see $VDT_LOCATION/gip/templates/GlueService
            template = getTemplate("GlueService", "GlueServiceUniqueID")
            if not cp_getBoolean(cp, "site", "advertise_gums", True):
                log.info("Not advertising authorization service.")
                return
            else:
                log.info("Advertising authorization service.")
    
            try:
                authfile = open('/etc/grid-security/gsi-authz.conf', 'r')
                authlines = authfile.readlines()
                authmod = re.compile('^(?!#)(.*)libprima_authz_module')
                for line in authlines:
                    m = authmod.match(line)
                    if m:
                        publish_gums(cp, template)
                        return
            except IOError:
                log.info("/etc/grid-security/gsi-authz.conf not found; assuming gridmap file authorization")
            
            publish_gridmap_file(cp, template)                

    except Exception, e:
        # Log error, then report it via stderr.
        log.exception(e)
        sys.stdout = sys.stderr
        raise
Esempio n. 20
0
 def test_vo_queues(self):
     os.environ['GIP_TESTING'] = '1'
     cp = config("test_configs/red.conf")
     vo_queues = Set(getVoQueues(cp))
     diff = vo_queues.symmetric_difference(example_queues)
     self.assertEquals(len(diff), 0, msg="The following VO-queues are " \
         "different between the expected and actual: %s" % str(diff))
Esempio n. 21
0
def main():
    """
    The main entry point for testing the osg-info-wrapper implementation.
    """
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestOsgInfoWrapper, stream, per_site=False)
Esempio n. 22
0
def main():
    try:
        cp = config()
        print_CESEBind(cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.error(e)
        raise
Esempio n. 23
0
def main():
    cp = config()
    if not cp_getBoolean(cp, 'cluster', 'advertise_cluster', True):
        return
    try:
        print_clusters(cp)
    except Exception, e:
        log.exception(e)
Esempio n. 24
0
def main():
    """
    The main entry point for when condor_test is run in standalone mode.
    """
    os.environ['GIP_TESTING'] = '1'
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestCondorProvider, stream, per_site=False)
Esempio n. 25
0
def main():
    cp = config()
    if not cp_getBoolean(cp, "cluster", "advertise_cluster", True):
        return
    try:
        print_clusters(cp)
    except Exception, e:
        log.exception(e)
Esempio n. 26
0
def main():
    try:
        cp = config()
        print_CESEBind(cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.error(e)
        raise
Esempio n. 27
0
def main():
    """
    The main entry point for when condor_test is run in standalone mode.
    """
    os.environ['GIP_TESTING'] = '1'
    cp = config()
    stream = streamHandler(cp)
    runTest(cp, TestCondorProvider, stream, per_site=False)
Esempio n. 28
0
def main():
    try:
        cp = config()
        print_Locations(cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.exception(e)
        raise
Esempio n. 29
0
def main():
    try:
        cp = config()
        print_Locations(cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.exception(e)
        raise
Esempio n. 30
0
def main():
    log.info('Starting CREAM service provider')
    try:
        cp = config()
        serviceID = buildServiceID(cp)
        siteID = cp_get(cp, "site", "unique_name", 'UNKNOWN_SITE')
        serviceName = '%s-CREAM' % siteID 
        creamVersion = getCreamVersion(cp)
        endpoint = 'https://%s:8443/ce-cream/services' % cp_get(cp, "ce", "name", 'UNKNOWN_CE')
        allVOs = voList(cp)
        acbr = ''
        owner = ''

        log.debug('CREAM VOs are %s' % allVOs)
        if not allVOs:
            log.error("No VOs supported!")
            acbr = '__GIP_DELETEME'
        else:
            acbr = '\n'.join(['GlueServiceAccessControlBaseRule: %s\n' \
                              'GlueServiceAccessControlBaseRule: VO:%s' % (vo, vo) for vo in allVOs])
            owner = '\n' + '\n'.join(['GlueServiceOwner: %s' % vo for vo in allVOs]) # owner needs an extra prepended newline

        pid = -1
        startTime = 'Not Applicable'
        serviceStatus = 'Not OK'
        serviceStatusInfo = 'Could not find tomcat process'

        try:
            (startTime, pid) = getStartTimeAndPid(cp)
            serviceStatus = 'OK'
            serviceStatusInfo = 'Tomcat (%d) is running' % pid
        except:
            log.error('Could not locate tomcat process (pgrep -f "org.apache.catalina.startup.Bootstrap start"'
                      ' probably failed to return any output!)')
        
        info = {'serviceID': serviceID,
                'serviceType': 'org.glite.ce.CREAM',
                'serviceName': serviceName,
                'version': creamVersion,
                'endpoint': endpoint,
                'semantics': 'https://edms.cern.ch/document/595770',
                'owner': owner,
                'url': '__GIP_DELETEME', # deprecated
                'uri': '__GIP_DELETEME', # deprecated
                'status': serviceStatus,
                'statusInfo': serviceStatusInfo,
                'wsdl': 'http://grid.pd.infn.it/cream/wsdl/org.glite.ce-cream_service.wsdl',
                'startTime': startTime,
                'siteID': siteID,
                'acbr': acbr
                }

        template = getTemplate("GlueService", "GlueServiceUniqueID")
        printTemplate(template, info)
    except Exception, e:
        sys.stdout = sys.stderr
        log.error(e)
        raise
Esempio n. 31
0
 def test_red(self):
     """
     Test all the output for red.unl.edu.
     """
     cp = config("test_modules/red/config")
     os.environ['GIP_TESTING'] = '1'
     entries = osg_info_wrapper.main(cp, return_entries=True)
     gv = GipValidate(entries)
     gv.run()
Esempio n. 32
0
def main():
    cp = config()
    ask = InputHandler(cp)
    try:
        config_site(ask)
    except KeyboardInterrupt:
        if ask(q.save_progress, None, None, makeBoolean):
            save(cp)
        else:
            sys.exit(1)
    save(cp)
Esempio n. 33
0
 def test_bestman_output(self):
     """
     Test to make sure we can parse BestMan output for the new and old server
     responses, as well as the new and old client formats
     """
     os.environ['GIP_TESTING'] = "1"
     cfg_name = os.path.join("test_configs", "red-se-test.conf")
     cp = config(cfg_name)
     info = srm_ping.bestman_srm_ping(cp, "1")
     self.verify_bestman_output(info)
     srm_ping.bestman_srm_ping(cp, "2")
     self.verify_bestman_output(info)
Esempio n. 34
0
 def test_bestman_output(self):
     """
     Test to make sure we can parse BestMan output for the new and old server
     responses, as well as the new and old client formats
     """
     os.environ['GIP_TESTING'] = "1"
     cfg_name = os.path.join("test_configs", "red-se-test.conf")
     cp = config(cfg_name)
     info = srm_ping.bestman_srm_ping(cp, "1")
     self.verify_bestman_output(info)
     srm_ping.bestman_srm_ping(cp, "2")
     self.verify_bestman_output(info)
Esempio n. 35
0
def main(cp = None, return_entries=False):
    """
    Main method for the osg-info-wrapper script.  This script safely runs the
    plugin and provider modules, caching where necessary, and combines it with
    the static data.  It then outputs the final GLUE information for this site.
    """
    
    log.debug("Starting up the osg-info-wrapper.")
    if cp == None:
        cp = config()

    temp_dir = os.path.expandvars(cp_get(cp, "gip", "temp_dir", \
        gipDir("$GIP_LOCATION/var/tmp", '/var/cache/gip'))) 
    plugin_dir = os.path.expandvars(cp_get(cp, "gip", "plugin_dir", \
        gipDir("$GIP_LOCATION/plugins", '/usr/libexec/gip/plugins')))
    provider_dir = os.path.expandvars(cp_get(cp, "gip", "provider_dir", \
        gipDir("$GIP_LOCATION/providers", '/usr/libexec/gip/providers')))
    static_dir = os.path.expandvars(cp_get(cp, "gip", "static_dir", \
        gipDir("$GIP_LOCATION/var/ldif", '/etc/gip/ldif.d')))

    # Make sure that our directories exist.
    create_if_not_exist(temp_dir, plugin_dir, provider_dir, static_dir)

    # Load up our add, alter, and delete attributes
    add_attributes = os.path.expandvars(cp_get(cp, "gip", \
        "add_attributes", gipDir("$GIP_LOCATION/etc/add-attributes.conf",
                                 '/etc/gip/add-attributes.conf')))
    alter_attributes = os.path.expandvars(cp_get(cp, "gip", \
        "alter_attributes", gipDir("$GIP_LOCATION/etc/alter-attributes.conf",
                                   '/etc/gip/alter-attributes.conf')))
    remove_attributes = os.path.expandvars(cp_get(cp, "gip", \
        "remove_attributes", gipDir("$GIP_LOCATION/etc/remove-attributes.conf",
                                    '/etc/gip/remove-attributes.conf')))

    # Flush the cache if appropriate
    do_flush_cache = cp_getBoolean(cp, "gip", "flush_cache", False)
    if do_flush_cache:
        log.info("Flushing cache upon request.")
        flush_cache(temp_dir)

    # Load up our parameters
    freshness = cp_getInt(cp, "gip", "freshness", 300)
    cache_ttl = cp_getInt(cp, "gip", "cache_ttl", 600)
    response  = cp_getInt(cp, "gip", "response",  240)
    timeout = cp_getInt(cp, "gip",   "timeout",   240)

    try:
        os.setpgrp()
    except OSError, oe:
        # If launched from a batch system (condor), we might not have perms
        if oe.errno != 1:
            raise
Esempio n. 36
0
def main(cp=None, return_entries=False):
    """
    Main method for the osg-info-wrapper script.  This script safely runs the
    plugin and provider modules, caching where necessary, and combines it with
    the static data.  It then outputs the final GLUE information for this site.
    """

    log.debug("Starting up the osg-info-wrapper.")
    if cp == None:
        cp = config()

    temp_dir = os.path.expandvars(cp_get(cp, "gip", "temp_dir", \
        gipDir("$GIP_LOCATION/var/tmp", '/var/cache/gip')))
    plugin_dir = os.path.expandvars(cp_get(cp, "gip", "plugin_dir", \
        gipDir("$GIP_LOCATION/plugins", '/usr/libexec/gip/plugins')))
    provider_dir = os.path.expandvars(cp_get(cp, "gip", "provider_dir", \
        gipDir("$GIP_LOCATION/providers", '/usr/libexec/gip/providers')))
    static_dir = os.path.expandvars(cp_get(cp, "gip", "static_dir", \
        gipDir("$GIP_LOCATION/var/ldif", '/etc/gip/ldif.d')))

    # Make sure that our directories exist.
    create_if_not_exist(temp_dir, plugin_dir, provider_dir, static_dir)

    # Load up our add, alter, and delete attributes
    add_attributes = os.path.expandvars(cp_get(cp, "gip", \
        "add_attributes", vdtDir("$VDT_LOCATION/gip/etc/add-attributes.conf",
                                 '/etc/gip/add-attributes.conf')))
    alter_attributes = os.path.expandvars(cp_get(cp, "gip", \
        "alter_attributes", vdtDir("$VDT_LOCATION/gip/etc/alter-attributes.conf",
                                   '/etc/gip/alter-attributes.conf')))
    remove_attributes = os.path.expandvars(cp_get(cp, "gip", \
        "remove_attributes", vdtDir("$VDT_LOCATION/gip/etc/remove-attributes.conf",
                                    '/etc/gip/remove-attributes.conf')))

    # Flush the cache if appropriate
    do_flush_cache = cp_getBoolean(cp, "gip", "flush_cache", False)
    if do_flush_cache:
        log.info("Flushing cache upon request.")
        flush_cache(temp_dir)

    # Load up our parameters
    freshness = cp_getInt(cp, "gip", "freshness", 300)
    cache_ttl = cp_getInt(cp, "gip", "cache_ttl", 600)
    response = cp_getInt(cp, "gip", "response", 240)
    timeout = cp_getInt(cp, "gip", "timeout", 240)

    try:
        os.setpgrp()
    except OSError, oe:
        # If launched from a batch system (condor), we might not have perms
        if oe.errno != 1:
            raise
Esempio n. 37
0
File: sge.py Progetto: holzman/gip
def main():
    try:
        cp = config()
        bootstrapSGE(cp)
        addToPath(cp_get(cp, "sge", "sge_path", "."))
        vo_map = VoMapper(cp)
        pbsVersion = getLrmsInfo(cp)
        print_CE(cp)
        print_VOViewLocal(cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.error(e)
        raise
Esempio n. 38
0
 def setUpLDAP(self, filename=None):
     if filename != None:
         self.filename = filename
     os.environ['GIP_TESTING'] = "1"
     cp = config(self.filename)
     self.ces = getCEList(cp)
     self.ses = getSEList(cp)
     cese_provider_path = os.path.expandvars("$GIP_LOCATION/libexec/" \
         "osg_info_cesebind.py --config %s" % self.filename)
     print >> sys.stderr, "Used command", cese_provider_path
     fd = os.popen(cese_provider_path)
     self.entries = read_ldap(fd, multi=True)
     self.exit_status = fd.close()
Esempio n. 39
0
File: sge.py Progetto: tiradani/gip
def main():
    try:
        cp = config()
        bootstrapSGE(cp)
        addToPath(cp_get(cp, "sge", "sge_path", "."))
        vo_map = VoMapper(cp)
        pbsVersion = getLrmsInfo(cp)
        print_CE(cp)
        print_VOViewLocal(cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.error(e)
        raise
Esempio n. 40
0
 def test_add_attributes(self):
     """
     Make sure the add-attributes.conf file works properly
     """
     cp = config("test_modules/simple/config")
     cp.set("gip", "add_attributes", "test_modules/simple/add_attributes")
     has_ce = False
     entries = osg_info_wrapper.main(cp, return_entries=True)
     for entry in entries:
         if entry.dn[0] == 'GlueCEUniqueID=red.unl.edu:2119/jobmanager-pbs' \
                 '-cms':
             has_ce = True
     self.assertEquals(has_ce, True, msg="The entry in the sample " \
         "add_attributes file was not found!")
Esempio n. 41
0
 def test_cache_flush(self):
     """
     Make sure that osg-info-wrapper flushes the cache properly.
     """
     cp = config("test_modules/cache_flush/config")
     cp.set("gip", "flush_cache", "False")
     entries = osg_info_wrapper.main(cp, return_entries=True)
     timestamp_entry = entries[0]
     t1 = float(timestamp_entry.glue['LocationVersion'][0])
     cp.set("gip", "flush_cache", "True")
     entries = osg_info_wrapper.main(cp, return_entries=True)
     timestamp_entry = entries[0]
     t2 = float(timestamp_entry.glue['LocationVersion'][0])
     self.failUnless(t1 < t2)
Esempio n. 42
0
 def test_remove_attributes(self):
     """
     Make sure the remove-attributes.conf file works properly
     """
     cp = config("test_modules/simple/config")
     cp.set("gip", "remove_attributes", \
         "test_modules/simple/remove_attributes")
     has_no_time = True
     entries = osg_info_wrapper.main(cp, return_entries=True)
     for entry in entries:
          if entry.dn[0] == 'GlueLocationLocalID=TIMESTAMP':
              has_no_time = False
     self.assertEquals(has_no_time, True, msg="The entry from the timestamp"\
         " provider is present, and it should have been removed.")
Esempio n. 43
0
 def test_add_attributes(self):
     """
     Make sure the add-attributes.conf file works properly
     """
     cp = config("test_modules/simple/config")
     cp.set("gip", "add_attributes", "test_modules/simple/add_attributes")
     has_ce = False
     entries = osg_info_wrapper.main(cp, return_entries=True)
     for entry in entries:
         if entry.dn[0] == 'GlueCEUniqueID=red.unl.edu:2119/jobmanager-pbs' \
                 '-cms':
             has_ce = True
     self.assertEquals(has_ce, True, msg="The entry in the sample " \
         "add_attributes file was not found!")
Esempio n. 44
0
 def test_cache_flush(self):
     """
     Make sure that osg-info-wrapper flushes the cache properly.
     """
     cp = config("test_modules/cache_flush/config")
     cp.set("gip", "flush_cache", "False")
     entries = osg_info_wrapper.main(cp, return_entries=True)
     timestamp_entry = entries[0]
     t1 = float(timestamp_entry.glue['LocationVersion'][0])
     cp.set("gip", "flush_cache", "True")
     entries = osg_info_wrapper.main(cp, return_entries=True)
     timestamp_entry = entries[0]
     t2 = float(timestamp_entry.glue['LocationVersion'][0])
     self.failUnless(t1 < t2)
Esempio n. 45
0
 def test_remove_attributes(self):
     """
     Make sure the remove-attributes.conf file works properly
     """
     cp = config("test_modules/simple/config")
     cp.set("gip", "remove_attributes", \
         "test_modules/simple/remove_attributes")
     has_no_time = True
     entries = osg_info_wrapper.main(cp, return_entries=True)
     for entry in entries:
         if entry.dn[0] == 'GlueLocationLocalID=TIMESTAMP':
             has_no_time = False
     self.assertEquals(has_no_time, True, msg="The entry from the timestamp"\
         " provider is present, and it should have been removed.")
Esempio n. 46
0
def determine_provider(provider_implementation, implementation, cp):
    """
    Determine which provider class to use based upon the requested provider
    implementation and the actual SE implementation
    """
    provider_implementation = provider_implementation.strip().lower()
    implementation = implementation.strip().lower()
    if provider_implementation == 'static':
        se_class = StorageElement
    elif provider_implementation == 'bestman':
        se_class = BestmanInfo
    elif provider_implementation == 'dcache':
        cp = config("$GIP_LOCATION/etc/dcache_storage.conf")
        se_class = DCacheInfo
    elif provider_implementation == 'dcache19':
        se_class = DCacheInfo19
    elif implementation.find('bestman') >= 0:
        se_class = BestmanInfo
    elif implementation.find('dcache') >= 0:
        cp = config("$GIP_LOCATION/etc/dcache_storage.conf")
        se_class = DCacheInfo
    else:
        se_class = StorageElement
    return se_class, cp
Esempio n. 47
0
 def test_static_ldif(self):
     """
     Test the ability to include static LDIF in the GIP.
     """
     cp = config("test_modules/simple/config")
     entries = osg_info_wrapper.main(cp, return_entries=True)
     has_timestamp = False
     has_ce = False
     for entry in entries:
         if entry.glue.get('LocationName', (0, ))[0] == 'TIMESTAMP':
             has_timestamp = True
         if entry.dn[0] == 'GlueCEUniqueID=red.unl.edu:2119/jobmanager' \
                 '-pbs-workq':
             has_ce = True
     self.assertEquals(has_ce, True, msg="Static info was not included.")
Esempio n. 48
0
def determine_provider(provider_implementation, implementation, cp):
    """
    Determine which provider class to use based upon the requested provider
    implementation and the actual SE implementation
    """
    provider_implementation = provider_implementation.strip().lower()
    implementation = implementation.strip().lower()
    if provider_implementation == 'static':
        se_class = StorageElement
    elif provider_implementation == 'bestman':
        se_class = BestmanInfo
    elif provider_implementation == 'dcache':
        cp = config("$GIP_LOCATION/etc/dcache_storage.conf")
        se_class = DCacheInfo
    elif provider_implementation == 'dcache19':
        se_class = DCacheInfo19
    elif implementation.find('bestman') >= 0:
        se_class = BestmanInfo
    elif implementation.find('dcache') >= 0:
        cp = config("$GIP_LOCATION/etc/dcache_storage.conf")
        se_class = DCacheInfo
    else:
        se_class = StorageElement
    return se_class, cp
Esempio n. 49
0
 def test_alter_attributes(self):
     """
     Make sure the alter-attributes.conf file works properly
     """
     cp = config("test_modules/simple/config")
     cp.set("gip","alter_attributes", "test_modules/simple/alter_attributes")
     has_ce = False
     entries = osg_info_wrapper.main(cp, return_entries=True)
     for entry in entries:
         if entry.dn[0] == 'GlueCEUniqueID=red.unl.edu:2119/jobmanager' \
                 '-pbs-workq':
             has_ce = True
             self.assertEquals(entry.glue['CEPolicyAssignedJobSlots'][0], \
                 '1235', msg="Plugin did not get applied properly")
     self.assertEquals(has_ce, True, msg="Static info was not included.")
Esempio n. 50
0
 def test_static_ldif(self):
     """
     Test the ability to include static LDIF in the GIP.
     """
     cp = config("test_modules/simple/config")
     entries = osg_info_wrapper.main(cp, return_entries=True)
     has_timestamp = False
     has_ce = False
     for entry in entries:
         if entry.glue.get('LocationName', (0,))[0] == 'TIMESTAMP':
             has_timestamp = True
         if entry.dn[0] == 'GlueCEUniqueID=red.unl.edu:2119/jobmanager' \
                 '-pbs-workq':
             has_ce = True
     self.assertEquals(has_ce, True, msg="Static info was not included.")
Esempio n. 51
0
def main():
    """
    Main wrapper for the Condor batch system GIP information.
    """
    try:
        cp = config()
	doPath(cp)

        #vo_map = VoMapper(cp)
        getLrmsInfo(cp) 
        print_CE(cp)
        print_VOViewLocal(cp)
    except Exception, e:
        log.exception(e)
        raise
Esempio n. 52
0
def main():
    """
    Main wrapper for the Condor batch system GIP information.
    """
    try:
        cp = config()
        doPath(cp)

        #vo_map = VoMapper(cp)
        getLrmsInfo(cp)
        print_CE(cp)
        print_VOViewLocal(cp)
    except Exception, e:
        log.exception(e)
        raise
Esempio n. 53
0
def main():
    try:
        # Load up the site configuration
        cp = config()
        se_only = cp_getBoolean(cp, "gip", "se_only", False)
        if not se_only and 'VDT_LOCATION' in os.environ:

            # get the VDT version
            vdt_version_cmd = os.path.expandvars(
                "$VDT_LOCATION/vdt/bin/") + 'vdt-version --no-wget'
            vdt_version_out = runCommand(vdt_version_cmd).readlines()

            gip_re = re.compile('Generic Information Provider\s+(.*?)\s*-.*')
            gip_version = 'UNKNOWN'
            for line in vdt_version_out:
                m = gip_re.match(line)
                if m:
                    gip_version = m.groups()[0]
                    break

            gip_version += '; $Revision$'

            # Get the timestamp in the two formats we wanted
            now = time.strftime("%a %b %d %T UTC %Y", time.gmtime())

            # Load up the template for GlueLocationLocalID
            # To view its contents, see $VDT_LOCATION/gip/templates/GlueCluster
            template = getTemplate("GlueCluster", "GlueLocationLocalID")
            cluster_id = getClusterID(cp)
            for subClusterId in getSubClusterIDs(cp):
                # Dictionary of data to fill in for GlueLocationLocalID
                info = {
                    'locationId': 'GIP_VERSION',
                    'subClusterId': subClusterId,
                    'clusterId': cluster_id,
                    'locationName': 'GIP_VERSION',
                    'version': gip_version,
                    'path': now,
                }

                # Spit out our template, fill it with the appropriate info.
                printTemplate(template, info)

    except Exception, e:
        # Log error, then report it via stderr.
        log.exception(e)
        sys.stdout = sys.stderr
        raise
Esempio n. 54
0
 def run_test_config(self, testconfig):
     os.environ['GIP_TESTING'] = "1"
     cfg_name = os.path.join("test_configs", testconfig)
     if not os.path.exists(cfg_name):
         self.fail(msg="Test configuration %s does not exist." % cfg_name)
     cp = config(cfg_name)
     providers_path = cp_get(cp, "gip", "provider_dir", "$GIP_LOCATION/" \
                             "providers")
     providers_path = os.path.expandvars(providers_path)
     se_provider_path = os.path.join(providers_path, 'storage_element.py')
     cmd = se_provider_path + " --config %s" % cfg_name
     print cmd
     fd = os.popen(cmd)
     entries = read_ldap(fd, multi=True)
     self.failIf(fd.close(), msg="Run of storage element provider failed!")
     return entries, cp
Esempio n. 55
0
def main():
    try:
        cp = config()
        slurm_path = cp_get(cp, "slurm", "slurm_path", ".")
        addToPath(slurm_path)
        # adding slurm_path/bin to the path as well, since slurm/torque home
        # points to /usr/local and the binaries exist in /usr/local/bin
        addToPath(slurm_path + "/bin")
        vo_map = VoMapper(cp)
        slurmVersion = getLrmsInfo(cp)
        queueInfo = print_CE(cp)
        print_VOViewLocal(queueInfo, cp)
    except Exception, e:
        sys.stdout = sys.stderr
        log.exception(e)
        raise
Esempio n. 56
0
 def test_alter_attributes(self):
     """
     Make sure the alter-attributes.conf file works properly
     """
     cp = config("test_modules/simple/config")
     cp.set("gip", "alter_attributes",
            "test_modules/simple/alter_attributes")
     has_ce = False
     entries = osg_info_wrapper.main(cp, return_entries=True)
     for entry in entries:
         if entry.dn[0] == 'GlueCEUniqueID=red.unl.edu:2119/jobmanager' \
                 '-pbs-workq':
             has_ce = True
             self.assertEquals(entry.glue['CEPolicyAssignedJobSlots'][0], \
                 '1235', msg="Plugin did not get applied properly")
     self.assertEquals(has_ce, True, msg="Static info was not included.")