Example #1
0
 def getVOsForSpace(self, space):
     all_vos = voListStorage(self._cp)
     if space:
         myspace = space.lower()
     else:
         myspace = ''
     for vo in all_vos:
         myvo = vo.lower()
         if myspace.find(myvo) >= 0:
             return [myvo]
     return super(BestmanInfo, self).getVOsForSpace(space)
Example #2
0
 def getVOsForSpace(self, space):
     all_vos = voListStorage(self._cp)
     if space:
         myspace = space.lower()
     else:
         myspace = ''
     for vo in all_vos:
         myvo = vo.lower()
         if myspace.find(myvo) >= 0:
             return [myvo]
     return super(BestmanInfo, self).getVOsForSpace(space)
Example #3
0
def getLGAllowedVOs(cp, vos, name=None):
    """
    Return the allowed VOs for a certain linkgroup.

    Uses getAllowedVOs to determine any manual mappings from the config file.
    """
    allowed = []
    # See if we've manually set this information
    if name:
        try:
            return getAllowedVOs(cp, name, return_default=False)
        except:
            pass
    mapper = VoMapper(cp)
    for vo_policy in vo_re.finditer(vos):
        vo_policy = vo_policy.groups()[0]
        if vo_policy == '*:*':
            return ['VO:%s' % i for i in voListStorage(cp)]
        if vo_policy.startswith('/'):
            log.debug("VO Policy: %s" % vo_policy)
            info = tuple(vo_policy.split(':'))
            if len(info) == 2:
                try:
                    allowed.append('VOMS:%s/Role=%s' % info)
                except:
                    pass
            else:
                log.error("Invalid VO policy: %s" % vo_policy)
        else:
            try:
                vo = mapper[vo_policy.split(':')[0]]
                allowed.append('VO:%s' % vo)
            except:
                pass
    # Remove duplicates and return
    allowed = list(sets.Set(allowed))

    # If there aren't any allowed VOs, then use the manual overrides.
    if not allowed:
        return getAllowedVOs(cp, name)
    return allowed
Example #4
0
def getLGAllowedVOs(cp, vos, name=None):
    """
    Return the allowed VOs for a certain linkgroup.

    Uses getAllowedVOs to determine any manual mappings from the config file.
    """
    allowed = []
    # See if we've manually set this information
    if name:
        try:
            return getAllowedVOs(cp, name, return_default=False)
        except:
            pass
    mapper = VoMapper(cp)
    for vo_policy in vo_re.finditer(vos):
        vo_policy = vo_policy.groups()[0]
        if vo_policy == '*:*':
            return ['VO:%s' % i for i in voListStorage(cp)]
        if vo_policy.startswith('/'):
            log.debug("VO Policy: %s" % vo_policy)
            info = tuple(vo_policy.split(':'))
            if len(info) == 2:
                try:
                    allowed.append('VOMS:%s/Role=%s' % info)
                except:
                    pass
            else:
                log.error("Invalid VO policy: %s" % vo_policy)
        else:
            try:
                vo = mapper[vo_policy.split(':')[0]]
                allowed.append('VO:%s' % vo)
            except:
                pass
    # Remove duplicates and return
    allowed = list(sets.Set(allowed))

    # If there aren't any allowed VOs, then use the manual overrides.
    if not allowed:
        return getAllowedVOs(cp, name)
    return allowed
Example #5
0
def getAllowedVOs(cp, space, return_default=True):
    """
    Returns a list of ACBRs for VOs which are allowed to access this space.

    Throws a general exception if return_default=False and there's no explicit
    mapping for this space.
    """
    allowed_vos = cp_get(cp, "dcache", "space_%s_vos" % space, None)
    if not allowed_vos:
        allowed_vos = cp_get(cp, "dcache", "allowed_vos", None)
        if not allowed_vos:
            if return_default:
                allowed_vos = cp_get(cp, "dcache", "default_policy", "*")
            else:
                raise Exception("No manual access controls for %s." % space)
    allowed_vos = [i.strip() for i in allowed_vos.split(',') if i.strip()]
    if '*' in allowed_vos:
        for vo in voListStorage(cp):
            if vo not in allowed_vos:
                allowed_vos.append(vo)
        allowed_vos.remove('*')
    allowed_vos = sets.Set(allowed_vos)
    return list(['VO:%s' % i for i in allowed_vos])
