示例#1
0
def main():
  global force

  from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
  gComponentInstaller.exitOnError = True

  Script.registerSwitch("f", "force", "Forces the removal of the logs", setForce)
  Script.parseCommandLine()
  args = Script.getPositionalArgs()

  if len(args) == 1:
    args = args[0].split('/')

  if len(args) < 2:
    Script.showHelp(exitCode=1)

  system = args[0]
  component = args[1]

  monitoringClient = ComponentMonitoringClient()
  result = monitoringClient.getInstallations({'Instance': component, 'UnInstallationTime': None},
                                             {'System': system},
                                             {'HostName': socket.getfqdn()}, True)
  if not result['OK']:
    gLogger.error(result['Message'])
    DIRACexit(1)
  if len(result['Value']) < 1:
    gLogger.warn('Given component does not exist')
    DIRACexit(1)
  if len(result['Value']) > 1:
    gLogger.error('Too many components match')
    DIRACexit(1)

  removeLogs = False
  if force:
    removeLogs = True
  else:
    if result['Value'][0]['Component']['Type'] in gComponentInstaller.componentTypes:
      result = promptUser('Remove logs?', ['y', 'n'], 'n')
      if result['OK']:
        removeLogs = result['Value'] == 'y'
      else:
        gLogger.error(result['Message'])
        DIRACexit(1)

  result = gComponentInstaller.uninstallComponent(system, component, removeLogs)
  if not result['OK']:
    gLogger.error(result['Message'])
    DIRACexit(1)

  result = MonitoringUtilities.monitorUninstallation(system, component)
  if not result['OK']:
    gLogger.error(result['Message'])
    DIRACexit(1)
  gLogger.notice('Successfully uninstalled component %s/%s' % (system, component))
  DIRACexit()
示例#2
0
 def export_uninstallComponent(self, system, component, removeLogs):
     """ Remove runit directory for the specified component
     It implies unsetupComponent
 """
     return gComponentInstaller.uninstallComponent(system, component,
                                                   removeLogs)
示例#3
0
 def export_uninstallComponent( self, system, component, removeLogs ):
   """ Remove runit directory for the specified component
       It implies unsetupComponent
   """
   return gComponentInstaller.uninstallComponent( system, component, removeLogs )
    DIRACexit(1)
if len(result['Value']) > 1:
    gLogger.error('Too many components match')
    DIRACexit(1)

removeLogs = False
if force:
    removeLogs = True
else:
    if result['Value'][0]['Component'][
            'Type'] in gComponentInstaller.componentTypes:
        result = promptUser('Remove logs?', ['y', 'n'], 'n')
        if result['OK']:
            removeLogs = result['Value'] == 'y'
        else:
            gLogger.error(result['Message'])
            DIRACexit(1)

result = gComponentInstaller.uninstallComponent(system, component, removeLogs)
if not result['OK']:
    gLogger.error(result['Message'])
    DIRACexit(1)

result = MonitoringUtilities.monitorUninstallation(system, component)
if not result['OK']:
    gLogger.error(result['Message'])
    DIRACexit(1)
gLogger.notice('Successfully uninstalled component %s/%s' %
               (system, component))
DIRACexit()
if len( result[ 'Value' ] ) < 1:
  gLogger.warn( 'Given component does not exist' )
  DIRACexit( 1 )
if len( result[ 'Value' ] ) > 1:
  gLogger.error( 'Too many components match' )
  DIRACexit( 1 )

removeLogs = False
if force:
  removeLogs = True
else:
  if result[ 'Value' ][0][ 'Component' ][ 'Type' ] in gComponentInstaller.componentTypes:
    result = promptUser( 'Remove logs?', [ 'y', 'n' ], 'n' )
    if result[ 'OK' ]:
      removeLogs = result[ 'Value' ] == 'y'
    else:
      gLogger.error( result[ 'Message' ] )
      DIRACexit( 1 )

result = gComponentInstaller.uninstallComponent( system, component, removeLogs )
if not result['OK']:
  gLogger.error( result[ 'Message' ] )
  DIRACexit( 1 )

result = MonitoringUtilities.monitorUninstallation( system, component )
if not result['OK']:
  gLogger.error( result[ 'Message' ] )
  DIRACexit( 1 )
gLogger.notice( 'Successfully uninstalled component %s/%s' % ( system, component ) )
DIRACexit()
示例#6
0
def main():
    global force

    from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller

    gComponentInstaller.exitOnError = True

    Script.registerSwitch("f", "force", "Forces the removal of the logs",
                          setForce)
    # Registering arguments will automatically add their description to the help menu
    Script.registerArgument((
        "System/Component: Full component name (ie: WorkloadManagement/Matcher)",
        "System:           Name of the DIRAC system (ie: WorkloadManagement)",
    ))
    Script.registerArgument(
        " Component:        Name of the DIRAC service (ie: Matcher)",
        mandatory=False)
    _, args = Script.parseCommandLine()

    if len(args) == 1:
        args = args[0].split("/")

    if len(args) < 2:
        Script.showHelp(exitCode=1)

    system = args[0]
    component = args[1]

    monitoringClient = ComponentMonitoringClient()
    result = monitoringClient.getInstallations(
        {
            "Instance": component,
            "UnInstallationTime": None
        }, {"System": system}, {"HostName": socket.getfqdn()}, True)
    if not result["OK"]:
        gLogger.error(result["Message"])
        DIRACexit(1)
    if len(result["Value"]) < 1:
        gLogger.warn("Given component does not exist")
        DIRACexit(1)
    if len(result["Value"]) > 1:
        gLogger.error("Too many components match")
        DIRACexit(1)

    removeLogs = False
    if force:
        removeLogs = True
    else:
        if result["Value"][0]["Component"][
                "Type"] in gComponentInstaller.componentTypes:
            result = promptUser("Remove logs?", ["y", "n"], "n")
            if result["OK"]:
                removeLogs = result["Value"] == "y"
            else:
                gLogger.error(result["Message"])
                DIRACexit(1)

    result = gComponentInstaller.uninstallComponent(system, component,
                                                    removeLogs)
    if not result["OK"]:
        gLogger.error(result["Message"])
        DIRACexit(1)

    result = MonitoringUtilities.monitorUninstallation(system, component)
    if not result["OK"]:
        gLogger.error(result["Message"])
        DIRACexit(1)
    gLogger.notice("Successfully uninstalled component %s/%s" %
                   (system, component))
    DIRACexit()