Exemplo n.º 1
0
def _update_targets(vesseldicts, environment_dict):
    """
  <Purpose>
    Connects to the nodes in the vesseldicts and adds them to the list
    of valid targets.

  <Arguments>
    vesseldicts:
        A list of vesseldicts obtained through
        SeattleClearinghouseClient calls.

  <Side Effects>
    All valid targets that the user can access on the specified nodes
    are added to the list of targets.

  <Exceptions>
    None

  <Returns>
    None
  """
    # Compile a list of the nodes that we need to check
    nodelist = []
    for vesseldict in vesseldicts:
        nodeip_port = vesseldict["node_ip"] + ":" + str(vesseldict["node_port"])
        if not nodeip_port in nodelist:
            nodelist.append(nodeip_port)

    # we'll output a message about the new keys later...
    newidlist = []
    faillist = []

    # Clear the list so that the user doesn't target vessels acquired from
    # previous requests when targeting this group
    seash_global_variables.targets["acquired"] = []
    print nodelist

    # currently, if I browse more than once, I look up everything again...
    retdict = seash_helper.contact_targets(
        nodelist, seash_helper.browse_target, environment_dict["currentkeyname"], "acquired"
    )

    # parse the output so we can print out something intelligible
    for nodename in retdict:
        if retdict[nodename][0]:
            newidlist = newidlist + retdict[nodename][1]
        else:
            faillist.append(nodename)

    seash_helper.print_vessel_errors(retdict)

    if len(newidlist) == 0:
        print "Could not add any new targets."
    else:
        print "Added targets: " + ", ".join(newidlist)

    if len(seash_global_variables.targets["acquired"]) > 0:
        num_targets = str(len(seash_global_variables.targets["acquired"]))
        print "Added group 'acquired' with " + num_targets + " targets"
Exemplo n.º 2
0
def release(input_dict, environment_dict):
    """
  <Purpose>
    Releases the specified vessels.

  <Arguments>
    input_dict:  The commanddict representing the user's input.
    environment_dict:  The dictionary representing the current seash
                       environment.

  <Side Effects>
    Connects to the Clearinghouse and releases vessels.
    Removes the released vessels from the list of valid targets.
    Does not guarantee that all vessels specified are released!

  <Exceptions>
    None

  <Returns>
    None
  """
    # Activate secure mode if user did not specify the insecure keyword
    allow_ssl_insecure = _get_user_argument(input_dict, 'insecure') is not None

    # Get the group name to release
    groupname = environment_dict['currenttarget']
    nodelist = seash_global_variables.targets[groupname]

    # Get the Clearinghouse vessel handles for each vessel
    retdict = seash_helper.contact_targets(nodelist,
                                           _get_clearinghouse_vessel_handle)

    clearinghouse_vesselhandles = []
    faillist = []
    # parse the output so we can print out something intelligible
    for nodename in retdict:

        if retdict[nodename][0]:
            clearinghouse_vesselhandles.append(retdict[nodename][1])
        else:
            faillist.append(nodename)

    # Release!
    client = _connect_to_clearinghouse(environment_dict['currentkeyname'],
                                       allow_ssl_insecure)
    client.release_resources(clearinghouse_vesselhandles)

    # Remove each vessel from the targets list
    removed_nodehandles = seash_global_variables.targets[groupname][:]
    for handle in removed_nodehandles:
        for target in seash_global_variables.targets:
            if handle in seash_global_variables.targets[target]:
                seash_global_variables.targets[target].remove(handle)
Exemplo n.º 3
0
def release(input_dict, environment_dict):
  """
  <Purpose>
    Releases the specified vessels.

  <Arguments>
    input_dict:  The commanddict representing the user's input.
    environment_dict:  The dictionary representing the current seash
                       environment.

  <Side Effects>
    Connects to the Clearinghouse and releases vessels.
    Removes the released vessels from the list of valid targets.
    Does not guarantee that all vessels specified are released!

  <Exceptions>
    None

  <Returns>
    None
  """
  # Activate secure mode if user did not specify the insecure keyword
  allow_ssl_insecure = _get_user_argument(input_dict, 'insecure') is not None

  # Get the group name to release
  groupname = environment_dict['currenttarget']
  nodelist = seash_global_variables.targets[groupname]

  # Get the Clearinghouse vessel handles for each vessel
  retdict = seash_helper.contact_targets(nodelist, _get_clearinghouse_vessel_handle)

  clearinghouse_vesselhandles = []
  faillist = []
  # parse the output so we can print out something intelligible
  for nodename in retdict:

    if retdict[nodename][0]:
      clearinghouse_vesselhandles.append(retdict[nodename][1])
    else:
      faillist.append(nodename)

  # Release!
  client = _connect_to_clearinghouse(environment_dict['currentkeyname'],
    allow_ssl_insecure)
  client.release_resources(clearinghouse_vesselhandles)

  # Remove each vessel from the targets list
  removed_nodehandles = seash_global_variables.targets[groupname][:]
  for handle in removed_nodehandles:
    for target in seash_global_variables.targets:
      if handle in seash_global_variables.targets[target]:
        seash_global_variables.targets[target].remove(handle)
Exemplo n.º 4
0
def _update_targets(vesseldicts, environment_dict):
  """
  <Purpose>
    Connects to the nodes in the vesseldicts and adds them to the list
    of valid targets.

  <Arguments>
    vesseldicts:
        A list of vesseldicts obtained through
        SeattleClearinghouseClient calls.

  <Side Effects>
    All valid targets that the user can access on the specified nodes
    are added to the list of targets.

  <Exceptions>
    None

  <Returns>
    None
  """
  # Compile a list of the nodes that we need to check
  nodelist = []
  for vesseldict in vesseldicts:
    nodeip_port = vesseldict['node_ip']+':'+str(vesseldict['node_port'])
    if not nodeip_port in nodelist:
      nodelist.append(nodeip_port)

  # we'll output a message about the new keys later...
  newidlist = []
  faillist = []

  # Clear the list so that the user doesn't target vessels acquired from
  # previous requests when targeting this group
  seash_global_variables.targets['acquired'] = []
  print nodelist

  # currently, if I browse more than once, I look up everything again...
  retdict = seash_helper.contact_targets(
    nodelist,
    seash_helper.browse_target,
    environment_dict['currentkeyname'],
    'acquired')

  # parse the output so we can print out something intelligible
  for nodename in retdict:
    if retdict[nodename][0]:
      newidlist = newidlist + retdict[nodename][1]
    else:
      faillist.append(nodename)

  seash_helper.print_vessel_errors(retdict)

  if len(newidlist) == 0:
    print "Could not add any new targets."
  else:
    print "Added targets: "+", ".join(newidlist)

  if len(seash_global_variables.targets['acquired']) > 0:
    num_targets = str(len(seash_global_variables.targets['acquired']))
    print "Added group 'acquired' with "+num_targets+" targets"