コード例 #1
0
ファイル: ilcdirac-version.py プロジェクト: LCDsoft/ILCDIRAC
def getInfo():
  """Retrieve information about setup, etc."""
  records = []

  records.append(('Setup', gConfig.getValue('/DIRAC/Setup', 'Unknown')))
  records.append(('ConfigurationServer', gConfig.getValue('/DIRAC/Configuration/Servers', [])))
  records.append(('Installation path', DIRAC.rootPath))

  if os.path.exists(os.path.join(DIRAC.rootPath, DIRAC.getPlatform(), 'bin', 'mysql')):
    records.append(('Installation type', 'server'))
  else:
    records.append(('Installation type', 'client'))

  records.append(('Platform', DIRAC.getPlatform()))

  ret = getProxyInfo(disableVOMS=False)
  if ret['OK']:
    print(pprint.pformat(ret))
    if 'group' in ret['Value']:
      vo = getVOForGroup(ret['Value']['group'])
    else:
      vo = getVOForGroup('')
    if not vo:
      vo = "None"
    records.append(('VirtualOrganization', vo))
    if 'identity' in ret['Value']:
      records.append(('User DN', ret['Value']['identity']))
    if 'secondsLeft' in ret['Value']:
      records.append(('Proxy validity, secs', {'Value': str(ret['Value']['secondsLeft']), 'Just': 'L'}))

  if gConfig.getValue('/DIRAC/Security/UseServerCertificate', True):
    records.append(('Use Server Certificate', 'Yes'))
  else:
    records.append(('Use Server Certificate', 'No'))
  if gConfig.getValue('/DIRAC/Security/SkipCAChecks', False):
    records.append(('Skip CA Checks', 'Yes'))
  else:
    records.append(('Skip CA Checks', 'No'))

  try:
    import gfalthr  # pylint: disable=import-error
    records.append(('gfal version', gfalthr.gfal_version()))
  except BaseException:
    pass

  fields = ['Option', 'Value']

  return fields, records
コード例 #2
0
ファイル: Service.py プロジェクト: DIRACGrid-test/DIRAC
  def _initMonitoring( self ):
    #Init extra bits of monitoring
    self._monitor.setComponentType( MonitoringClient.COMPONENT_SERVICE )
    self._monitor.setComponentName( self._name )
    self._monitor.setComponentLocation( self._cfg.getURL() )
    self._monitor.initialize()
    self._monitor.registerActivity( "Connections", "Connections received", "Framework", "connections", MonitoringClient.OP_RATE )
    self._monitor.registerActivity( "Queries", "Queries served", "Framework", "queries", MonitoringClient.OP_RATE )
    self._monitor.registerActivity( 'CPU', "CPU Usage", 'Framework', "CPU,%", MonitoringClient.OP_MEAN, 600 )
    self._monitor.registerActivity( 'MEM', "Memory Usage", 'Framework', 'Memory,MB', MonitoringClient.OP_MEAN, 600 )
    self._monitor.registerActivity( 'PendingQueries', "Pending queries", 'Framework', 'queries', MonitoringClient.OP_MEAN )
    self._monitor.registerActivity( 'ActiveQueries', "Active queries", 'Framework', 'threads', MonitoringClient.OP_MEAN )
    self._monitor.registerActivity( 'RunningThreads', "Running threads", 'Framework', 'threads', MonitoringClient.OP_MEAN )
    self._monitor.registerActivity( 'MaxFD', "Max File Descriptors", 'Framework', 'fd', MonitoringClient.OP_MEAN )

    self._monitor.setComponentExtraParam( 'DIRACVersion', DIRAC.version )
    self._monitor.setComponentExtraParam( 'platform', DIRAC.getPlatform() )
    self._monitor.setComponentExtraParam( 'startTime', Time.dateTime() )
    for prop in ( ( "__RCSID__", "version" ), ( "__doc__", "description" ) ):
      try:
        value = getattr( self._handler[ 'module' ], prop[0] )
      except Exception as e:
        gLogger.exception( e )
        gLogger.error( "Missing property", prop[0] )
        value = 'unset'
      self._monitor.setComponentExtraParam( prop[1], value )
    for secondaryName in self._cfg.registerAlsoAs():
      gLogger.info( "Registering %s also as %s" % ( self._name, secondaryName ) )
      self._validNames.append( secondaryName )
    return S_OK()
