예제 #1
0
def main():
  """
  <Purpose>
    Entry point into the program.  Reads the hosts that need installing
    from file and then starts the threads that will take care of downloading
    and installing seattle.  Then waits for all threads to finish.  This takes
    a while as an RSA key needs to be generated during each install.

  <Arguments>
    None

  <Exceptions>
    Possible exception when launching new threads.

  <Side Effects>
    None.

  <Returns>
    None.
  """
  
  # start the timeout monitor thread
  deploy_threading.init()
  
  # the fn of the file that contains the list of nodes we'll be using
  nodelist_fn = ''
  
  # did we get a parameter passed in? if so that's our fn
  if len(sys.argv) > 1:
    nodelist_fn = sys.argv[1]
    print 'Using '+nodelist_fn+' filename to read in hostnames'
  else:
    print 'Using default missing.list filename to read in hostnames'
    
  # get hosts from file
  #if nodelist_fn:
  #  hosts = get_remote_hosts_from_file(nodelist_fn)
  #else: # use default fn
  #  hosts = get_remote_hosts_from_file()
  # '128.208.1.130', 128.208.1.217
  
  # or manually type in hosts here
  hosts = [ ]
  
  # if we have hostnames
  if hosts:
    
    
    # BEGIN
    func_handle = parallelize_repy.parallelize_initfunction(hosts, worker, 10)
    
    size = str(len(hosts))
    
    while not parallelize_repy.parallelize_isfunctionfinished(func_handle):
      results_dict = parallelize_repy.parallelize_getresults(func_handle)
      print str(len(results_dict['aborted']))+' aborted, '+str(len(results_dict['exception']))+\
          ' exceptioned, '+str(len(results_dict['returned']))+' finished of '+size+' total.'
      time.sleep(5)
      
  deploy_threading.destroy()
def main():
  """
  <Purpose>
    Entry point into the program.  Reads the hosts that need installing
    from file and then starts the threads that will take care of downloading
    and installing seattle.  Then waits for all threads to finish.  This takes
    a while as an RSA key needs to be generated during each install.

  <Arguments>
    None

  <Exceptions>
    Possible exception when launching new threads.

  <Side Effects>
    None.

  <Returns>
    None.
  """
  
  # start the timeout monitor thread
  deploy_threading.init()
  
  # the fn of the file that contains the list of nodes we'll be using
  nodelist_fn = ''
  
  # did we get a parameter passed in? if so that's our fn
  if len(sys.argv) > 1:
    nodelist_fn = sys.argv[1]
    print 'Using '+nodelist_fn+' filename to read in hostnames'
  else:
    print 'Using default missing.list filename to read in hostnames'
    
  # get hosts from file
  if nodelist_fn:
    hosts = get_remote_hosts_from_file(nodelist_fn)
  else: # use default fn
    hosts = get_remote_hosts_from_file()
  
  # if we have hostnames
  if hosts:
    # build up a command string that'll download and install seattle
    cmd_list = []
    
    # try to uninstall seattle_repy, then remove dir
    cmd_list.append('cd seattle_repy; ./stop_seattle.sh; ./uninstall.sh')
    # 1. Remove old file, and download the file
    cmd_list.append('cd ~; rm -rf seattle_linux.tgz; rm -rf seattle_repy')
    
    cmd_list.append('wget https://seattlegeni.cs.washington.edu/geni/download/flibble/seattle_linux.tgz')
    
    
    # 2. Untar
    cmd_list.append('tar -xf seattle_linux.tgz')
    
    # 3. Change into seattle_repy directory and execute python install.py and start seattle
    cmd_list.append('cd seattle_repy; python install.py; ./start_seattle.sh ')
    
    # merge into a command string
    cmd_str = '; '.join(cmd_list)
    
    while hosts:
      # 8 is the number of threads we'll launch
      while thread_counter < 8:
        # grab a tuple from hosts array
        host = hosts.pop()
        
        # separate it out for clarity
        user = host[0]
        machine = host[1]
        
        print 'Starting on '+str(machine)
         
        try:
          # start thread and then give it some time to boot up
          thread.start_new_thread(worker, (cmd_str, user, machine,))
          time.sleep(.2)
        except Exception, e:
          print "Exception while trying to start worker thread"
          print e
          return
      
    # wait until we're done...
    while thread_counter > 0:
      time.sleep(1)
def main():
    """
  <Purpose>
    Entry point into the program.  Reads the hosts that need installing
    from file and then starts the threads that will take care of downloading
    and installing seattle.  Then waits for all threads to finish.  This takes
    a while as an RSA key needs to be generated during each install.

  <Arguments>
    None

  <Exceptions>
    Possible exception when launching new threads.

  <Side Effects>
    None.

  <Returns>
    None.
  """

    # start the timeout monitor thread
    deploy_threading.init()

    # the fn of the file that contains the list of nodes we'll be using
    nodelist_fn = ''

    # did we get a parameter passed in? if so that's our fn
    if len(sys.argv) > 1:
        nodelist_fn = sys.argv[1]
        print 'Using ' + nodelist_fn + ' filename to read in hostnames'
    else:
        print 'Using default missing.list filename to read in hostnames'

    # get hosts from file
    if nodelist_fn:
        hosts = get_remote_hosts_from_file(nodelist_fn)
    else:  # use default fn
        hosts = get_remote_hosts_from_file()

    # if we have hostnames
    if hosts:
        # build up a command string that'll download and install seattle
        cmd_list = []

        # try to uninstall seattle_repy, then remove dir
        cmd_list.append('cd seattle_repy; ./stop_seattle.sh; ./uninstall.sh')
        # 1. Remove old file, and download the file
        cmd_list.append('cd ~; rm -rf seattle_linux.tgz; rm -rf seattle_repy')

        cmd_list.append(
            'wget https://seattlegeni.cs.washington.edu/geni/download/flibble/seattle_linux.tgz'
        )

        # 2. Untar
        cmd_list.append('tar -xf seattle_linux.tgz')

        # 3. Change into seattle_repy directory and execute python install.py and start seattle
        cmd_list.append(
            'cd seattle_repy; python install.py; ./start_seattle.sh ')

        # merge into a command string
        cmd_str = '; '.join(cmd_list)

        while hosts:
            # 8 is the number of threads we'll launch
            while thread_counter < 8:
                # grab a tuple from hosts array
                host = hosts.pop()

                # separate it out for clarity
                user = host[0]
                machine = host[1]

                print 'Starting on ' + str(machine)

                try:
                    # start thread and then give it some time to boot up
                    thread.start_new_thread(worker, (
                        cmd_str,
                        user,
                        machine,
                    ))
                    time.sleep(.2)
                except Exception, e:
                    print "Exception while trying to start worker thread"
                    print e
                    return

        # wait until we're done...
        while thread_counter > 0:
            time.sleep(1)