Example #6
0
def getAllowedVOs(cp, space, return_default=True):
    """
    Returns a list of ACBRs for VOs which are allowed to access this space.

    Throws a general exception if return_default=False and there's no explicit
    mapping for this space.
    """
    allowed_vos = cp_get(cp, "dcache", "space_%s_vos" % space, None)
    if not allowed_vos:
        allowed_vos = cp_get(cp, "dcache", "allowed_vos", None)
        if not allowed_vos:
            if return_default:
                allowed_vos = cp_get(cp, "dcache", "default_policy", "*")
            else:
                raise Exception("No manual access controls for %s." % space)
    allowed_vos = [i.strip() for i in allowed_vos.split(',') if i.strip()]
    if '*' in allowed_vos:
        for vo in voListStorage(cp):
            if vo not in allowed_vos:
                allowed_vos.append(vo)
        allowed_vos.remove('*')
    allowed_vos = sets.Set(allowed_vos)
    return list(['VO:%s' % i for i in allowed_vos])
Example #7
0
    def getSRMs(self):
        try:
            # BUGFIX: Resolve the IP address of srm host that the admin
            # specifies.  If this IP address matches the IP address given by
            # dCache, then we will print out the admin-specified hostname
            # instead of looking it up.  This is for sites where the SRM host
            # is a CNAME instead of the A name.
            srm_host = cp_get(self._cp, self._section, "srm_host", None)
            srm_ip = None
            if srm_host:
                try:
                    srm_ip = socket.gethostbyname(srm_host)
                except:
                    pass
            #vos = [i.strip() for i in cp.get("vo", "vos").split(',')]

            # Determine the VOs which are allowed to use this storage element
            acbr_tmpl = '\nGlueServiceAccessControlRule: VO:%s' \
                '\nGlueServiceAccessControlRule: %s'
            acbr = ''
            vos = voListStorage(self._cp)
            for vo in vos:
                acbr += acbr_tmpl % (vo, vo)
            acbr = acbr[1:]

            # Use the srm-LoginBroker cell to list all the SRM cells available.
            results = self.admin.execute("srm-LoginBroker", "ls")
            srms = []
            for line in results.split("\n"):
                if len(line.strip()) == 0:
                    continue
                #Lines have the following format:
            #SRM-srm@srm-srmDomain;Storage;{SRM,1.1.1};[srm:8443];<0,300000>;
                doorname, kind, versions, host, logins, dummy = line.split(';')
                protocol, version = versions[1:-1].split(',')
                hostname, port = host[1:-1].split(':')
                hostname = hostname.split(',')[0]
                # Make sure we have a FQDN (dCache has a nasty habit of
                # dropping the domain name internally.
                try:
                    hostname = socket.getfqdn(hostname)
                    hostname_ip = socket.gethostbyname(hostname)
                except:
                    hostname_ip = None
                if hostname_ip != None and hostname_ip == srm_ip and \
                        srm_host != None:
                    hostname = srm_host

                # From the SRM info, build the information for the GLUE entity.
                info = {
                    "serviceType": "SRM",
                    "acbr": acbr,
                    "cpLocalID": doorname,
                    "protocolType": "SRM",
                    "capability": "control",
                    "status": "OK",
                    "statusInfo": "SRM instance is responding.",
                    "wsdl": "http://sdm.lbl.gov/srm-wg/srm.v1.1.wsdl",
                    "semantics": "http://sdm.lbl.gov/srm-wg/doc/srm.v1.0.pdf",
                    "startTime": "1970-01-01T00:00:00Z",
                }

                # Augment the information with SRM v1 protocol information, then
                # print out the control and service entries
                info['version'] = "1.1.0"
                endpoint = "httpg://%s:%i/srm/managerv1" % (hostname,
                                                            int(port))
                info['endpoint'] = endpoint
                info['serviceID'] = endpoint
                info['uri'] = endpoint
                info['url'] = endpoint
                info['serviceName'] = endpoint
                # Bugfix: Make the control protocol unique ID unique between
                # the SRM versions.
                info['cpLocalID'] = doorname + '_srmv1'
                srms.append(info)
                info = dict(info)

                # Change the v1 information to v2 and add it again to the list.
                info['version'] = "2.2.0"
                endpoint = "httpg://%s:%i/srm/managerv2" % (hostname,
                                                            int(port))
                info['endpoint'] = endpoint
                info['serviceID'] = endpoint
                info['uri'] = endpoint
                info['url'] = endpoint
                info['serviceName'] = endpoint
                info["wsdl"] = "http://sdm.lbl.gov/srm-wg/srm.v2.2.wsdl"
                info[
                    "semantics"] = "http://sdm.lbl.gov/srm-wg/doc/SRM.v2.2.pdf"
                # Bugfix: Make the control protocol unique ID unique between
                # the SRM versions
                info['cpLocalID'] = doorname + '_srmv2'
                srms.append(info)
            return srms

        except Exception, e:
            log.exception(e)
            return super(DCacheInfo, self).getSRMs()