コード例 #3
0
    def _initMonitoring(cls, serviceName, fullUrl):
        """
      Initialize the monitoring specific to this handler
      This has to be called only by :py:meth:`.__initializeService`
      to ensure thread safety and unicity of the call.

      :param serviceName: relative URL ``/<System>/<Component>``
      :param fullUrl: full URl like ``https://<host>:<port>/<System>/<Component>``
    """

        # Init extra bits of monitoring

        cls._monitor = MonitoringClient()
        cls._monitor.setComponentType(MonitoringClient.COMPONENT_WEB)

        cls._monitor.initialize()

        if tornado.process.task_id() is None:  # Single process mode
            cls._monitor.setComponentName('Tornado/%s' % serviceName)
        else:
            cls._monitor.setComponentName(
                'Tornado/CPU%d/%s' % (tornado.process.task_id(), serviceName))

        cls._monitor.setComponentLocation(fullUrl)

        cls._monitor.registerActivity("Queries", "Queries served", "Framework",
                                      "queries", MonitoringClient.OP_RATE)

        cls._monitor.setComponentExtraParam('DIRACVersion', DIRAC.version)
        cls._monitor.setComponentExtraParam('platform', DIRAC.getPlatform())
        cls._monitor.setComponentExtraParam('startTime', datetime.utcnow())

        cls._stats = {'requests': 0, 'monitorLastStatsUpdate': time.time()}

        return S_OK()
コード例 #4
0
ファイル: AgentModule.py プロジェクト: DIRACGrid/DIRAC
    def __getCodeInfo(self):
        try:
            self.__agentModule = __import__(self.__class__.__module__,
                                            globals(), locals(), "__doc__")
        except Exception as excp:
            self.log.exception("Cannot load agent module", lException=excp)

        if six.PY3:
            try:
                from importlib.metadata import version as get_version  # pylint: disable=import-error,no-name-in-module
                import inspect

                self.__codeProperties["version"] = get_version(
                    inspect.getmodule(self).__package__.split(".")[0])
            except Exception:
                self.log.exception("Failed to find version for " + repr(self))
                self.__codeProperties["version"] = "unset"
        else:
            try:
                self.__codeProperties["version"] = getattr(
                    self.__agentModule, "__RCSID__")
            except Exception:
                self.log.error("Missing property __RCSID__")
                self.__codeProperties["version"] = "unset"

        try:
            self.__codeProperties["description"] = getattr(
                self.__agentModule, "__doc__")
        except Exception:
            self.log.error("Missing property __doc__")
            self.__codeProperties["description"] = "unset"

        self.__codeProperties["DIRACVersion"] = DIRAC.version
        self.__codeProperties["platform"] = DIRAC.getPlatform()
コード例 #5
0
    def am_initialize(self, *initArgs):
        """ Common initialization for all the agents.

        This is executed every time an agent (re)starts.
        This is called by the AgentReactor, should not be overridden.
    """
        agentName = self.am_getModuleParam('fullName')
        result = self.initialize(*initArgs)
        if not isReturnStructure(result):
            return S_ERROR("initialize must return S_OK/S_ERROR")
        if not result['OK']:
            return S_ERROR("Error while initializing %s: %s" %
                           (agentName, result['Message']))
        mkDir(self.am_getControlDirectory())
        workDirectory = self.am_getWorkDirectory()
        mkDir(workDirectory)
        # Set the work directory in an environment variable available to subprocesses if needed
        os.environ['AGENT_WORKDIRECTORY'] = workDirectory

        self.__moduleProperties['shifterProxy'] = self.am_getOption(
            'shifterProxy')
        if self.am_monitoringEnabled() and not self.activityMonitoring:
            self.monitor.enable()
        if len(self.__moduleProperties['executors']) < 1:
            return S_ERROR("At least one executor method has to be defined")
        if not self.am_Enabled():
            return S_ERROR("Agent is disabled via the configuration")
        self.log.notice("=" * 40)
        self.log.notice("Loaded agent module %s" %
                        self.__moduleProperties['fullName'])
        self.log.notice(" Site: %s" % DIRAC.siteName())
        self.log.notice(" Setup: %s" % gConfig.getValue("/DIRAC/Setup"))
        self.log.notice(" Base Module version: %s " % __RCSID__)
        self.log.notice(" Agent version: %s" %
                        self.__codeProperties['version'])
        self.log.notice(" DIRAC version: %s" % DIRAC.version)
        self.log.notice(" DIRAC platform: %s" % DIRAC.getPlatform())
        pollingTime = int(self.am_getOption('PollingTime'))
        if pollingTime > 3600:
            self.log.notice(" Polling time: %s hours" % (pollingTime / 3600.))
        else:
            self.log.notice(" Polling time: %s seconds" %
                            self.am_getOption('PollingTime'))
        self.log.notice(" Control dir: %s" % self.am_getControlDirectory())
        self.log.notice(" Work dir: %s" % self.am_getWorkDirectory())
        if self.am_getOption('MaxCycles') > 0:
            self.log.notice(" Cycles: %s" % self.am_getMaxCycles())
        else:
            self.log.notice(" Cycles: unlimited")
        if self.am_getWatchdogTime() > 0:
            self.log.notice(" Watchdog interval: %s" %
                            self.am_getWatchdogTime())
        else:
            self.log.notice(" Watchdog interval: disabled ")
        self.log.notice("=" * 40)
        self.__initialized = True
        return S_OK()
