Пример #1
0
 def getLFCRegisteredDNs(self):
     #Request a proxy
     if gConfig.useServerCertificate():
         if not self.__generateProxy():
             return False
     #Execute the call
     cmdEnv = dict(os.environ)
     cmdEnv['LFC_HOST'] = 'lfc-egee.in2p3.fr'
     if os.path.isfile(self.proxyLocation):
         cmdEnv['X509_USER_PROXY'] = self.proxyLocation
     lfcDNs = []
     try:
         retlfc = Subprocess.systemCall(30, ('lfc-listusrmap', ),
                                        env=cmdEnv)
         if not retlfc['OK']:
             self.log.fatal('Can not get LFC User List', retlfc['Message'])
             return retlfc
         if retlfc['Value'][0]:
             self.log.fatal('Can not get LFC User List', retlfc['Value'][2])
             return S_ERROR("lfc-listusrmap failed")
         else:
             for item in List.fromChar(retlfc['Value'][1], '\n'):
                 dn = item.split(' ', 1)[1]
                 lfcDNs.append(dn)
         return S_OK(lfcDNs)
     finally:
         if os.path.isfile(self.proxyLocation):
             self.log.info("Destroying proxy...")
             os.unlink(self.proxyLocation)
 def __checkoutFromSVN( self, moduleName = None, sourceURL = None, tagVersion = None ):
   """
   This method checkout a given tag from a SVN repository. 
   Note: we can checkout any project form a SVN repository 
   
   :param str moduleName: The name of the Module
   :param str sourceURL: The code repository
   :param str tagVersion: the tag for example: v4r3p6
   
   """
   
   if not moduleName:
     moduleName = self.params.name
   
   if not sourceURL:
     sourceURL = self.params.sourceURL   
     
   if not tagVersion:
     tagVersion = self.params.version
     
   cmd = "svn export --trust-server-cert --non-interactive '%s/%s' '%s'" % ( sourceURL, tagVersion,
                                                                             os.path.join( self.params.destination, moduleName ) )
   gLogger.verbose( "Executing: %s" % cmd )
   result = Subprocess.systemCall( 900, shlex.split(cmd) )
   if not result[ 'OK' ]:
     return S_ERROR( "Error while retrieving sources from SVN: %s" % result[ 'Message' ] )
   exitStatus, stdData, errData = result[ 'Value' ]
   if exitStatus:
     return S_ERROR( "Error while retrieving sources from SVN: %s" % "\n".join( [ stdData, errData ] ) )
   return S_OK()
Пример #3
0
def executeRabbitmqctl(arg, *argv):
    """Executes RabbitMQ administration command.
      It uses rabbitmqctl command line interface.
      For every command the -q argument ("quit mode")
      is used, since in some cases the output must be processed,
      so we don't want any additional informations printed.

    Args:
      arg(str): command recognized by the rabbitmqctl.
      argv: optional list of string parameters.

    :rtype: S_OK or S_ERROR
    :type argv: python:list

    """
    command = ["sudo", "/usr/sbin/rabbitmqctl", "-q", arg] + list(argv)
    timeOut = 30
    result = Subprocess.systemCall(timeout=timeOut, cmdSeq=command)
    if not result["OK"]:
        return S_ERROR(errno.EPERM, "%r failed to launch" % command)
    errorcode, cmd_out, cmd_err = result["Value"]
    if errorcode:
        # No idea what errno code should be used here.
        # Maybe we should define some specific for rabbitmqctl
        return S_ERROR(
            errno.EPERM, "%r failed, status code: %s stdout: %r stderr: %r" % (command, errorcode, cmd_out, cmd_err)
        )
    return S_OK(cmd_out)
Пример #4
0
 def getLFCRegisteredDNs( self ):
   #Request a proxy
   if gConfig.useServerCertificate():
     if not self.__generateProxy():
       return False
   #Execute the call
   cmdEnv = dict( os.environ )
   cmdEnv['LFC_HOST'] = 'lfc-egee.in2p3.fr'
   if os.path.isfile( self.proxyLocation ):
     cmdEnv[ 'X509_USER_PROXY' ] = self.proxyLocation
   lfcDNs = []
   try:
     retlfc = Subprocess.systemCall( 30, ( 'lfc-listusrmap', ), env = cmdEnv )
     if not retlfc['OK']:
       self.log.fatal( 'Can not get LFC User List', retlfc['Message'] )
       return retlfc
     if retlfc['Value'][0]:
       self.log.fatal( 'Can not get LFC User List', retlfc['Value'][2] )
       return S_ERROR( "lfc-listusrmap failed" )
     else:
       for item in List.fromChar( retlfc['Value'][1], '\n' ):
         dn = item.split( ' ', 1 )[1]
         lfcDNs.append( dn )
     return S_OK( lfcDNs )
   finally:
     if os.path.isfile( self.proxyLocation ):
       self.log.info( "Destroying proxy..." )
       os.unlink( self.proxyLocation )
