예제 #1
0
    def getDescription(self):
        """ Get CE description as a dictionary
    """

        ceDict = {}
        for option, value in self.ceParameters.items():
            if type(value) == type([]):
                ceDict[option] = value
            elif type(value) == type(" "):
                tmpInt = self.__getInt(value)
                if tmpInt is not None:
                    self.log.debug("Found CE integer attribute: %s = %s" % (option, tmpInt))
                    ceDict[option] = tmpInt
                else:
                    self.log.debug("Found string attribute: %s = %s" % (option, value))
                    ceDict[option] = value
            elif type(value) == type(1) or type(value) == type(1.0):
                self.log.debug("Found integer attribute: %s = %s" % (option, value))
                ceDict[option] = value
            else:
                self.log.warn("Type of option %s = %s not determined" % (option, value))

        release = gConfig.getValue("/LocalSite/ReleaseVersion", version)
        ceDict["DIRACVersion"] = release
        ceDict["ReleaseVersion"] = release
        project = gConfig.getValue("/LocalSite/ReleaseProject", "")
        if project:
            ceDict["ReleaseProject"] = project

        return S_OK(ceDict)
예제 #2
0
  def getJDL( self ):
    """Returns CE JDL as a string.
    """

    # Add the CE parameters
    for option, value in self.ceParameters.items():
      if type( option ) == type( [] ):
        self.classAd.insertAttributeVectorString( option, value.split( ', ' ) )
      elif type( value ) == type( ' ' ):
        jdlInt = self.__getInt( value )
        if type( jdlInt ) == type( 1 ):
          self.log.debug( 'Found JDL integer attribute: %s = %s' % ( option, jdlInt ) )
          self.classAd.insertAttributeInt( option, jdlInt )
        else:
          self.log.debug( 'Found string attribute: %s = %s' % ( option, value ) )
          self.classAd.insertAttributeString( option, value )
      elif type( value ) == type( 1 ):
        self.log.debug( 'Found integer attribute: %s = %s' % ( option, value ) )
        self.classAd.insertAttributeInt( option, value )
      else:
        self.log.warn( 'Type of option %s = %s not determined' % ( option, value ) )

    # Add the CE requirements if any
    requirements = ''
    for option, value in self.ceRequirementDict.items():
      if type( value ) == type( ' ' ):
        jdlInt = self.__getInt( value )
        if type( jdlInt ) == type( 1 ):
          requirements += ' other.' + option + ' == %d &&' % ( jdlInt )
          self.log.debug( 'Found JDL reqt integer attribute: %s = %s' % ( option, jdlInt ) )
          self.classAd.insertAttributeInt( option, jdlInt )
        else:
          requirements += ' other.' + option + ' == "%s" &&' % ( value )
          self.log.debug( 'Found string reqt attribute: %s = %s' % ( option, value ) )
          self.classAd.insertAttributeString( option, value )
      elif type( value ) == type( 1 ):
        requirements += ' other.' + option + ' == %d &&' % ( value )
        self.log.debug( 'Found integer reqt attribute: %s = %s' % ( option, value ) )
        self.classAd.insertAttributeInt( option, value )
      else:
        self.log.warn( 'Could not determine type of:  %s = %s' % ( option, value ) )

    if requirements:
      if re.search( '&&$', requirements ):
        requirements = requirements[:-3]
      self.classAd.set_expression( 'Requirements', requirements )
    else:
      self.classAd.set_expression( 'Requirements', 'True' )

    release = gConfig.getValue( '/LocalSite/ReleaseVersion', version )
    self.classAd.insertAttributeString( 'DIRACVersion', release )
    self.classAd.insertAttributeString( 'ReleaseVersion', release )
    project = gConfig.getValue( "/LocalSite/ReleaseProject", "" )
    if project:
      self.classAd.insertAttributeString( 'ReleaseProject', project )
    if self.classAd.isOK():
      jdl = self.classAd.asJDL()
      return S_OK( jdl )
    else:
      return S_ERROR( 'ClassAd job is not valid' )
예제 #3
0
  def getDescription(self):
    """ Get CE description as a dictionary
    """

    ceDict = {}
    for option, value in self.ceParameters.iteritems():
      if isinstance(value, list):
        ceDict[option] = value
      elif isinstance(value, basestring):
        try:
          ceDict[option] = int(value)
        except ValueError:
          ceDict[option] = value
      elif isinstance(value, (int, long, float)):
        ceDict[option] = value
      else:
        self.log.warn('Type of option %s = %s not determined' % (option, value))

    release = gConfig.getValue('/LocalSite/ReleaseVersion', version)
    ceDict['DIRACVersion'] = release
    ceDict['ReleaseVersion'] = release
    project = gConfig.getValue("/LocalSite/ReleaseProject", "")
    if project:
      ceDict['ReleaseProject'] = project

    result = self.getCEStatus()
    if result['OK']:
      if 'AvailableProcessors' in result:
        cores = result['AvailableProcessors']
        ceDict['NumberOfProcessors'] = cores

    return S_OK(ceDict)