コード例 #6
0
    def _initMonitoring(self):
        if not self.activityMonitoring:
            # Init extra bits of monitoring
            self._monitor.setComponentType(MonitoringClient.COMPONENT_SERVICE)
            self._monitor.setComponentName(self._name)
            self._monitor.setComponentLocation(self._cfg.getURL())
            self._monitor.initialize()
            self._monitor.registerActivity("Connections",
                                           "Connections received", "Framework",
                                           "connections",
                                           MonitoringClient.OP_RATE)
            self._monitor.registerActivity("Queries", "Queries served",
                                           "Framework", "queries",
                                           MonitoringClient.OP_RATE)
            self._monitor.registerActivity("CPU", "CPU Usage", "Framework",
                                           "CPU,%", MonitoringClient.OP_MEAN,
                                           600)
            self._monitor.registerActivity("MEM", "Memory Usage", "Framework",
                                           "Memory,MB",
                                           MonitoringClient.OP_MEAN, 600)
            self._monitor.registerActivity("PendingQueries", "Pending queries",
                                           "Framework", "queries",
                                           MonitoringClient.OP_MEAN)
            self._monitor.registerActivity("ActiveQueries", "Active queries",
                                           "Framework", "threads",
                                           MonitoringClient.OP_MEAN)
            self._monitor.registerActivity("RunningThreads", "Running threads",
                                           "Framework", "threads",
                                           MonitoringClient.OP_MEAN)
            self._monitor.registerActivity("MaxFD", "Max File Descriptors",
                                           "Framework", "fd",
                                           MonitoringClient.OP_MEAN)

            self._monitor.setComponentExtraParam("DIRACVersion", DIRAC.version)
            self._monitor.setComponentExtraParam("platform",
                                                 DIRAC.getPlatform())
            self._monitor.setComponentExtraParam("startTime", Time.dateTime())
            props = [("__doc__", "description")]
            if six.PY2:
                props += [("__RCSID__", "version")]
            for prop in props:
                try:
                    value = getattr(self._handler["module"], prop[0])
                except Exception as e:
                    gLogger.exception(e)
                    gLogger.error("Missing property", prop[0])
                    value = "unset"
                self._monitor.setComponentExtraParam(prop[1], value)

        for secondaryName in self._cfg.registerAlsoAs():
            gLogger.info("Registering %s also as %s" %
                         (self._name, secondaryName))
            self._validNames.append(secondaryName)

        return S_OK()
