added fetch_context, get_rspec and main methods
authorTony Mack <tmack@cs.princeton.edu>
Wed, 2 Dec 2009 03:33:12 +0000 (03:33 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Wed, 2 Dec 2009 03:33:12 +0000 (03:33 +0000)
sfa/managers/aggregate_manager_pl.py
sfa/managers/slice_manager_pl.py

index a9792b6..68fd9f5 100644 (file)
@@ -76,10 +76,9 @@ def get_slices(api):
     slices.refresh()
     return slices['hrn']
      
-  
-
  
 def get_rspec(api, hrn=None):
+    from sfa.plc.nodes import Nodes
     nodes = Nodes(api)
     if hrn:
         rspec = nodes.get_rspec(hrn)
index c68d952..c2c5806 100644 (file)
@@ -162,4 +162,32 @@ def get_slices(api):
     slices.refresh()
     return slices['hrn']
      
+def get_rspec(api, hrn=None):
+    from sfa.plc.nodes import Nodes
+    nodes = Nodes(api)
+    if hrn:
+        rspec = nodes.get_rspec(hrn)
+    else:
+        nodes.refresh()
+        rspec = nodes['rspec']
+
+    return rspec
+
+"""
+Returns the request context required by sfatables. At some point, this mechanism should be changed
+to refer to "contexts", which is the information that sfatables is requesting. But for now, we just
+return the basic information needed in a dict.
+"""
+def fetch_context(slice_hrn, user_hrn, contexts):
+    base_context = {'sfa':{'user':{'hrn':user_hrn}}}
+    return base_context
+
+def main():
+    r = RSpec()
+    r.parseFile(sys.argv[1])
+    rspec = r.toDict()
+    create_slice(None,'plc.princeton.tmacktestslice',rspec)
+
+if __name__ == "__main__":
+    main()