예제 #4
0
  def getDescription( self ):
    """ Get CE description as a dictionary
    """

    ceDict = {}
    for option, value in self.ceParameters.items():
      if type( value ) == type( [] ):
        ceDict[option] = value
      elif type( value ) == type( ' ' ):
        tmpInt = self.__getInt( value )
        if tmpInt is not None:
          self.log.debug( 'Found CE integer attribute: %s = %s' % ( option, tmpInt ) )
          ceDict[option] = tmpInt
        else:
          self.log.debug( 'Found string attribute: %s = %s' % ( option, value ) )
          ceDict[option] = value
      elif type( value ) == type( 1 ) or type( value ) == type( 1. ):
        self.log.debug( 'Found integer attribute: %s = %s' % ( option, value ) )
        ceDict[option] = value
      else:
        self.log.warn( 'Type of option %s = %s not determined' % ( option, value ) )

    release = gConfig.getValue( '/LocalSite/ReleaseVersion', version )
    ceDict['DIRACVersion'] = release
    ceDict['ReleaseVersion'] = release
    project = gConfig.getValue( "/LocalSite/ReleaseProject", "" )
    if project:
      ceDict['ReleaseProject'] = project

    return S_OK( ceDict )
예제 #5
0
    def __init__(self, ceName):
        """Standard constructor"""
        self.log = gLogger.getSubLogger(ceName)
        self.ceName = ceName
        self.ceParameters = {}
        self.proxy = ""
        self.valid = None
        self.mandatoryParameters = []
        self.batchSystem = None
        self.taskResults = {}
        self.minProxyTime = gConfig.getValue("/Registry/MinProxyLifeTime",
                                             10800)  # secs
        self.defaultProxyTime = gConfig.getValue(
            "/Registry/DefaultProxyLifeTime", 43200)  # secs
        self.proxyCheckPeriod = gConfig.getValue(
            "/Registry/ProxyCheckingPeriod", 3600)  # secs

        clsName = self.__class__.__name__
        if clsName.endswith("ComputingElement"):
            self.ceType = clsName[:-len("ComputingElement")]
        else:
            self.log.warning("%s should end with 'ComputingElement'!" %
                             clsName)
            self.ceType = clsName

        self.initializeParameters()
        self.log.debug("CE parameters", self.ceParameters)
예제 #6
0
    def getValidPropertiesForMethod(self, method, defaultProperties=False):
        """
    Get all authorized groups for calling a method

    :type  method: string
    :param method: Method to test
    :return: List containing the allowed groups
    """
        authProps = gConfig.getValue("%s/%s" % (self.authSection, method), [])
        if authProps:
            return authProps
        if defaultProperties:
            self.__authLogger.debug(
                "Using hardcoded properties for method %s : %s" %
                (method, defaultProperties))
            if not isinstance(defaultProperties, (list, tuple)):
                return List.fromChar(defaultProperties)
            return defaultProperties
        defaultPath = "%s/Default" % "/".join(method.split("/")[:-1])
        authProps = gConfig.getValue("%s/%s" % (self.authSection, defaultPath),
                                     [])
        if authProps:
            self.__authLogger.debug(
                "Method %s has no properties defined using %s" %
                (method, defaultPath))
            return authProps
        self.__authLogger.debug(
            "Method %s has no authorization rules defined. Allowing no properties"
            % method)
        return []
예제 #7
0
def initializeStorageElementHandler(serviceInfo):
    """  Initialize Storage Element global settings
  """

    global base_path
    global use_tokens_flag
    global max_storage_size
    cfgPath = serviceInfo['serviceSectionPath']

    base_path = gConfig.getValue("%s/BasePath" % cfgPath, base_path)
    if not base_path:
        gLogger.error('Failed to get the base path')
        return S_ERROR('Failed to get the base path')
    if not os.path.exists(base_path):
        os.makedirs(base_path)

    use_tokens_flag = gConfig.getValue("%s/UseTokens" % cfgPath,
                                       use_tokens_flag)
    max_storage_size = gConfig.getValue("%s/MaxStorageSize" % cfgPath,
                                        max_storage_size)

    gLogger.info('Starting DIRAC Storage Element')
    gLogger.info('Base Path: %s' % base_path)
    gLogger.info('Max size: %d MB' % max_storage_size)
    gLogger.info('Use access control tokens: ' + str(use_tokens_flag))
    return S_OK()