コード例 #7
0
    def _initMonitoring(self):
        if not self.activityMonitoring:
            # Init extra bits of monitoring
            self._monitor.setComponentType(MonitoringClient.COMPONENT_SERVICE)
            self._monitor.setComponentName(self._name)
            self._monitor.setComponentLocation(self._cfg.getURL())
            self._monitor.initialize()
            self._monitor.registerActivity("Connections",
                                           "Connections received", "Framework",
                                           "connections",
                                           MonitoringClient.OP_RATE)
            self._monitor.registerActivity("Queries", "Queries served",
                                           "Framework", "queries",
                                           MonitoringClient.OP_RATE)
            self._monitor.registerActivity('CPU', "CPU Usage", 'Framework',
                                           "CPU,%", MonitoringClient.OP_MEAN,
                                           600)
            self._monitor.registerActivity('MEM', "Memory Usage", 'Framework',
                                           'Memory,MB',
                                           MonitoringClient.OP_MEAN, 600)
            self._monitor.registerActivity('PendingQueries', "Pending queries",
                                           'Framework', 'queries',
                                           MonitoringClient.OP_MEAN)
            self._monitor.registerActivity('ActiveQueries', "Active queries",
                                           'Framework', 'threads',
                                           MonitoringClient.OP_MEAN)
            self._monitor.registerActivity('RunningThreads', "Running threads",
                                           'Framework', 'threads',
                                           MonitoringClient.OP_MEAN)
            self._monitor.registerActivity('MaxFD', "Max File Descriptors",
                                           'Framework', 'fd',
                                           MonitoringClient.OP_MEAN)

            self._monitor.setComponentExtraParam('DIRACVersion', DIRAC.version)
            self._monitor.setComponentExtraParam('platform',
                                                 DIRAC.getPlatform())
            self._monitor.setComponentExtraParam('startTime', Time.dateTime())
            for prop in (("__RCSID__", "version"), ("__doc__", "description")):
                try:
                    value = getattr(self._handler['module'], prop[0])
                except Exception as e:
                    gLogger.exception(e)
                    gLogger.error("Missing property", prop[0])
                    value = 'unset'
                self._monitor.setComponentExtraParam(prop[1], value)

        for secondaryName in self._cfg.registerAlsoAs():
            gLogger.info("Registering %s also as %s" %
                         (self._name, secondaryName))
            self._validNames.append(secondaryName)

        return S_OK()
コード例 #8
0
ファイル: AgentModule.py プロジェクト: DIRACGrid/DIRAC
  def am_initialize(self, *initArgs):
    """ Common initialization for all the agents.

        This is executed every time an agent (re)starts.
        This is called by the AgentReactor, should not be overridden.
    """
    agentName = self.am_getModuleParam('fullName')
    result = self.initialize(*initArgs)
    if not isReturnStructure(result):
      return S_ERROR("initialize must return S_OK/S_ERROR")
    if not result['OK']:
      return S_ERROR("Error while initializing %s: %s" % (agentName, result['Message']))
    mkDir(self.am_getControlDirectory())
    workDirectory = self.am_getWorkDirectory()
    mkDir(workDirectory)
    # Set the work directory in an environment variable available to subprocesses if needed
    os.environ['AGENT_WORKDIRECTORY'] = workDirectory

    self.__moduleProperties['shifterProxy'] = self.am_getOption('shifterProxy')
    if self.am_monitoringEnabled():
      self.monitor.enable()
    if len(self.__moduleProperties['executors']) < 1:
      return S_ERROR("At least one executor method has to be defined")
    if not self.am_Enabled():
      return S_ERROR("Agent is disabled via the configuration")
    self.log.notice("=" * 40)
    self.log.notice("Loaded agent module %s" % self.__moduleProperties['fullName'])
    self.log.notice(" Site: %s" % DIRAC.siteName())
    self.log.notice(" Setup: %s" % gConfig.getValue("/DIRAC/Setup"))
    self.log.notice(" Base Module version: %s " % __RCSID__)
    self.log.notice(" Agent version: %s" % self.__codeProperties['version'])
    self.log.notice(" DIRAC version: %s" % DIRAC.version)
    self.log.notice(" DIRAC platform: %s" % DIRAC.getPlatform())
    pollingTime = int(self.am_getOption('PollingTime'))
    if pollingTime > 3600:
      self.log.notice(" Polling time: %s hours" % (pollingTime / 3600.))
    else:
      self.log.notice(" Polling time: %s seconds" % self.am_getOption('PollingTime'))
    self.log.notice(" Control dir: %s" % self.am_getControlDirectory())
    self.log.notice(" Work dir: %s" % self.am_getWorkDirectory())
    if self.am_getOption('MaxCycles') > 0:
      self.log.notice(" Cycles: %s" % self.am_getMaxCycles())
    else:
      self.log.notice(" Cycles: unlimited")
    if self.am_getWatchdogTime() > 0:
      self.log.notice(" Watchdog interval: %s" % self.am_getWatchdogTime())
    else:
      self.log.notice(" Watchdog interval: disabled ")
    self.log.notice("=" * 40)
    self.__initialized = True
    return S_OK()
