예제 #1
0
    def Run(self,program,args,folder,silent=False):

        # shell command
        commands = ['./'+program]
        commands.extend(args)

        # logfile
        logfile = folder+'/'+program+'.log'

        # call
        result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder,silent)

        # return result
        if not result and not silent:
            logging.error('impossible to run the project. For more details, see the log file:')
            logging.error(logfile)
            
        return result
예제 #2
0
    def Run(self,program,args,folder,silent=False):

        # shell command
        commands = ['./'+program]
        commands.extend(args)
        self.logger.debug("Command: "+" ".join(commands))

        # logfile
        logfile = os.path.normpath(folder+'/'+program+'.log')
        self.logger.debug("LogFile: "+logfile)

        # call
        result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder,silent)

        # return result
        if not result and not silent:
            self.logger.error('impossible to run the project. For more details, see the log file:')
            self.logger.error(logfile)
            
        return result
예제 #3
0
    def Run(self, program, args, folder, silent=False):

        # shell command
        commands = ['./' + program]
        commands.extend(args)

        # logfile
        logfile = folder + '/' + program + '.log'

        # call
        result, out = ShellCommand.ExecuteWithLog(commands, logfile, folder,
                                                  silent)

        # return result
        if not result and not silent:
            logging.error(
                'impossible to run the project. For more details, see the log file:'
            )
            logging.error(logfile)

        return result
예제 #4
0
def main(args):
  try:
    opts, pargs = getopt.getopt(args, "", ["inter=", "inter_ssh=",
                                           "version=", "machines=",
                                           "force" ])
  except:
    sys.exit(__doc__)

  # default values
  machines = []
  inter_machine = None
  inter_ssh_port = 22
  version = None
  force = 0

  if len(opts) == 0:
    # no flags were given, use old style args: <inter> <machine_list>
    if len(pargs) < 2: sys.exit(__doc__)
    inter_machine = pargs[0]
    machines = pargs[1:]
  else:
    # flags were given, use new style
    if len(pargs) != 0: sys.exit(__doc__)

    for name,value in opts:
      if name == '--inter': inter_machine = value
      elif name == '--inter_ssh': inter_ssh_port = string.atoi(value)
      elif name == '--version': version = value
      elif name == '--machines': machines = string.split(value, ',')
      elif name == '--force': force = 1

  if len(machines) == 0:
    sys.exit("ERROR: Must specify machines to clean")

  commands = []

  if version:
    # Cleanup up only a specific version of RPMS
    test_cmd = 'cat /export/hda3/%s/STATE 2>/dev/null' % version

    # Change the STATE file to "REMOVE"
    commands.append('echo REMOVE > /export/hda3/%s/STATE' % version)

    commands.extend( uninstall_version_rpms(version) )
    commands.append( "rm -rf /export/hd?3/%s" % version )

    # Remove any lingering chubby config info and localbabysitter files
    commands.append( "rm -f /etc/google/ent%s.chubby_cell "
                     "/etc/localbabysitter.d/*-%s.conf" %
                     (version.replace('.', '-'), version) )

    if force:
      # Kill any lingering processes with this version number
      commands.append( "/usr/bin/pkill -KILL -f '/%s/'" %
                       version.replace('.', '\\.') )
      commands.append( "/usr/bin/pkill -KILL -f '/%s/'" %
                       version.replace('.', '\\.') )

    commands.extend( version_dependent_named_cleanup(version) )

  else:
    # Uninstall all enterprise RPMS
    # all new versions should clean up after themselves in %preun/%postun
    test_cmd = 'cat /export/hda3/*/STATE 2>/dev/null'

    # Change the STATE file(s) to "REMOVE"
    commands.append('echo REMOVE | tee `ls /export/hda3/*/STATE` > /dev/null')

    commands.extend(uninstall_all_rpms())

    # Cleanup legacy versions and third party RPMS and some other files
    commands.extend(version_independent_misc_cleanup())

    # Remove any lingering chubby config info and version related
    # localbabysitter files. syslogd.conf and klogd.conf belong to
    # OS and cannot be removed.
    commands.append( "rm -f /etc/google/ent*.chubby_cell "
                     "/etc/localbabysitter.d/*-*.conf")

    # Remove zone stuff from named.conf
    commands.extend( version_independent_named_cleanup() )

    if force:
      # Kill any lingering processes belonging to nobody
      commands.append( "/usr/bin/pkill -KILL -u nobody" )
      commands.append( "/usr/bin/pkill -KILL -u nobody" )

  raw_cmd = string.join(commands, '; ')

  for machine in machines:
    print
    print "#################"
    print "Cleaning machine %s" % machine
    print "#################"

    ssh_cmd = remote_cmd(machine, test_cmd)

    if inter_machine:
      cmd = remote_cmd(inter_machine, ssh_cmd, inter_ssh_port)
    else:
      cmd = ssh_cmd

    p = os.popen(cmd, 'r')
    for line in p.readlines():
      if line.find('ACTIVE') == 0:
        sys.stdout.write('Warning: Machine %s in active state\n' % machine)
        if not force:
          sys.exit('Quitting.  Use --force flag to force clean.')

    p.close()

    ssh_cmd = remote_cmd(machine, raw_cmd)

    if inter_machine:
      cmd = remote_cmd(inter_machine, ssh_cmd, inter_ssh_port)
    else:
      cmd = ssh_cmd

    os.system(cmd)