예제 #8
0
    def getDescription(self):
        """ Get CE description as a dictionary
    """

        ceDict = {}
        for option, value in self.ceParameters.items():
            if isinstance(value, list):
                ceDict[option] = value
            elif isinstance(value, basestring):
                try:
                    ceDict[option] = int(value)
                except ValueError:
                    ceDict[option] = value
            elif isinstance(value, (int, long, float)):
                ceDict[option] = value
            else:
                self.log.warn('Type of option %s = %s not determined' %
                              (option, value))

        release = gConfig.getValue('/LocalSite/ReleaseVersion', version)
        ceDict['DIRACVersion'] = release
        ceDict['ReleaseVersion'] = release
        project = gConfig.getValue("/LocalSite/ReleaseProject", "")
        if project:
            ceDict['ReleaseProject'] = project

        result = self.getCEStatus()
        if result['OK']:
            if 'AvailableProcessors' in result:
                cores = result['AvailableProcessors']
                ceDict['NumberOfProcessors'] = cores

        return S_OK(ceDict)
예제 #9
0
    def initialize(self, systemName, cfgPath):
        if self.__initialized:
            return
        self.__initialized = True

        from DIRAC.ConfigurationSystem.Client.Config import gConfig
        from os import getpid

        #self.__printDebug( "The configuration path is %s" % cfgPath )
        #Get the options for the different output backends
        retDict = gConfig.getOptionsDict("%s/BackendsOptions" % cfgPath)

        #self.__printDebug( retDict )
        if not retDict['OK']:
            cfgBackOptsDict = {
                'FileName': 'Dirac-log_%s.log' % getpid(),
                'Interactive': True,
                'SleepTime': 150
            }
        else:
            cfgBackOptsDict = retDict['Value']

        self.__backendOptions.update(cfgBackOptsDict)

        if not self.__backendOptions.has_key('Filename'):
            self.__backendOptions['FileName'] = 'Dirac-log_%s.log' % getpid()

        sleepTime = 150
        try:
            sleepTime = int(self.__backendOptions['SleepTime'])
        except:
            pass
        self.__backendOptions['SleepTime'] = sleepTime

        self.__backendOptions['Interactive'] = gConfig.getValue(
            "%s/BackendsOptions/Interactive" % cfgPath, True)

        self.__backendOptions['Site'] = DIRAC.siteName()

        #Configure outputs
        desiredBackends = gConfig.getValue("%s/LogBackends" % cfgPath,
                                           'stdout')
        self.registerBackends(List.fromChar(desiredBackends))
        #Configure verbosity
        defaultLevel = Logger.defaultLogLevel
        if "Scripts" in cfgPath:
            defaultLevel = gConfig.getValue('/Systems/Scripts/LogLevel',
                                            Logger.defaultLogLevel)
        self.setLevel(gConfig.getValue("%s/LogLevel" % cfgPath, defaultLevel))
        #Configure framing
        self._showCallingFrame = gConfig.getValue("%s/LogShowLine" % cfgPath,
                                                  self._showCallingFrame)
        #Get system name
        self._systemName = str(systemName)

        if not self.__backendOptions['Interactive']:
            ExitCallback.registerExitCallback(self.flushAllMessages)
예제 #10
0
파일: Logger.py 프로젝트: bmb/DIRAC
  def initialize( self, systemName, cfgPath ):
    if self.__initialized:
      return
    self.__initialized = True

    from DIRAC.ConfigurationSystem.Client.Config import gConfig
    from os import getpid

    #self.__printDebug( "The configuration path is %s" % cfgPath )
    #Get the options for the different output backends
    retDict = gConfig.getOptionsDict( "%s/BackendsOptions" % cfgPath )

    #self.__printDebug( retDict )
    if not retDict[ 'OK' ]:
      cfgBackOptsDict = { 'FileName': 'Dirac-log_%s.log' % getpid(), 'Interactive': True, 'SleepTime': 150 }
    else:
      cfgBackOptsDict = retDict[ 'Value' ]

    self.__backendOptions.update( cfgBackOptsDict )

    if not self.__backendOptions.has_key( 'Filename' ):
      self.__backendOptions[ 'FileName' ] = 'Dirac-log_%s.log' % getpid()

    sleepTime = 150
    try:
      sleepTime = int ( self.__backendOptions[ 'SleepTime' ] )
    except:
      pass
    self.__backendOptions[ 'SleepTime' ] = sleepTime

    self.__backendOptions[ 'Interactive' ] = gConfig.getValue( "%s/BackendsOptions/Interactive" % cfgPath, True )

    self.__backendOptions[ 'Site' ] = DIRAC.siteName()

    #Configure outputs
    desiredBackends = gConfig.getValue( "%s/LogBackends" % cfgPath, 'stdout' )
    self.registerBackends( List.fromChar( desiredBackends ) )
    #Configure verbosity
    defaultLevel = Logger.defaultLogLevel
    if "Scripts" in cfgPath:
      defaultLevel = gConfig.getValue( '/Systems/Scripts/LogLevel', Logger.defaultLogLevel )
    self.setLevel( gConfig.getValue( "%s/LogLevel" % cfgPath, defaultLevel ) )
    #Configure framing
    self._showCallingFrame = gConfig.getValue( "%s/LogShowLine" % cfgPath, self._showCallingFrame )
    #Get system name
    self._systemName = str( systemName )

    if not self.__backendOptions['Interactive']:
      ExitCallback.registerExitCallback( self.flushAllMessages )
