Changeset 3303

Show
Ignore:
Timestamp:
12/17/09 14:25:16 (10 years ago)
Author:
jsamuel
Message:

In the experimentlib, add functions get_vesselhandle() and get_nodeid() and fix the format of the nodeid in vesseldicts returned by browse_node().

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/experimentmanager/experimentlib.py

    r3282 r3303  
    752752      vesseldict['nodelocation'] = nodelocation 
    753753      vesseldict['vesselname'] = vesselname 
    754       vesseldict['nodeid'] = nodeinfo['nodekey'] 
     754      vesseldict['nodeid'] = nodeid 
    755755      # Additional keys that browse_node provides. 
    756756      vesseldict['status'] = nodeinfo['vessels'][vesselname]['status'] 
     
    14281428  _validate_vesselhandle(vesselhandle) 
    14291429  return vesselhandle.split(":") 
     1430 
     1431 
     1432 
     1433 
     1434 
     1435def get_vesselhandle(nodeid, vesselname): 
     1436  """ 
     1437  <Purpose> 
     1438    Given a nodeid and vesselname, returns a vesselhandle that represents the 
     1439    vessel. 
     1440  <Arguments> 
     1441    nodeid 
     1442      The nodeid of the node that the vessel is on. 
     1443    vesselname 
     1444      The name of the vessel. 
     1445  <Exceptions> 
     1446    None 
     1447  <Side Effects> 
     1448    None 
     1449  <Returns> 
     1450    A vesselhandle. 
     1451  """ 
     1452  return nodeid + ":" + vesselname 
    14301453 
    14311454 
     
    15121535       
    15131536  return _node_location_cache[nodeid] 
    1514      
     1537 
     1538 
     1539 
     1540 
     1541 
     1542def get_nodeid(nodelocation): 
     1543  """ 
     1544  <Purpose> 
     1545    Determine a nodelocation given a nodeid. Note that if you have already 
     1546    obtained a vesselhandle for a vessel on the node, you can get the nodeid 
     1547    using get_nodeid_and_vesselname(vesselhandle), which would avoid having 
     1548    to contact the node. 
     1549  <Arguments> 
     1550    nodelocation 
     1551      The nodelocation of the node whose nodeid is to be determined. 
     1552  <Exceptions> 
     1553    NodeCommunicationError 
     1554      If a failure occurs in communicating with the node. 
     1555  <Side Effects> 
     1556    None 
     1557  <Returns> 
     1558    A nodeid. 
     1559  """ 
     1560  # We assume at least one vessel on the node. This is a safe assumption 
     1561  # unless there's something very wrong with the node. 
     1562  return browse_node(nodelocation)[0]['nodeid'] 
     1563 
    15151564   
    15161565