Exemple #1
0
    def acquire_vessels(self, vessel_count):
        """
    <Purpose>
      Acquire an argument number of vessels via SeattleGENI. Vessel type is
      obtained from the config dictionary. This function is a wrapper around the
      Experiment Library function seattlegeni_acquire_vessels, with logging
      support.

    <Arguments>
      number
        The number of vessels to acquire.

    <Exceptions>
      None

    <Side Effects>
      Renews the vessels upon acquisition to extend expiration time
    
    <Returns>
      A list of vesselhandles of freshly-acquired vessels. On failure, returns an
      empty list.
    """
        self.logger.info('Acquiring ' + str(vessel_count) + ' vessels')

        try:
            vessel_handlers = explib.seattlegeni_acquire_vessels(
                self.config['identity'], self.config['vessel_type'],
                vessel_count)

        except explib.SeattleClearinghouseError, e:
            self.logger.error('Error while acquiring vessels: ' + str(e))
            return []
Exemple #2
0
    def acquire_vessels(self, vessel_count):
        """
    <Purpose>
      Acquire an argument number of vessels via SeattleGENI. Vessel type is
      obtained from the config dictionary. This function is a wrapper around the
      Experiment Library function seattlegeni_acquire_vessels, with logging
      support.

    <Arguments>
      number
        The number of vessels to acquire.

    <Exceptions>
      None

    <Side Effects>
      Renews the vessels upon acquisition to extend expiration time
    
    <Returns>
      A list of vesselhandles of freshly-acquired vessels. On failure, returns an
      empty list.
    """
        self.logger.info("Acquiring " + str(vessel_count) + " vessels")

        try:
            vessel_handlers = explib.seattlegeni_acquire_vessels(
                self.config["identity"], self.config["vessel_type"], vessel_count
            )

        except explib.SeattleClearinghouseError, e:
            self.logger.error("Error while acquiring vessels: " + str(e))
            return []
Exemple #3
0
def acquire_vessels(number):
  """
  <Purpose>
    Acquire an argument number of vessels via SeattleGENI. Vessel type is
    obtained from the config dictionary. This function is a wrapper around the
    Experiment Library function seattlegeni_acquire_vessels, with logging
    support.

  <Arguments>
    number
      The number of vessels to acquire.

  <Exceptions>
    None

  <Side Effects>
    None
    
  <Returns>
    A list of vesselhandles of freshly-acquired vessels. On failure, returns an
    empty list.
  """

  # Log the fact that vessels are being acquired
  config['logfile'].write(str(time.time()) + ': Acquiring ' + str(number) + ' vessel(s)...')
  config['logfile'].flush()

  # Attempt to acquire vessels. Log success or failure, accordingly.
  try:
    vesselhandle_list = explib.seattlegeni_acquire_vessels(config['identity'],
                                                           config['vesseltype'],
                                                           number)
  except explib.SeattleGENIError, e:
    config['logfile'].write('failure\n')
    config['logfile'].write('Error was: ' + str(e) + '\n')
    return []