예제 #11
0
 def display(self):
   if request.params.has_key( "site" ) and len( request.params[ "site" ] ) > 0:
     if str( request.params[ "site" ] ) != "All":
       c.select = str( request.params[ "site" ] )
   else:
     c.select =  gConfig.getValue( "/Website/DefaultExternalURL", "http://diracgrid.org" )
   return render( "web/External.mako" )
예제 #12
0
 def __discoverVO( self ):
   #Which setup to use?
   if self.KW_VO in self.kwargs and self.kwargs[ self.KW_VO ]:
     self.vo = str( self.kwargs[ self.KW_VO ] )
   else:
     self.vo = gConfig.getValue( "/DIRAC/VirtualOrganization", "unknown" )
   return S_OK()
예제 #13
0
def getVO(defaultVO=""):
    """
    Return VO from configuration
    """
    from DIRAC import gConfig

    return gConfig.getValue("/DIRAC/VirtualOrganization", defaultVO)
예제 #14
0
def getResourceDict(ceName=None):
    """Look into LocalSite for Resource Requirements
  """
    from DIRAC.WorkloadManagementSystem.private.Queues import maxCPUSegments

    ret = gConfig.getOptionsDict("/LocalSite/ResourceDict")
    if not ret["OK"]:
        resourceDict = {}
    else:
        # FIXME: es mejor copiar el diccionario?
        resourceDict = dict(ret["Value"])

    # if a CE Name is given, check the corresponding section
    if ceName:
        ret = gConfig.getOptionsDict("/LocalSite/%s/ResourceDict" % ceName)
        if ret["OK"]:
            resourceDict.update(dict(ret["Value"]))

    # now add some defaults
    resourceDict["Setup"] = gConfig.getValue("/DIRAC/Setup", "None")
    if not "CPUTime" in resourceDict:
        resourceDict["CPUTime"] = maxCPUSegments[-1]
    if not "PilotType" in resourceDict:
        # FIXME: this is a test, we need the list of available types
        resourceDict["PilotType"] = "private"

    return resourceDict
예제 #15
0
 def __discoverSetup(self):
     #Which setup to use?
     if self.KW_SETUP in self.kwargs and self.kwargs[self.KW_SETUP]:
         self.setup = str(self.kwargs[self.KW_SETUP])
     else:
         self.setup = gConfig.getValue("/DIRAC/Setup", "Test")
     return S_OK()
예제 #16
0
파일: Registry.py 프로젝트: sparsh35/DIRAC
def getDefaultVOMSVO():
    """ Get default VOMS VO

      :return: str
  """
    return gConfig.getValue("%s/DefaultVOMSVO" % gBaseRegistrySection,
                            "") or getVO()
예제 #17
0
 def __discoverSetup( self ):
   #Which setup to use?
   if self.KW_SETUP in self.kwargs and self.kwargs[ self.KW_SETUP ]:
     self.setup = str( self.kwargs[ self.KW_SETUP ] )
   else:
     self.setup = gConfig.getValue( "/DIRAC/Setup", "Test" )
   return S_OK()
예제 #18
0
파일: MonitoringDB.py 프로젝트: rob-c/DIRAC
 def __init__(self, name='Monitoring/MonitoringDB', readOnly=False):
   section = getDatabaseSection("Monitoring/MonitoringDB")
   indexPrefix = gConfig.getValue("%s/IndexPrefix" % section, CSGlobals.getSetup()).lower()
   super(MonitoringDB, self).__init__('MonitoringDB', name, indexPrefix)
   self.__readonly = readOnly
   self.__documents = {}
   self.__loadIndexes()
