Exemple #1
0
def get_vos_from_acbr(acbr):
    acbr_lines = acbr.splitlines()
    vos = sets.Set()
    for line in acbr_lines:
        acbr = line.split()[-1]
        try:
            acbr = normalizeFQAN(acbr)
            acbr = acbr.split('/')
            if len(acbr) == 1 or len(acbr[0]) > 0:
                continue
            acbr = acbr[1]
        except:
            continue
        vos.add(acbr)
    return vos
Exemple #2
0
def get_vos_from_acbr(acbr):
    acbr_lines = acbr.splitlines()
    vos = sets.Set()
    for line in acbr_lines:
        acbr = line.split()[-1]
        try:
            acbr = normalizeFQAN(acbr)
            acbr = acbr.split('/')
            if len(acbr) == 1 or len(acbr[0]) > 0:
                continue
            acbr = acbr[1]
        except:
            continue
        vos.add(acbr)
    return vos
Exemple #3
0
    def parseVOInfos_fromReservations(self):
        log.debug("Starting 'parseVOInfos_fromReservations'")
        seUniqueID = self.getUniqueID()

        # The VOInfo objects should correspond to reservation DESCRIPTIONs,
        # which may map to multiple reservations
        voinfo = {}
        log.debug("There are %i reservations." % len(self.handler.reservations))
        for id, reservation in self.handler.reservations.items():
            desc = reservation.get('description', 'DEFAULT')
            if desc.lower() == 'null':
                desc = 'DEFAULT'
            reservation_set = voinfo.setdefault(desc, [])
            reservation_set.append(reservation)

        log.debug("VOInfo objects: %s" % str(voinfo))

        # Iterate through all the link groups, and then go through all the
        # reservations in that link group.
        for lgid, linkgroup in self.handler.linkgroups.items():
            # Determine ACBRs and allowed VOs
            found_reservation_vos = sets.Set()
            allowed_acbrs = getLGAllowedVOs(self._cp,
                linkgroup.get('acbrs', ''), linkgroup.get('name', ''))
            fqans = [normalizeFQAN(i) for i in allowed_acbrs]
            all_lg_vos = sets.Set([i.split('/')[1] for i in fqans])

            # Find the corresponding SA
            found_sa = False
            lgname = linkgroup.get('name', '')
            for sa in self.sas:
                if sa.get('name', None) != lgname:
                    continue
                found_sa = True
                break
            if not found_sa:
                continue

            # Advertise the right tag for any VO which has a space reservation
            # in this link group.
            for tag, reservations_set in voinfo.items():
                for info in reservations_set:
                    if info.get('linkgroupref', None) != lgid:
                        continue
                    log.debug("Analyzing reservation: %s" % str(info))
                    # Regardless of who owns the reservation, anyone who can
                    # write into the LG can write into the reservation.
                    #if len(str(info.get('FQAN', ''))) == 0:
                    #    allowed_acbrs = getLGAllowedVOs(self._cp, info.get(
                    #        'acbrs', ''))
                    #else:
                    #    allowed_acbrs = ['VOMS:' +str(info.get('FQAN', ''))]
                    fqans = [normalizeFQAN(i) for i in allowed_acbrs]
                    vos = [i.split('/')[1] for i in fqans]
                    found_reservation_vos.update(vos)
                    if len(vos) == 0:
                        continue
                    path = self.getPathForSA(lgname, vos[0],
                        section=self._section)
                    myid = '%s:%s' % (tag, info.get('id', 'UNKNOWN'))
                    info = {'voInfoID': myid,
                            'seUniqueID': seUniqueID,
                            'name': myid,
                            'path': path,
                            'tag': tag,
                            'acbr': '\n'.join(['GlueVOInfoAccessControlBaseRule: '\
                                '%s' % i for i in allowed_acbrs]),
                            'saLocalID': sa['saLocalID'],
                            }
                    self.vos.append(info)


            # For any VO with no pre-existing reservation, but which is allowed
            # to make reservations, also do a VOInfo object.
            for vo in all_lg_vos.difference(found_reservation_vos):
                vo = normalizeFQAN(i).split('/')[1]
                path = self.getPathForSA(lgname, vo,
                    section=self._section)
                id = '%s' % vo
                info = {'voInfoID': id,
                        'seUniqueID': seUniqueID,
                        'name': id,
                        'path': path,
                        'tag': '%s with no reserved space' % vo,
                        'acbr': 'GlueVOInfoAccessControlBaseRule: VO:%s' % vo,
                        'saLocalID': sa['saLocalID'],
                       }
                self.vos.append(info)