Example #8
0
    def getSRMs(self):
        prev_srm_host = None
        try:
            info = super(DCacheInfo19, self).getSRMs()
            endpoint = info[0]['endpoint']
            srmhost_re = re.compile("://(.*?):")
            m = srmhost_re.search(endpoint)
            if m:
                prev_srm_host = m.groups()[0]
        except:
            raise
        try:
            # BUGFIX: Resolve the IP address of srm host that the admin
            # specifies.  If this IP address matches the IP address given by
            # dCache, then we will print out the admin-specified hostname
            # instead of looking it up.  This is for sites where the SRM host
            # is a CNAME instead of the A name.
            srm_host = cp_get(self._cp, self._section, "srm_host", None)
            srm_ip = None
            if srm_host:
                try:
                    srm_ip = socket.gethostbyname(srm_host)
                except:
                    pass
            #vos = [i.strip() for i in cp.get("vo", "vos").split(',')]

            if prev_srm_host:
                srm_host = prev_srm_host

            # Determine the VOs which are allowed to use this storage element
            acbr_tmpl = '\nGlueServiceAccessControlRule: VO:%s' \
                '\nGlueServiceAccessControlRule: %s'
            acbr = ''
            
            vos = voListStorage(self._cp, section=self._section)
            for vo in vos:
                acbr += acbr_tmpl % (vo, vo)
            acbr = acbr[1:]
            srms = []

            # Use the srm-LoginBroker cell to list all the SRM cells available.
            for srm in self.handler.doors.values():
                if srm.get('family', '') != 'SRM':
                    continue
                if not srm.get('name', ''):
                    continue
                doorname = srm.get('name', '')
                hostname = srm.get('FQDN', '')
                port = srm.get('port', 0)
                # Make sure we have a FQDN (dCache has a nasty habit of
                # dropping the domain name internally.
                try:
                    hostname = socket.getfqdn(hostname)
                    hostname_ip = socket.gethostbyname(hostname)
                except:
                    hostname_ip = None
                if hostname_ip != None and hostname_ip == srm_ip and \
                        srm_host != None:
                    hostname = srm_host

                if prev_srm_host:
                    hostname = prev_srm_host

                # From the SRM info, build the information for the GLUE entity.
                info = {
                    "serviceType"  : "SRM",
                    "acbr"         : acbr,
                    "cpLocalID"    : srm.get('name', ''),
                    "protocolType" : "SRM",
                    "capability"   : "control",
                    "status"       : "OK",
                    "statusInfo"   : "SRM instance is responding.",
                    "wsdl"         : "http://sdm.lbl.gov/srm-wg/srm.v1.1.wsdl",
                    "semantics"  : "http://sdm.lbl.gov/srm-wg/doc/srm.v1.0.pdf",
                    "startTime"    : "1970-01-01T00:00:00Z",
                    }

                # Augment the information with SRM v1 protocol information, then
                # print out the control and service entries
                info['version'] = "1.1.0"
                endpoint = "httpg://%s:%i/srm/managerv1" % (hostname, int(port))
                info['endpoint'] = endpoint
                info['serviceID'] = endpoint
                info['uri'] = endpoint
                info['url'] = endpoint
                info['serviceName'] = endpoint
                # Bugfix: Make the control protocol unique ID unique between
                # the SRM versions.
                info['cpLocalID'] = doorname + '_srmv1'
                srms.append(info)
                info = dict(info)

                # Change the v1 information to v2 and add it again to the list.
                info['version'] = "2.2.0"
                endpoint = "httpg://%s:%i/srm/managerv2" % (hostname, int(port))
                info['endpoint'] = endpoint
                info['serviceID'] = endpoint
                info['uri'] = endpoint
                info['url'] = endpoint
                info['serviceName'] = endpoint
                info["wsdl"] = "http://sdm.lbl.gov/srm-wg/srm.v2.2.wsdl"
                info["semantics"] = "http://sdm.lbl.gov/srm-wg/doc/SRM.v2.2.pdf"
                # Bugfix: Make the control protocol unique ID unique between
                # the SRM versions
                info['cpLocalID'] = doorname + '_srmv2'
                srms.append(info)
            return srms

        except Exception, e:
            log.exception(e)
            return super(DCacheInfo19, self).getSRMs()