def main():

    identity = experimentlib.create_identity_from_key_files(PUBLICKEY_FILENAME, PRIVATEKEY_FILENAME)

    # Get a list of nodes advertising under the public key. Some of these
    # nodes may be unreachable or may have gone offline since they advertised.
    # This won't try to communicate with the actual nodes.
    nodelocation_list = experimentlib.lookup_node_locations_by_identity(identity)

    print("nodelocation_list:" + str(nodelocation_list))

    # Talk to each advertising node to find out which vessels we have on each.
    # We get back a list of dictionaries, where each dictionary describes a
    # vessel. There may be multiple vessels from any single node in this list.
    active_vesselhandle_list = experimentlib.find_vessels_on_nodes(identity, nodelocation_list)

    print("active_vesselhandle_list:" + str(active_vesselhandle_list))

    # Now we want to find out which vessels we've acquired through seattlegeni
    # that are not in our list. We may, for example, want to release those
    # vessels because we consider them unusable.

    try:
        expected_vesselhandle_list = experimentlib.seattlegeni_get_acquired_vessels(identity)

        print("expected_vesselhandle_list:" + str(expected_vesselhandle_list))

        # If we already have enough usable vessels, we're done.
        if len(active_vesselhandle_list) >= MIN_VESSELS_TO_KEEP:
            print(
                "There are already "
                + str(len(active_vesselhandle_list))
                + " active vessels "
                + "and our MIN_VESSELS_TO_KEEP is "
                + str(MIN_VESSELS_TO_KEEP)
            )
            return

        # We assume all of our vessels come from seattlegeni, so if any vessels we
        # should have access to according to seattlegeni aren't accessible or
        # otherwise usable, then release them.
        vesselhandles_to_release = []
        for vesselhandle in expected_vesselhandle_list:
            if vesselhandle not in active_vesselhandle_list:
                vesselhandles_to_release.append(vesselhandle)

        if vesselhandles_to_release:
            print(
                str(len(vesselhandles_to_release))
                + " vessels were inaccessible, so will try to release them:"
                + str(vesselhandles_to_release)
            )
            try:
                experimentlib.seattlegeni_release_vessels(identity, vesselhandles_to_release)
            except experimentlib.SeattleClearinghouseError, e:
                print("Failed to release vessels: " + str(e))
            else:
                print("Vessels successfully released.")

        # Determine the maximum number of vessels we can acquire through seattlegeni.
        max_vessels_allowed = experimentlib.seattlegeni_max_vessels_allowed(identity)
        print("max_vessels_allowed: " + str(max_vessels_allowed))

        # Determine the number of vessels we already have acquired through seattlegeni.
        num_currently_acquired = len(experimentlib.seattlegeni_get_acquired_vessels(identity))
        print("currently_acquired_count: " + str(num_currently_acquired))

        # Let's try to get as close to MIN_VESSELS_TO_KEEP without requesting more
        # than is allowed by this account.
        num_vessels_to_request = min(max_vessels_allowed, MIN_VESSELS_TO_KEEP) - num_currently_acquired

        if num_vessels_to_request <= 0:
            print("This account doesn't have enough vessel credits to request more vessels.")
            return
        else:
            print("Will try to acquire " + str(num_vessels_to_request) + " vessels.")

        vessel_type = experimentlib.SEATTLECLEARINGHOUSE_VESSEL_TYPE_WAN
        acquired_vessels = experimentlib.seattlegeni_acquire_vessels(identity, vessel_type, num_vessels_to_request)

        print("Acquired " + str(num_vessels_to_request) + " vessels: " + str(acquired_vessels))
Exemple #5
0
  * the current directory contains a valid PEM file containing CA certificates