예제 #19
0
파일: Registry.py 프로젝트: sparsh35/DIRAC
def getDefaultVOMSAttribute():
    """ Get default VOMS attribute

      :return: str
  """
    return gConfig.getValue("%s/DefaultVOMSAttribute" % gBaseRegistrySection,
                            "")
예제 #20
0
def getResourceDict( ceName = None ):
  """Look into LocalSite for Resource Requirements
  """
  from DIRAC.WorkloadManagementSystem.private.Queues import maxCPUSegments
  ret = gConfig.getOptionsDict( '/LocalSite/ResourceDict' )
  if not ret['OK']:
    resourceDict = {}
  else:
    # FIXME: es mejor copiar el diccionario?
    resourceDict = dict( ret['Value'] )

  # if a CE Name is given, check the corresponding section
  if ceName:
    ret = gConfig.getOptionsDict( '/LocalSite/%s/ResourceDict' % ceName )
    if ret['OK']:
      resourceDict.update( dict( ret['Value'] ) )

  # now add some defaults
  resourceDict['Setup'] = gConfig.getValue( '/DIRAC/Setup', 'None' )
  if not 'CPUTime' in resourceDict:
    resourceDict['CPUTime'] = maxCPUSegments[-1]
  if not 'PilotType' in resourceDict:
    # FIXME: this is a test, we need the list of available types
    resourceDict['PilotType'] = 'private'

  return resourceDict
예제 #21
0
 def display(self):
   if request.params.has_key("site") and len(request.params["site"]) > 0:
     if str(request.params["site"]) != "All":
       c.select = str(request.params["site"])
   else:
     c.select =  gConfig.getValue( "/Website/DefaultExternalURL", "google.com" )
   return render("info/External.mako")
예제 #22
0
파일: __init__.py 프로젝트: zenglzh/DIRAC
def siteName():
    """
  Determine and return DIRAC name for current site
  """
    global __siteName
    if not __siteName:
        __siteName = gConfig.getValue('/LocalSite/Site', _siteName)
    return __siteName
예제 #23
0
 def __getModificator(self):
     rpcClient = getRPCClient(
         gConfig.getValue("/DIRAC/Configuration/MasterServer",
                          "Configuration/Server"))
     commiter = "%s@%s - %s" % (
         credentials.getUsername(), credentials.getSelectedGroup(),
         Time.dateTime().strftime("%Y-%m-%d %H:%M:%S"))
     return Modificator(rpcClient, commiter)
예제 #24
0
  def getCSOption( self, optionName, defaultValue = False ):
    """
    Get an option from the CS section of the services

    @return : Value for serviceSection/optionName in the CS being defaultValue the default
    """
    return gConfig.getValue( "%s/%s" % ( self.serviceInfoDict[ 'serviceSectionPath' ], optionName ),
                             defaultValue )
예제 #25
0
  def getCSOption( self, optionName, defaultValue = False ):
    """
    Get an option from the CS section of the services

    @return : Value for serviceSection/optionName in the CS being defaultValue the default
    """
    return gConfig.getValue( "%s/%s" % ( self.serviceInfoDict[ 'serviceSectionPath' ], optionName ),
                             defaultValue )
예제 #26
0
파일: CS.py 프로젝트: KrzysztofCiba/DIRAC
def getSiteTier( sites ):
  if isinstance(sites, basestring):
    sites = [sites]
  tiers = []
  for site in sites:
    t = gConfig.getValue("%s/Sites/LCG/%s/MoUTierLevel" %( g_BaseResourcesSection, site ) )
    tiers = tiers + [t]
  return S_OK(tiers)
예제 #27
0
파일: CS.py 프로젝트: KrzysztofCiba/DIRAC
def getMailForUser( users ):
  if isinstance(users, basestring):
    users = [users]
  mails = []
  for user in users:
    mail = gConfig.getValue("%s/Users/%s/Email" %(g_BaseRegistrySection, user))
    mails.append(mail)
  return S_OK(mails)
예제 #28
0
  def __init__( self, ceName ):
    """ Standard constructor
    """
    self.log = gLogger.getSubLogger( ceName )
    self.ceName = ceName
    self.ceType = ''
    self.ceParameters = {}
    self.proxy = ''
    self.valid = None
    self.mandatoryParameters = []
    self.batch = None

    self.minProxyTime = gConfig.getValue( '/Registry/MinProxyLifeTime', 10800 ) #secs
    self.defaultProxyTime = gConfig.getValue( '/Registry/DefaultProxyLifeTime', 86400 ) #secs
    self.proxyCheckPeriod = gConfig.getValue( '/Registry/ProxyCheckingPeriod', 3600 ) #secs

    self.initializeParameters()
