Ejemplo n.º 1
0
def _get_queryset_exclude_nat(port):
    """
  Give a nicer though less accurate name to the function as we're using it a
  lot here in the tests.
  """
    return maindb._get_queryset_of_all_available_vessels_for_a_port_exclude_nat_nodes(
        port)
Ejemplo n.º 2
0
def get_available_vessel_counts_by_port():

  # Set the log level high enough so that we don't produce a bunch of logging
  # output due to the logging decorators.
  initial_log_level = log.loglevel
  log.set_log_level(log.LOG_LEVEL_INFO)

  available_vessels_dict = {}
  
  for port in maindb.ALLOWED_USER_PORTS:
    available_vessels_dict[port] = {}
    available_vessels_dict[port]["all"] = maindb._get_queryset_of_all_available_vessels_for_a_port_include_nat_nodes(port).count()
    available_vessels_dict[port]["no_nat"] = maindb._get_queryset_of_all_available_vessels_for_a_port_exclude_nat_nodes(port).count()
    available_vessels_dict[port]["only_nat"] = maindb._get_queryset_of_all_available_vessels_for_a_port_only_nat_nodes(port).count()
  
  # Restore the original log level.
  log.set_log_level(initial_log_level)
  
  return available_vessels_dict
Ejemplo n.º 3
0
def get_available_lan_vessel_counts():
  """
  Returns a dictionary where each key is a port and each value is a
  reverse-sorted list of integers representing the the sizes of subnets with
  available vessels on that port. These will be the maximum numbers of LAN
  vessels a user on that port could request at once.
  """
  
  lan_sizes_by_port = {}

  subnetlist = maindb._get_subnet_list()

  for port in maindb.ALLOWED_USER_PORTS:
    subnet_vessel_list_sizes = []
    nonnatvesselsqueryset = maindb._get_queryset_of_all_available_vessels_for_a_port_exclude_nat_nodes(port)
  
    for subnet in subnetlist:
      lanvesselsqueryset = nonnatvesselsqueryset.filter(node__last_known_ip__startswith=subnet + '.')
      subnet_vessel_list_sizes.append(lanvesselsqueryset.count())
  
    subnet_vessel_list_sizes.sort(reverse=True)
    lan_sizes_by_port[port] = subnet_vessel_list_sizes

  return lan_sizes_by_port
def _get_queryset_exclude_nat(port):
    """
  Give a nicer though less accurate name to the function as we're using it a
  lot here in the tests.
  """
    return maindb._get_queryset_of_all_available_vessels_for_a_port_exclude_nat_nodes(port)