コード例 #9
0
    def _initMonitoring(self):
        """
        Initialize the monitoring
        """

        self._monitor.setComponentType(MonitoringClient.COMPONENT_TORNADO)
        self._monitor.initialize()
        self._monitor.setComponentName("Tornado")

        self._monitor.registerActivity("CPU", "CPU Usage", "Framework", "CPU,%", MonitoringClient.OP_MEAN, 600)
        self._monitor.registerActivity("MEM", "Memory Usage", "Framework", "Memory,MB", MonitoringClient.OP_MEAN, 600)

        self._monitor.setComponentExtraParam("DIRACVersion", DIRAC.version)
        self._monitor.setComponentExtraParam("platform", DIRAC.getPlatform())
        self._monitor.setComponentExtraParam("startTime", datetime.datetime.utcnow())
コード例 #10
0
 def __getCodeInfo(self):
     versionVar = "__RCSID__"
     docVar = "__doc__"
     try:
         self.__agentModule = __import__(self.__class__.__module__,
                                         globals(), locals(), versionVar)
     except Exception as excp:
         self.log.exception("Cannot load agent module", lException=excp)
     for prop in ((versionVar, "version"), (docVar, "description")):
         try:
             self.__codeProperties[prop[1]] = getattr(
                 self.__agentModule, prop[0])
         except Exception:
             self.log.error("Missing property", prop[0])
             self.__codeProperties[prop[1]] = 'unset'
     self.__codeProperties['DIRACVersion'] = DIRAC.version
     self.__codeProperties['platform'] = DIRAC.getPlatform()
コード例 #11
0
ファイル: AgentModule.py プロジェクト: DIRACGrid-test/DIRAC
 def __getCodeInfo( self ):
   versionVar = "__RCSID__"
   docVar = "__doc__"
   try:
     self.__agentModule = __import__( self.__class__.__module__,
                                      globals(),
                                      locals(),
                                      versionVar )
   except Exception:
     self.log.exception( "Cannot load agent module" )
   for prop in ( ( versionVar, "version" ), ( docVar, "description" ) ):
     try:
       self.__codeProperties[ prop[1] ] = getattr( self.__agentModule, prop[0] )
     except Exception:
       self.log.error( "Missing property", prop[0] )
       self.__codeProperties[ prop[1] ] = 'unset'
   self.__codeProperties[ 'DIRACVersion' ] = DIRAC.version
   self.__codeProperties[ 'platform' ] = DIRAC.getPlatform()
コード例 #12
0
ファイル: TornadoServer.py プロジェクト: pmusset/DIRAC
    def _initMonitoring(self):
        """
      Initialize the monitoring
    """

        self._monitor.setComponentType(MonitoringClient.COMPONENT_TORNADO)
        self._monitor.initialize()
        self._monitor.setComponentName('Tornado')

        self._monitor.registerActivity('CPU', "CPU Usage", 'Framework',
                                       "CPU,%", MonitoringClient.OP_MEAN, 600)
        self._monitor.registerActivity('MEM', "Memory Usage", 'Framework',
                                       'Memory,MB', MonitoringClient.OP_MEAN,
                                       600)

        self._monitor.setComponentExtraParam('DIRACVersion', DIRAC.version)
        self._monitor.setComponentExtraParam('platform', DIRAC.getPlatform())
        self._monitor.setComponentExtraParam('startTime',
                                             datetime.datetime.utcnow())
コード例 #13
0
    def __getCodeInfo(self):

        try:
            self.__codeProperties["version"] = importlib.metadata.version(
                inspect.getmodule(self).__package__.split(".")[0])
        except Exception:
            self.log.exception(f"Failed to find version for {self!r}")
            self.__codeProperties["version"] = "unset"
        try:
            self.__agentModule = __import__(self.__class__.__module__,
                                            globals(), locals(), "__doc__")
        except Exception as excp:
            self.log.exception("Cannot load agent module", lException=excp)
        try:
            self.__codeProperties["description"] = getattr(
                self.__agentModule, "__doc__")
        except Exception:
            self.log.error("Missing property __doc__")
            self.__codeProperties["description"] = "unset"
        self.__codeProperties["DIRACVersion"] = DIRAC.version
        self.__codeProperties["platform"] = DIRAC.getPlatform()