예제 #29
0
 def display(self):
     if request.params.has_key("site") and len(request.params["site"]) > 0:
         if str(request.params["site"]) != "All":
             c.select = str(request.params["site"])
     else:
         c.select = gConfig.getValue("/Website/DefaultExternalURL",
                                     "http://diracgrid.org")
     return render("web/External.mako")
예제 #30
0
 def __getModificator(self):
     rpcClient = getRPCClient(gConfig.getValue("/DIRAC/Configuration/MasterServer", "Configuration/Server"))
     commiter = "%s@%s - %s" % (
         credentials.getUsername(),
         credentials.getSelectedGroup(),
         Time.dateTime().strftime("%Y-%m-%d %H:%M:%S"),
     )
     return Modificator(rpcClient, commiter)
예제 #31
0
  def __init__( self, ceName ):
    """ Standard constructor
    """
    self.log = gLogger.getSubLogger( ceName )
    self.ceName = ceName
    self.ceType = ''
    self.ceParameters = {}
    self.proxy = ''
    self.valid = None
    self.mandatoryParameters = []
    self.batch = None

    self.minProxyTime = gConfig.getValue( '/Registry/MinProxyLifeTime', 10800 ) #secs
    self.defaultProxyTime = gConfig.getValue( '/Registry/DefaultProxyLifeTime', 86400 ) #secs
    self.proxyCheckPeriod = gConfig.getValue( '/Registry/ProxyCheckingPeriod', 3600 ) #secs

    self.initializeParameters()
예제 #32
0
파일: __init__.py 프로젝트: afalabel/DIRAC
def siteName():
  """
  Determine and return DIRAC name for current site
  """
  global __siteName
  if not __siteName:
    __siteName = gConfig.getValue( '/LocalSite/Site', _siteName )
  return __siteName
예제 #33
0
def getVOMSVOForGroup(group):
    vomsVO = gConfig.getValue(
        "%s/Groups/%s/VOMSVO" % (gBaseRegistrySection, group),
        getDefaultVOMSVO())
    if not vomsVO:
        vo = getVOForGroup(group)
        vomsVO = getVOOption(vo, 'VOMSName', '')
    return vomsVO
예제 #34
0
파일: Registry.py 프로젝트: sparsh35/DIRAC
def getVOForGroup(group):
    """ Search VO name for group

      :param str group: group name

      :return: str
  """
    return getVO() or gConfig.getValue(
        "%s/Groups/%s/VO" % (gBaseRegistrySection, group), "")
예제 #35
0
def getHostnameForDN( dn ):
  retVal = gConfig.getSections( "%s/Hosts" % gBaseSecuritySection )
  if not retVal[ 'OK' ]:
    return retVal
  hostList = retVal[ 'Value' ]
  for hostname in hostList:
    if dn in gConfig.getValue( "%s/Hosts/%s/DN" % ( gBaseSecuritySection, hostname ), [] ):
      return S_OK( hostname )
  return S_ERROR( "No hostname found for dn %s" % dn )
예제 #36
0
def getGroupsWithVOMSAttribute( vomsAttr ):
  retVal = gConfig.getSections( "%s/Groups" % ( gBaseSecuritySection ) )
  if not retVal[ 'OK' ]:
    return []
  groups = []
  for group in retVal[ 'Value' ]:
    if vomsAttr == gConfig.getValue( "%s/Groups/%s/VOMSRole" % ( gBaseSecuritySection, group ), "" ):
      groups.append( group )
  return groups
예제 #37
0
파일: CS.py 프로젝트: KrzysztofCiba/DIRAC
def getSENodes( SE ):  
  if isinstance(SE, basestring):
    SE = [SE]
  node = []
  for se in SE: 
    n = gConfig.getValue("%s/StorageElements/%s/AccessProtocol.1/Host" %( g_BaseResourcesSection, 
                                                                          se ) )
    node = node + [n] 
  return S_OK(node)
예제 #38
0
def getSENodes(SE):
    if isinstance(SE, basestring):
        SE = [SE]
    node = []
    for se in SE:
        n = gConfig.getValue("%s/StorageElements/%s/AccessProtocol.1/Host" %
                             (g_BaseResourcesSection, se))
        node = node + [n]
    return S_OK(node)
예제 #39
0
def getMailForUser(users):
    if isinstance(users, basestring):
        users = [users]
    mails = []
    for user in users:
        mail = gConfig.getValue("%s/Users/%s/Email" %
                                (g_BaseRegistrySection, user))
        mails.append(mail)
    return S_OK(mails)
