SFA browser basic functionality
[sfa-gui.git] / SfaData.py
index 049b0d3..b99c56e 100644 (file)
@@ -1,5 +1,6 @@
 import os
-from subprocess import call
+import re
+from subprocess import *
 from sfa.util.rspecHelper import RSpec
 
 class SfaData:
@@ -30,8 +31,26 @@ class SfaData:
     def setSlice(self, slice):
         SfaData.slice = slice
 
-    def getRecord(self):
-        pass
+    def getRecord(self, hrn):
+        text = Popen(["sfi.py", "-u", self.getUser(), "-a", 
+                      self.getAuthority(), "-r", self.registry, 
+                      "-s", self.slicemgr, "show", hrn], 
+                     stdout=PIPE).communicate()[0]
+        return text
+
+    def listChildren(self, hrn):
+        children = []
+        text = Popen(["sfi.py", "-u", self.getUser(), "-a", 
+                      self.getAuthority(), "-r", self.registry, 
+                      "-s", self.slicemgr, "list", hrn], 
+                     stdout=PIPE).communicate()[0]
+        lines = text.split('\n')
+        for line in lines:
+            if line:
+                (hrn, kind) = line.split() 
+                children.append((hrn, kind))
+
+        return children
 
     def getRSpec(self):
         slice = self.getSlice()