Example #9
0
        "port": 2811,
        "onlineTotal": 0,
        "nearlineTotal": nt,
        "onlineUsed": used,
        "nearlineUsed": nu,
        "architecture": arch,
        "free": available,
        "total": total,
        "bdii": cp_get(cp, "bdii", "endpoint", "Unknown"),
        "siteUniqueID": siteUniqueID,
        "arch": arch,
    }
    seTemplate = getTemplate("GlueSE", "GlueSEUniqueID")
    printTemplate(seTemplate, info)

    vos = voListStorage(cp)
    try:
        used, available, total = getClassicSESpace(cp, total=True)
    except Exception, e:
        used = 0
        available = 0
        total = 0
    acbr = []
    for vo in vos:
        acbr.append("GlueSAAccessControlBaseRule: VO:%s" % vo)
    acbr = '\n'.join(acbr)
    path = cp_get(cp, "osg_dirs", "data", "/UNKNOWN")
    info = {
        "saLocalID": seUniqueID,
        "seUniqueID": seUniqueID,
        "root": "/",
Example #10
0
             "port"           : 2811,
             "onlineTotal"    : 0,
             "nearlineTotal"  : nt,
             "onlineUsed"     : used,
             "nearlineUsed"   : nu,
             "architecture"   : arch,
             "free"           : available,
             "total"          : total,
             "bdii"           : cp_get(cp, "bdii", "endpoint", "Unknown"),
             "siteUniqueID"   : siteUniqueID,
             "arch"           : arch,
           }
    seTemplate = getTemplate("GlueSE", "GlueSEUniqueID")
    printTemplate(seTemplate, info)

    vos = voListStorage(cp)
    try:
        used, available, total = getClassicSESpace(cp, total=True)
    except Exception, e:
        used = 0
        available = 0
        total = 0
    acbr = []
    for vo in vos:
        acbr.append("GlueSAAccessControlBaseRule: VO:%s" % vo)
    acbr = '\n'.join(acbr)
    path = cp_get(cp, "osg_dirs", "data", "/UNKNOWN")
    info = {"saLocalID"        : seUniqueID,
            "seUniqueID"       : seUniqueID,
            "root"             : "/",
            "path"             : path,
Example #11
0
    def getSRMs(self):
        try:
            # BUGFIX: Resolve the IP address of srm host that the admin
            # specifies.  If this IP address matches the IP address given by
            # dCache, then we will print out the admin-specified hostname 
            # instead of looking it up.  This is for sites where the SRM host 
            # is a CNAME instead of the A name.
            srm_host = cp_get(self._cp, self._section, "srm_host", None)
            srm_ip = None
            if srm_host:
                try:
                    srm_ip = socket.gethostbyname(srm_host)
                except:
                    pass
            #vos = [i.strip() for i in cp.get("vo", "vos").split(',')]

            # Determine the VOs which are allowed to use this storage element
            acbr_tmpl = '\nGlueServiceAccessControlRule: VO:%s' \
                '\nGlueServiceAccessControlRule: %s'
            acbr = ''
            vos = voListStorage(self._cp)
            for vo in vos:
                acbr += acbr_tmpl % (vo, vo)
            acbr = acbr[1:]

            # Use the srm-LoginBroker cell to list all the SRM cells available.
            results = self.admin.execute("srm-LoginBroker", "ls")
            srms = []
            for line in results.split("\n"):
                if len(line.strip()) == 0:
                    continue
                #Lines have the following format:
               #SRM-srm@srm-srmDomain;Storage;{SRM,1.1.1};[srm:8443];<0,300000>;
                doorname, kind, versions, host, logins, dummy = line.split(';')
                protocol, version = versions[1:-1].split(',')
                hostname, port = host[1:-1].split(':')
                hostname = hostname.split(',')[0]
                # Make sure we have a FQDN (dCache has a nasty habit of
                # dropping the domain name internally.
                try:
                    hostname = socket.getfqdn(hostname)
                    hostname_ip = socket.gethostbyname(hostname)
                except:
                    hostname_ip = None 
                if hostname_ip != None and hostname_ip == srm_ip and \
                        srm_host != None:
                    hostname = srm_host
        
                # From the SRM info, build the information for the GLUE entity.
                info = {
                    "serviceType"  : "SRM",
                    "acbr"         : acbr,
                    "cpLocalID"    : doorname,
                    "protocolType" : "SRM",
                    "capability"   : "control",
                    "status"       : "OK",
                    "statusInfo"   : "SRM instance is responding.",
                    "wsdl"         : "http://sdm.lbl.gov/srm-wg/srm.v1.1.wsdl",
                    "semantics"  : "http://sdm.lbl.gov/srm-wg/doc/srm.v1.0.pdf",
                    "startTime"    : "1970-01-01T00:00:00Z",
                    }
        
                # Augment the information with SRM v1 protocol information, then
                # print out the control and service entries
                info['version'] = "1.1.0"
                endpoint = "httpg://%s:%i/srm/managerv1" % (hostname, int(port))
                info['endpoint'] = endpoint
                info['serviceID'] = endpoint
                info['uri'] = endpoint
                info['url'] = endpoint
                info['serviceName'] = endpoint
                # Bugfix: Make the control protocol unique ID unique between 
                # the SRM versions.
                info['cpLocalID'] = doorname + '_srmv1'
                srms.append(info)
                info = dict(info)

                # Change the v1 information to v2 and add it again to the list.
                info['version'] = "2.2.0"
                endpoint = "httpg://%s:%i/srm/managerv2" % (hostname, int(port))
                info['endpoint'] = endpoint
                info['serviceID'] = endpoint
                info['uri'] = endpoint
                info['url'] = endpoint
                info['serviceName'] = endpoint
                info["wsdl"] = "http://sdm.lbl.gov/srm-wg/srm.v2.2.wsdl"
                info["semantics"] = "http://sdm.lbl.gov/srm-wg/doc/SRM.v2.2.pdf"
                # Bugfix: Make the control protocol unique ID unique between 
                # the SRM versions
                info['cpLocalID'] = doorname + '_srmv2'
                srms.append(info)
            return srms

        except Exception, e:
            log.exception(e)
            return super(DCacheInfo, self).getSRMs()