예제 #40
0
  def __init__( self, ceName ):
    """ Standard constructor
    """
    self.log = gLogger.getSubLogger( ceName )
    self.ceName = ceName
    self.ceType = ''
    #self.log.setLevel('debug') #temporary for debugging
    self.ceParameters = {}
    self.proxy = ''
    self.valid = None
    self.mandatoryParameters = []

    self.minProxyTime = gConfig.getValue( '/Registry/MinProxyLifeTime', 10800 ) #secs
    self.defaultProxyTime = gConfig.getValue( '/Registry/DefaultProxyLifeTime', 86400 ) #secs
    self.proxyCheckPeriod = gConfig.getValue( '/Registry/ProxyCheckingPeriod', 3600 ) #secs

    self.ceConfigDict = getLocalCEConfigDict( ceName )
    self.initializeParameters()
예제 #41
0
    def __init__(self, ceName):
        """ Standard constructor
    """
        self.log = gLogger.getSubLogger(ceName)
        self.ceName = ceName
        self.ceType = ""
        # self.log.setLevel('debug') #temporary for debugging
        self.ceParameters = {}
        self.proxy = ""
        self.valid = None
        self.mandatoryParameters = []

        self.minProxyTime = gConfig.getValue("/Registry/MinProxyLifeTime", 10800)  # secs
        self.defaultProxyTime = gConfig.getValue("/Registry/DefaultProxyLifeTime", 86400)  # secs
        self.proxyCheckPeriod = gConfig.getValue("/Registry/ProxyCheckingPeriod", 3600)  # secs

        self.ceConfigDict = getLocalCEConfigDict(ceName)
        self.initializeParameters()
예제 #42
0
def getSiteTier(sites):
    if isinstance(sites, basestring):
        sites = [sites]
    tiers = []
    for site in sites:
        t = gConfig.getValue("%s/Sites/LCG/%s/MoUTierLevel" %
                             (g_BaseResourcesSection, site))
        tiers = tiers + [t]
    return S_OK(tiers)
예제 #43
0
    def getDescription(self):
        """ Get CE description as a dictionary
    """

        ceDict = {}
        for option, value in self.ceParameters.items():
            if type(value) == type([]):
                ceDict[option] = value
            elif type(value) == type(' '):
                tmpInt = self.__getInt(value)
                if tmpInt is not None:
                    self.log.debug('Found CE integer attribute: %s = %s' %
                                   (option, tmpInt))
                    ceDict[option] = tmpInt
                else:
                    self.log.debug('Found string attribute: %s = %s' %
                                   (option, value))
                    ceDict[option] = value
            elif type(value) == type(1) or type(value) == type(1.):
                self.log.debug('Found integer attribute: %s = %s' %
                               (option, value))
                ceDict[option] = value
            else:
                self.log.warn('Type of option %s = %s not determined' %
                              (option, value))

        release = gConfig.getValue('/LocalSite/ReleaseVersion', version)
        ceDict['DIRACVersion'] = release
        ceDict['ReleaseVersion'] = release
        project = gConfig.getValue("/LocalSite/ReleaseProject", "")
        if project:
            ceDict['ReleaseProject'] = project

        result = self.getCEStatus()
        if result['OK']:
            if 'AvailableCores' in result:
                cores = result['AvailableCores']
                if cores > 1:
                    tagList = []
                    for i in range(2, cores + 1):
                        tagList.append('%dCore' % i)
                    ceDict['Tag'] = tagList

        return S_OK(ceDict)
예제 #44
0
파일: Registry.py 프로젝트: closier/DIRAC
def findDefaultGroupForUser(userName):
    defGroups = gConfig.getValue("/%s/DefaultGroup" % gBaseSecuritySection, ["user"])
    result = getGroupsForUser(userName)
    if not result["OK"]:
        return result
    userGroups = result["Value"]
    for group in defGroups:
        if group in userGroups:
            return S_OK(group)
    return S_OK(False)
예제 #45
0
파일: Registry.py 프로젝트: DIRACGrid/DIRAC
def getUsernameForID(ID, usersList=False):
  if not usersList:
    retVal = gConfig.getSections("%s/Users" % gBaseRegistrySection)
    if not retVal['OK']:
      return retVal
    usersList = retVal['Value']
  for username in usersList:
    if ID in gConfig.getValue("%s/Users/%s/ID" % (gBaseRegistrySection, username), []):
      return S_OK(username)
  return S_ERROR("No username found for ID %s" % ID)
