Пример #1
0
def main():

  identity = experimentlib.create_identity_from_key_files(PUBLICKEY_FILENAME, PRIVATEKEY_FILENAME)

  nodelocation_list = experimentlib.lookup_node_locations_by_identity(identity)

  print("Number of advertising nodes: " + str(len(nodelocation_list)))

  vesselhandle_list = experimentlib.find_vessels_on_nodes(identity, nodelocation_list)

  print("Number of active vessels: " + str(len(vesselhandle_list)))

  # Note that we could use experimentlib.run_parallelized() to parallelize
  # this, but for simplicity we do each sequentially.

  for vesselhandle in vesselhandle_list:
    try:
      nodeid, vesselname = experimentlib.get_nodeid_and_vesselname(vesselhandle)
      nodelocation = experimentlib.get_node_location(nodeid)
  
      # Note: you may want to reset_vessel().
      
      experimentlib.upload_file_to_vessel(vesselhandle, identity, PROGRAM_FILE)
      print("Uploaded " + PROGRAM_FILE + " to " + nodelocation + " vessel " + vesselname)
          
      experimentlib.start_vessel(vesselhandle, identity, PROGRAM_FILE, ARGUMENTS_TO_START_PROGRAM_WITH)
      print("Program started on " + nodelocation + " vessel " + vesselname)
        
    except experimentlib.SeattleExperimentError, e:
      print("Failure on vessel " + vesselhandle + ". Error was: " + str(e))
Пример #2
0
def main():

  identity = experimentlib.create_identity_from_key_files(PUBLICKEY_FILENAME, PRIVATEKEY_FILENAME)

  nodelocation_list = experimentlib.lookup_node_locations_by_identity(identity)

  print("Number of advertising nodes: " + str(len(nodelocation_list)))

  vesselhandle_list = experimentlib.find_vessels_on_nodes(identity, nodelocation_list)

  print("Number of active vessels: " + str(len(vesselhandle_list)))

  # Note that we could use experimentlib.run_parallelized() to parallelize the
  # uploading of files and speed things up, but for simplicity we do each
  # upload sequentially.

  for vesselhandle in vesselhandle_list:
    try:
      nodeid, vesselname = experimentlib.get_nodeid_and_vesselname(vesselhandle)
      nodelocation = experimentlib.get_node_location(nodeid)
      
      for local_filename in FILES_TO_UPLOAD:
        experimentlib.upload_file_to_vessel(vesselhandle, identity, local_filename)
        print("Uploaded " + local_filename + " to " + nodelocation + " vessel " + vesselname)
      
    except experimentlib.SeattleExperimentError, e:
      print("Failure on vessel " + vesselhandle + ". Error was: " + str(e))
Пример #3
0
    def _upload_to_vessels_helper(self, vessel, filename_list):
        for filename in filename_list:
            try:
                explib.upload_file_to_vessel(vessel, self.config["identity"], filename)

            except explib.NodeCommunicationError:
                self.logger.error("Failed to upload '" + filename + "' to vessel " + self.vessel_location(vessel))

            else:
                self.logger.debug("Successfully uploaded '" + filename + "' to vessel " + self.vessel_location(vessel))
                self.successful_handlers.append(vessel)
Пример #4
0
    def _upload_to_vessels_helper(self, vessel, filename_list):
        for filename in filename_list:
            try:
                explib.upload_file_to_vessel(vessel, self.config['identity'],
                                             filename)

            except explib.NodeCommunicationError:
                self.logger.error("Failed to upload '" + filename +
                                  "' to vessel " +
                                  self.vessel_location(vessel))

            else:
                self.logger.debug("Successfully uploaded '" + filename +
                                  "' to vessel " +
                                  self.vessel_location(vessel))
                self.successful_handlers.append(vessel)
Пример #5
0
def upload_to_vessels(vesselhandle_list, filename):
  """
  <Purpose>
    Uploads a file to a set of vessels. A batch wrapper around the Experiment
    Library function upload_file_to_vessel, with logging support.

  <Arguments>
    vesselhandle_list
      A list of vesselhandles of vessels to which the file is to be uploaded.
    filename
      The filename of the file to be uploaded.

  <Exceptions>
    None

  <Side Effects>
    None
    
  <Returns>
    A list of vessels to which the upload succeeded.
  """

  # Log the fact that uploads are occurring
  config['logfile'].write(str(time.time()) + ': Uploading ' + filename + ' to '+ str(len(vesselhandle_list)) + ' vessel(s)...\n')
  config['logfile'].flush()


  # Initially set return list equal to argument vesselhandle list
  success_list = vesselhandle_list
  failed_list = []
  # For each vesselhandle, attempt an upload
  for vh in vesselhandle_list:
    try:
      print "UPLOADING:%s  - %s" % (vh, filename)
      explib.upload_file_to_vessel(vh, config['identity'], filename)
    except explib.NodeCommunicationError, e:
      # If upload failed, remove from vesselhandle_list...
      success_list.remove(vh)
      # ...add to failed_list...
      failed_list.append(vh)
      # ...and lookup the nodelocation so it can be logged
      nodeid, vesselname = explib.get_nodeid_and_vesselname(vh)
      nodelocation = explib.get_node_location(nodeid)
      config['logfile'].write('Failure on vessel ' + nodelocation + '\n')
      config['logfile'].write('Error was: ' + str(e) + '\n')
      config['logfile'].flush()
Пример #6
0
def main():

    identity = experimentlib.create_identity_from_key_files(
        PUBLICKEY_FILENAME, PRIVATEKEY_FILENAME)

    nodelocation_list = experimentlib.lookup_node_locations_by_identity(
        identity)

    print("Number of advertising nodes: " + str(len(nodelocation_list)))

    vesselhandle_list = experimentlib.find_vessels_on_nodes(
        identity, nodelocation_list)

    print("Number of active vessels: " + str(len(vesselhandle_list)))

    # Note that we could use experimentlib.run_parallelized() to parallelize
    # this, but for simplicity we do each sequentially.

    for vesselhandle in vesselhandle_list:
        try:
            nodeid, vesselname = experimentlib.get_nodeid_and_vesselname(
                vesselhandle)
            nodelocation = experimentlib.get_node_location(nodeid)

            # Note: you may want to reset_vessel().

            experimentlib.upload_file_to_vessel(vesselhandle, identity,
                                                PROGRAM_FILE)
            print("Uploaded " + PROGRAM_FILE + " to " + nodelocation +
                  " vessel " + vesselname)

            experimentlib.start_vessel(vesselhandle, identity, PROGRAM_FILE,
                                       ARGUMENTS_TO_START_PROGRAM_WITH)
            print("Program started on " + nodelocation + " vessel " +
                  vesselname)

        except experimentlib.SeattleExperimentError, e:
            print("Failure on vessel " + vesselhandle + ". Error was: " +
                  str(e))