To run appmap.py without SSL authentication, use the `--insecure` switch. Check documentation for more details."""

      sys.exit()
    
  # Get list of vessels user has previously allocated
  CBFUNC_CONTEXT['vesselhandle_list'] = experimentlib.seattlegeni_get_acquired_vessels(CBFUNC_CONTEXT['identity'])

  if appmap_config['num_nodes'] > 0 and len(CBFUNC_CONTEXT['vesselhandle_list']) > 0:
    # Release any vessels previously acquired from GENI
    experimentlib.seattlegeni_release_vessels(CBFUNC_CONTEXT['identity'], CBFUNC_CONTEXT['vesselhandle_list'])

  if appmap_config['num_nodes'] > 0:
    # Acquire argument number of vessels using seattlegeni interface
    CBFUNC_CONTEXT['vesselhandle_list'] = experimentlib.seattlegeni_acquire_vessels(CBFUNC_CONTEXT['identity'], "wan", int(appmap_config['num_nodes']))

  # If no vessels were acquired, an error occurred and script exits
  if len(CBFUNC_CONTEXT['vesselhandle_list']) == 0:
    print "Error: No vessels acquired. Try rerunning " + sys.argv[0]
    sys.exit()
    
  nodelocation_list = []
  vessel_details = experimentlib.seattlegeni_get_acquired_vessels_details(CBFUNC_CONTEXT['identity'])
  for vessel in vessel_details:
    nodelocation_list.append(vessel["nodelocation"])

  print("Number of vessels acquired: " + str(len(CBFUNC_CONTEXT['vesselhandle_list'])))
  
  # Write node IPs to file to be uploaded
  neighborip_fo = open("neighboriplist.txt", "w")
def main():

    identity = experimentlib.create_identity_from_key_files(
        PUBLICKEY_FILENAME, PRIVATEKEY_FILENAME)

    # Get a list of nodes advertising under the public key. Some of these
    # nodes may be unreachable or may have gone offline since they advertised.
    # This won't try to communicate with the actual nodes.
    nodelocation_list = experimentlib.lookup_node_locations_by_identity(
        identity)

    print("nodelocation_list:" + str(nodelocation_list))

    # Talk to each advertising node to find out which vessels we have on each.
    # We get back a list of dictionaries, where each dictionary describes a
    # vessel. There may be multiple vessels from any single node in this list.
    active_vesselhandle_list = experimentlib.find_vessels_on_nodes(
        identity, nodelocation_list)

    print("active_vesselhandle_list:" + str(active_vesselhandle_list))

    # Now we want to find out which vessels we've acquired through seattlegeni
    # that are not in our list. We may, for example, want to release those
    # vessels because we consider them unusable.

    try:
        expected_vesselhandle_list = experimentlib.seattlegeni_get_acquired_vessels(
            identity)

        print("expected_vesselhandle_list:" + str(expected_vesselhandle_list))

        # If we already have enough usable vessels, we're done.
        if len(active_vesselhandle_list) >= MIN_VESSELS_TO_KEEP:
            print("There are already " + str(len(active_vesselhandle_list)) +
                  " active vessels " + "and our MIN_VESSELS_TO_KEEP is " +
                  str(MIN_VESSELS_TO_KEEP))
            return

        # We assume all of our vessels come from seattlegeni, so if any vessels we
        # should have access to according to seattlegeni aren't accessible or
        # otherwise usable, then release them.
        vesselhandles_to_release = []
        for vesselhandle in expected_vesselhandle_list:
            if vesselhandle not in active_vesselhandle_list:
                vesselhandles_to_release.append(vesselhandle)

        if vesselhandles_to_release:
            print(
                str(len(vesselhandles_to_release)) +
                " vessels were inaccessible, so will try to release them:" +
                str(vesselhandles_to_release))
            try:
                experimentlib.seattlegeni_release_vessels(
                    identity, vesselhandles_to_release)
            except experimentlib.SeattleClearinghouseError, e:
                print("Failed to release vessels: " + str(e))
            else:
                print("Vessels successfully released.")

        # Determine the maximum number of vessels we can acquire through seattlegeni.
        max_vessels_allowed = experimentlib.seattlegeni_max_vessels_allowed(
            identity)
        print("max_vessels_allowed: " + str(max_vessels_allowed))

        # Determine the number of vessels we already have acquired through seattlegeni.
        num_currently_acquired = len(
            experimentlib.seattlegeni_get_acquired_vessels(identity))
        print("currently_acquired_count: " + str(num_currently_acquired))

        # Let's try to get as close to MIN_VESSELS_TO_KEEP without requesting more
        # than is allowed by this account.
        num_vessels_to_request = min(
            max_vessels_allowed, MIN_VESSELS_TO_KEEP) - num_currently_acquired

        if num_vessels_to_request <= 0:
            print(
                "This account doesn't have enough vessel credits to request more vessels."
            )
            return
        else:
            print("Will try to acquire " + str(num_vessels_to_request) +
                  " vessels.")

        vessel_type = experimentlib.SEATTLECLEARINGHOUSE_VESSEL_TYPE_WAN
        acquired_vessels = experimentlib.seattlegeni_acquire_vessels(
            identity, vessel_type, num_vessels_to_request)

        print("Acquired " + str(num_vessels_to_request) + " vessels: " +
              str(acquired_vessels))