예제 #46
0
def getServiceOption( serviceInfo, optionName, defaultValue ):
  """ Get service option resolving default values from the master service
  """
  if optionName[0] == "/":
    return gConfig.getValue( optionName, defaultValue )
  for csPath in serviceInfo[ 'csPaths' ]:
    result = gConfig.getOption( "%s/%s" % ( csPath, optionName, ), defaultValue )
    if result[ 'OK' ]:
      return result[ 'Value' ]
  return defaultValue
예제 #47
0
def getUsernameForDN( dn, usersList = False ):
  if not usersList:
    retVal = gConfig.getSections( "%s/Users" % gBaseSecuritySection )
    if not retVal[ 'OK' ]:
      return retVal
    usersList = retVal[ 'Value' ]
  for username in usersList:
    if dn in gConfig.getValue( "%s/Users/%s/DN" % ( gBaseSecuritySection, username ), [] ):
      return S_OK( username )
  return S_ERROR( "No username found for dn %s" % dn )
예제 #48
0
  def __init__( self, ceName ):
    """ Standard constructor
    """
    self.log = gLogger.getSubLogger( ceName )
    self.ceName = ceName
    self.ceType = ''
    #self.log.setLevel('debug') #temporary for debugging
    self.classAd = ClassAd( '[]' )
    self.ceRequirementDict = {}
    self.ceParameters = {}
    self.proxy = ''
    self.valid = None

    self.minProxyTime = gConfig.getValue( '/Registry/MinProxyLifeTime', 10800 ) #secs
    self.defaultProxyTime = gConfig.getValue( '/Registry/DefaultProxyLifeTime', 86400 ) #secs
    self.proxyCheckPeriod = gConfig.getValue( '/Registry/ProxyCheckingPeriod', 3600 ) #secs

    self.ceConfigDict = getLocalCEConfigDict( ceName )
    self.initializeParameters()
예제 #49
0
 def __getRemoteConfiguration(self):
     rpcClient = getRPCClient(gConfig.getValue("/DIRAC/Configuration/MasterServer", "Configuration/Server"))
     modCfg = Modificator(rpcClient)
     retVal = modCfg.loadFromRemote()
     if retVal["OK"]:
         session["cfgData"] = str(modCfg)
         session["csName"] = "%s Configuration" % (modCfg.getValue("/DIRAC/VirtualOrganization"))
         session.save()
         c.cfgData = modCfg.cfgData
         c.csName = session["csName"]
     return retVal
예제 #50
0
 def getCSExtensions( self ):
   if not self.__csExt:
     from DIRAC.ConfigurationSystem.Client.Config import gConfig
     exts = gConfig.getValue( '/DIRAC/Extensions', [] )
     for iP in range( len( exts ) ):
       ext = exts[ iP ]
       if ext.endswith( "DIRAC" ):
         ext = ext[:-5]
         exts[ iP ] = ext
     self.__csExt = exts
   return self.__csExt
예제 #51
0
 def initialize(self):
   credDict = self.getRemoteCredentials()
   self.ownerDN = credDict['DN']
   self.ownerGroup = credDict['group']
   self.userProperties = credDict[ 'properties' ]
   self.owner = credDict[ 'username' ]
   self.peerUsesLimitedProxy = credDict[ 'isLimitedProxy' ]
   self.diracSetup = self.serviceInfoDict['clientSetup']
   serviceSectionPath = self.serviceInfoDict['serviceSectionPath']
   self.maxParametricJobs = gConfig.getValue('%s/MaxParametricJobs'%serviceSectionPath,MAX_PARAMETRIC_JOBS)
   self.jobPolicy = JobPolicy( self.ownerDN, self.ownerGroup, self.userProperties )
예제 #52
0
 def getShortcutsForGroup( self, group ):
   groupSection = "%s/Shortcuts/%s" % ( self.webSection, group )
   retVal = gConfig.getOptions( groupSection, listOrdered = True )
   if retVal[ 'OK' ]:
     names = retVal[ 'Value' ]
   else:
     names = []
   entries = []
   for entryName in names:
     actionPath = gConfig.getValue( "%s/%s" % ( groupSection, entryName ) )
     entries.append( ( entryName, actionPath ) )
   return entries
예제 #53
0
파일: Registry.py 프로젝트: bmb/DIRAC
def findDefaultGroupForUser( userName ):
  defGroups = gConfig.getValue( "/%s/DefaultGroup" % gBaseSecuritySection, [ "user" ] )
  result = getGroupsForUser( userName )
  if not result[ 'OK' ]:
    return result
  userGroups = result[ 'Value' ]
  for group in defGroups:
    if group in userGroups:
      return S_OK( group )
  if userGroups:
    return S_OK( userGroups[0] )
  return S_ERROR( "User %s has no groups" % userName )