Example #1
0
    def __init__(self,
                 vo=None,
                 adminUrl=False,
                 attributesUrl=False,
                 certificatesUrl=False):

        if vo is None:
            vo = getVO()
        if not vo:
            raise Exception('No VO name given')

        self.vo = vo
        self.vomsVO = getVOOption(vo, "VOMSName")
        if not self.vomsVO:
            raise Exception("Can not get VOMS name for VO %s" % vo)
        self.__soapClients = {}
        for key, url in (('Admin', adminUrl), ('Attributes', attributesUrl),
                         ('Certificates', certificatesUrl)):
            urls = []
            if not url:
                url = gConfig.getValue(
                    "/Registry/VO/%s/VOMSServices/VOMS%s" % (self.vo, key), "")
            if not url:
                result = gConfig.getSections('/Registry/VO/%s/VOMSServers' %
                                             self.vo)
                if result['OK']:
                    vomsServers = result['Value']
                    for server in vomsServers:
                        urls.append('https://%s:8443/voms/%s/services/VOMS%s' %
                                    (server, self.vomsVO, key))
            else:
                urls = [url]

            gotURL = False
            for url in urls:
                retries = 3
                while retries:
                    retries -= 1
                    try:
                        client = getSOAPClient("%s?wsdl" % url)
                        client.set_options(headers={"X-VOMS-CSRF-GUARD": "1"})
                        self.__soapClients[key] = client
                        gotURL = True
                        break
                    except Exception:
                        pass
                if gotURL:
                    break
            if not gotURL:
                raise Exception(
                    'Could not connect to the %s service for VO %s' %
                    (key, self.vo))
Example #2
0
 def __init__( self, adminUrl = False, attributesUrl = False ):
   self.__soapClients = {}
   for key, url in ( ( 'Admin', adminUrl ), ( 'Attributes', attributesUrl ) ):
     if not url:
       url = gConfig.getValue( "/Registry/VOMS/URLs/VOMS%s" % key, "" )
     if not url:
       raise Exception( "No URL defined for VOMS%s" % key )
     retries = 3
     while retries:
       retries -= 1
       try:
         self.__soapClients[ key ] = getSOAPClient( "%s?wsdl" % url )
         break
       except Exception:
         if retries:
           pass
         else:
           raise
Example #3
0
 def __init__(self, adminUrl=False, attributesUrl=False):
     self.__soapClients = {}
     for key, url in (('Admin', adminUrl), ('Attributes', attributesUrl)):
         if not url:
             url = gConfig.getValue("/Registry/VOMS/URLs/VOMS%s" % key, "")
         if not url:
             raise Exception("No URL defined for VOMS%s" % key)
         retries = 3
         while retries:
             retries -= 1
             try:
                 self.__soapClients[key] = getSOAPClient("%s?wsdl" % url)
                 break
             except Exception:
                 if retries:
                     pass
                 else:
                     raise
Example #4
0
  def __init__( self, vo = None, adminUrl = False, attributesUrl = False, certificatesUrl = False ):

    if vo is None:
      vo = getVO()
    if not vo:
      raise Exception( 'No VO name given' )

    self.vo = vo
    self.vomsVO = getVOOption( vo, "VOMSName" )
    if not self.vomsVO:
      raise Exception( "Can not get VOMS name for VO %s" % vo )
    self.__soapClients = {}
    for key, url in ( ( 'Admin', adminUrl ), ( 'Attributes', attributesUrl ), ( 'Certificates', certificatesUrl ) ):
      urls = []
      if not url:
        url = gConfig.getValue( "/Registry/VO/%s/VOMSServices/VOMS%s" % ( self.vo, key ), "" )
      if not url:
        result = gConfig.getSections( '/Registry/VO/%s/VOMSServers' % self.vo )
        if result['OK']:
          vomsServers = result['Value']
          for server in vomsServers:
            urls.append( 'https://%s:8443/voms/%s/services/VOMS%s' % ( server, self.vomsVO, key ) )
      else:
        urls = [url]

      gotURL = False
      for url in urls:
        retries = 3
        while retries:
          retries -= 1
          try:
            client = getSOAPClient( "%s?wsdl" % url )
            client.set_options(headers={"X-VOMS-CSRF-GUARD":"1"})
            self.__soapClients[ key ] = client
            gotURL = True
            break
          except Exception:
            pass
        if gotURL:
          break
      if not gotURL:
        raise Exception( 'Could not connect to the %s service for VO %s' % ( key, self.vo ) )
Example #5
0
 def __init__( self, adminUrl = False, attributesUrl = False, certificatesUrl = False ):
   self.__soapClients = {}
   for key, url in ( ( 'Admin', adminUrl ), ( 'Attributes', attributesUrl ), ( 'Certificates', certificatesUrl ) ):
     if not url:
       url = gConfig.getValue( "/Registry/VOMS/URLs/VOMS%s" % key, "" )
     if not url:
       raise Exception( "No URL defined for VOMS%s" % key )
     retries = 3
     while retries:
       retries -= 1
       try:
         client = getSOAPClient( "%s?wsdl" % url )
         client.set_options(headers={"X-VOMS-CSRF-GUARD":"1"})
         self.__soapClients[ key ] = client
         break
       except Exception:
         if retries:
           pass
         else:
           raise