コード例 #14
0
 def platform(arg):
     Script.disableCS()
     print(DIRAC.getPlatform())
     DIRAC.exit(0)
コード例 #15
0
def main():
    import os

    import DIRAC
    from DIRAC import gConfig
    from DIRAC.Core.Security.ProxyInfo import getProxyInfo
    from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
    from DIRAC.Core.Utilities.PrettyPrint import printTable

    def version(arg):
        Script.disableCS()
        print(DIRAC.version)
        DIRAC.exit(0)

    def platform(arg):
        Script.disableCS()
        print(DIRAC.getPlatform())
        DIRAC.exit(0)

    Script.registerSwitch("v", "version",
                          "print version of current DIRAC installation",
                          version)
    Script.registerSwitch("p", "platform",
                          "print platform of current DIRAC installation",
                          platform)
    Script.parseCommandLine(ignoreErrors=True)

    records = []

    records.append(("Setup", gConfig.getValue("/DIRAC/Setup", "Unknown")))
    records.append((
        "AuthorizationServer",
        gConfig.getValue(
            "/DIRAC/Security/Authorization/issuer",
            "/DIRAC/Security/Authorization/issuer option is absent"),
    ))
    records.append(("ConfigurationServer",
                    gConfig.getValue("/DIRAC/Configuration/Servers",
                                     "None found")))
    records.append(("Installation path", DIRAC.rootPath))

    if os.path.exists(
            os.path.join(DIRAC.rootPath, DIRAC.getPlatform(), "bin", "mysql")):
        records.append(("Installation type", "server"))
    else:
        records.append(("Installation type", "client"))

    records.append(("Platform", DIRAC.getPlatform()))

    ret = getProxyInfo(disableVOMS=True)
    if ret["OK"]:
        if "group" in ret["Value"]:
            vo = getVOForGroup(ret["Value"]["group"])
        else:
            vo = getVOForGroup("")
        if not vo:
            vo = "None"
        records.append(("VirtualOrganization", vo))
        if "identity" in ret["Value"]:
            records.append(("User DN", ret["Value"]["identity"]))
        if "secondsLeft" in ret["Value"]:
            records.append(("Proxy validity, secs", {
                "Value": str(ret["Value"]["secondsLeft"]),
                "Just": "L"
            }))

    if gConfig.getValue("/DIRAC/Security/UseServerCertificate", True):
        records.append(("Use Server Certificate", "Yes"))
    else:
        records.append(("Use Server Certificate", "No"))
    if gConfig.getValue("/DIRAC/Security/UseTokens",
                        "false").lower() in ("y", "yes", "true"):
        records.append(("Use tokens", "Yes"))
    else:
        records.append(("Use tokens", "No"))
    if gConfig.getValue("/DIRAC/Security/SkipCAChecks", False):
        records.append(("Skip CA Checks", "Yes"))
    else:
        records.append(("Skip CA Checks", "No"))

    records.append(("DIRAC version", DIRAC.version))

    fields = ["Option", "Value"]

    print()
    printTable(fields, records, numbering=False)
    print()
コード例 #16
0
ファイル: dirac-info.py プロジェクト: DIRACGrid-test/DIRAC
from DIRAC.ConfigurationSystem.Client.Helpers.Registry       import getVOForGroup
from DIRAC.Core.Utilities.PrettyPrint                        import printTable

Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... Site' % Script.scriptName, ] ) )
Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

records = []

records.append( ('Setup', gConfig.getValue( '/DIRAC/Setup', 'Unknown' ) ) )
records.append( ('ConfigurationServer', str( gConfig.getValue( '/DIRAC/Configuration/Servers', [] ) ) ) )
records.append( ('Installation path', DIRAC.rootPath ) )

if os.path.exists( os.path.join( DIRAC.rootPath, DIRAC.getPlatform(), 'bin', 'mysql' ) ):
  records.append( ('Installation type', 'server' ) )