Пример #5
0
  def __checkoutFromSVN(self, moduleName=None, sourceURL=None, tagVersion=None):
    """
    This method checkout a given tag from a SVN repository.
    Note: we can checkout any project form a SVN repository

    :param str moduleName: The name of the Module
    :param str sourceURL: The code repository
    :param str tagVersion: the tag for example: v4r3p6

    """

    if not moduleName:
      moduleName = self.params.name

    if not sourceURL:
      sourceURL = self.params.sourceURL

    if not tagVersion:
      tagVersion = self.params.version

    cmd = "svn export --trust-server-cert --non-interactive '%s/%s' '%s'" % (sourceURL, tagVersion,
                                                                             os.path.join(self.params.destination,
                                                                                          moduleName))
    gLogger.verbose("Executing: %s" % cmd)
    result = Subprocess.systemCall(900, shlex.split(cmd))
    if not result['OK']:
      return S_ERROR("Error while retrieving sources from SVN: %s" % result['Message'])
    exitStatus, stdData, errData = result['Value']
    if exitStatus:
      return S_ERROR("Error while retrieving sources from SVN: %s" % "\n".join([stdData, errData]))
    return S_OK()
Пример #6
0
def executeRabbitmqctl(arg, *argv):
    """Executes RabbitMQ administration command.
    It uses rabbitmqctl command line interface.
    For every command the -q argument ("quit mode")
    is used, since in some cases the output must be processed,
    so we don't want any additional informations printed.
  Args:
    arg(str): command recognized by the rabbitmqctl.
    argv(list): optional list of string parameters.
  Returns:
    S_OK:
    S_ERROR:

  """
    command = ['sudo', '/usr/sbin/rabbitmqctl', '-q', arg] + list(argv)
    timeOut = 30
    result = Subprocess.systemCall(timeout=timeOut, cmdSeq=command)
    if result['OK']:
        errorcode, cmd_out, cmd_err = result['Value']
    else:
        return S_ERROR(
            errno.EPERM, "%r failed, status code: %s stdout: %r stderr: %r" %
            (command, errorcode, cmd_out, cmd_err))
    if errorcode:
        # No idea what errno code should be used here.
        # Maybe we should define some specific for rabbitmqctl
        return S_ERROR(
            errno.EPERM, "%r failed, status code: %s stdout: %r stderr: %r" %
            (command, errorcode, cmd_out, cmd_err))
    return S_OK(cmd_out)
Пример #7
0
def executeRabbitmqctl(arg, *argv):
  """Executes RabbitMQ administration command.
    It uses rabbitmqctl command line interface.
    For every command the -q argument ("quit mode")
    is used, since in some cases the output must be processed,
    so we don't want any additional informations printed.
  Args:
    arg(str): command recognized by the rabbitmqctl.
    argv(list): optional list of string parameters.
  Returns:
    S_OK:
    S_ERROR:

  """
  command =['sudo','/usr/sbin/rabbitmqctl','-q', arg] + list(argv)
  timeOut = 30
  result = Subprocess.systemCall(timeout = timeOut, cmdSeq = command)
  if result['OK']:
    errorcode, cmd_out, cmd_err = result['Value']
  else:
    return S_ERROR(errno.EPERM, "%r failed, status code: %s stdout: %r stderr: %r" %
                                (command, errorcode, cmd_out, cmd_err) )
  if errorcode:
    # No idea what errno code should be used here.
    # Maybe we should define some specific for rabbitmqctl
    return S_ERROR(errno.EPERM, "%r failed, status code: %s stdout: %r stderr: %r" %
                                (command, errorcode, cmd_out, cmd_err) )
  return S_OK(cmd_out)
 def __checkoutFromSVN(self):
     cmd = "svn export --trust-server-cert --non-interactive '%s/%s' '%s'" % (
         self.params.sourceURL, self.params.version,
         os.path.join(self.params.destination, self.params.name))
     gLogger.verbose("Executing: %s" % cmd)
     result = Subprocess.systemCall(900, shlex.split(cmd))
     if not result['OK']:
         return S_ERROR("Error while retrieving sources from SVN: %s" %
                        result['Message'])
     exitStatus, stdData, errData = result['Value']
     if exitStatus:
         return S_ERROR("Error while retrieving sources from SVN: %s" %
                        "\n".join([stdData, errData]))
     return S_OK()