Example #1
0
def get_handle_from_nodehandle(nodehandle):
  '''
  <Purpose>
    Given a node handle (e.g. 192.168.1.1:1224:v8), figure out its vesselhandle.

  <Parameters>
    nodehandle:
      A string representing a vessel, in the format 'node_id:port:vesselname'

  <Exceptions>
    NMClientException

  <Side Effects>
    Connect to the given node handle.

  <Return>
    The vesselhandle that corresponds with the node handle.

  '''
  nodeid, port, vesselname = nodehandle.split(':')
  port = int(port)
  nmhandle = fastnmclient.nmclient_createhandle(nodeid, port)
  try:
    vesseldict = fastnmclient.nmclient_getvesseldict(nmhandle)
  finally:
    fastnmclient.nmclient_destroyhandle(nmhandle)
  return rsa_publickey_to_string(vesseldict['nodekey']) + ':' + vesselname
Example #2
0
        handleinfo['vesselname'] = vesselname
        fastnmclient.nmclient_set_handle_info(newhandle, handleinfo)

        # then add the vessel to the target list, etc.
        # add_vessel has no race conditions as long as longname is unique
        # (and it should be unique)
        id = add_vessel(longname,currentkeyname,newhandle)
        seash_global_variables.targets[targetgroup].append(longname)

        # and append some information to be printed...
        retlist.append('%'+str(id)+"("+longname+")")



  finally:
    fastnmclient.nmclient_destroyhandle(nodehandle)

  return (True, retlist)


def list_or_update_target(longname):

  vesselname = seash_global_variables.vesselinfo[longname]['vesselname']

  try:
    vesseldict = fastnmclient.nmclient_getvesseldict(seash_global_variables.vesselinfo[longname]['handle'])

  except fastnmclient.NMClientException, e:
    return (False, str(e))

  else:
Example #3
0
                newhandle = fastnmclient.nmclient_duplicatehandle(nodehandle)
                handleinfo = fastnmclient.nmclient_get_handle_info(newhandle)
                handleinfo['vesselname'] = vesselname
                fastnmclient.nmclient_set_handle_info(newhandle, handleinfo)

                # then add the vessel to the target list, etc.
                # add_vessel has no race conditions as long as longname is unique
                # (and it should be unique)
                id = add_vessel(longname, currentkeyname, newhandle)
                seash_global_variables.targets[targetgroup].append(longname)

                # and append some information to be printed...
                retlist.append('%' + str(id) + "(" + longname + ")")

    finally:
        fastnmclient.nmclient_destroyhandle(nodehandle)

    return (True, retlist)


def list_or_update_target(longname):

    vesselname = seash_global_variables.vesselinfo[longname]['vesselname']

    try:
        vesseldict = fastnmclient.nmclient_getvesseldict(
            seash_global_variables.vesselinfo[longname]['handle'])

    except fastnmclient.NMClientException, e:
        return (False, str(e))