else:
  records.append( ('Installation type', 'client' ) )

records.append( ( 'Platform', DIRAC.getPlatform() ) )

ret = getProxyInfo( disableVOMS = True )
if ret['OK']:
  if 'group' in ret['Value']:
    records.append( ('VirtualOrganization', getVOForGroup( ret['Value']['group'] ) ) )
  else:
    records.append( ('VirtualOrganization', getVOForGroup( '' ) ) )
  if 'identity' in ret['Value']:
    records.append( ('User DN', ret['Value']['identity'] ) )
  if 'secondsLeft' in ret['Value']:
コード例 #17
0
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
from DIRAC.Core.Utilities.PrettyPrint import printTable

Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s [option|cfgfile] ... Site' % Script.scriptName, ]))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

records = []

records.append(('Setup', gConfig.getValue('/DIRAC/Setup', 'Unknown')))
records.append(('ConfigurationServer', gConfig.getValue('/DIRAC/Configuration/Servers', [])))
records.append(('Installation path', DIRAC.rootPath))

if os.path.exists(os.path.join(DIRAC.rootPath, DIRAC.getPlatform(), 'bin', 'mysql')):
  records.append(('Installation type', 'server'))
else:
  records.append(('Installation type', 'client'))

records.append(('Platform', DIRAC.getPlatform()))

ret = getProxyInfo(disableVOMS=True)
if ret['OK']:
  if 'group' in ret['Value']:
    vo = getVOForGroup(ret['Value']['group'])
  else:
    vo = getVOForGroup('')
  if not vo:
    vo = "None"
  records.append(('VirtualOrganization', vo))
コード例 #18
0
ファイル: dirac_info.py プロジェクト: pmusset/DIRAC
def main():
    import os

    import DIRAC
    from DIRAC import gConfig
    from DIRAC.Core.Base import Script
    from DIRAC.Core.Security.ProxyInfo import getProxyInfo
    from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
    from DIRAC.Core.Utilities.PrettyPrint import printTable

    def version(arg):
        Script.disableCS()
        print(DIRAC.version)
        DIRAC.exit(0)

    def platform(arg):
        Script.disableCS()
        print(DIRAC.getPlatform())
        DIRAC.exit(0)

    Script.registerSwitch("v", "version",
                          "print version of current DIRAC installation",
                          version)
    Script.registerSwitch("p", "platform",
                          "print platform of current DIRAC installation",
                          platform)
    Script.parseCommandLine(ignoreErrors=True)

    records = []

    records.append(('Setup', gConfig.getValue('/DIRAC/Setup', 'Unknown')))
    records.append(('ConfigurationServer',
                    gConfig.getValue('/DIRAC/Configuration/Servers', [])))
    records.append(('Installation path', DIRAC.rootPath))

    if os.path.exists(
            os.path.join(DIRAC.rootPath, DIRAC.getPlatform(), 'bin', 'mysql')):
        records.append(('Installation type', 'server'))
    else:
        records.append(('Installation type', 'client'))

    records.append(('Platform', DIRAC.getPlatform()))

    ret = getProxyInfo(disableVOMS=True)
    if ret['OK']:
        if 'group' in ret['Value']:
            vo = getVOForGroup(ret['Value']['group'])
        else:
            vo = getVOForGroup('')
        if not vo:
            vo = "None"
        records.append(('VirtualOrganization', vo))
        if 'identity' in ret['Value']:
            records.append(('User DN', ret['Value']['identity']))
        if 'secondsLeft' in ret['Value']:
            records.append(('Proxy validity, secs', {
                'Value': str(ret['Value']['secondsLeft']),
                'Just': 'L'
            }))

    if gConfig.getValue('/DIRAC/Security/UseServerCertificate', True):
        records.append(('Use Server Certificate', 'Yes'))
    else:
        records.append(('Use Server Certificate', 'No'))
    if gConfig.getValue('/DIRAC/Security/SkipCAChecks', False):
        records.append(('Skip CA Checks', 'Yes'))
    else:
        records.append(('Skip CA Checks', 'No'))

    records.append(('DIRAC version', DIRAC.version))

    fields = ['Option', 'Value']

    print()
    printTable(fields, records, numbering=False)
    print()