import os
-from subprocess import call
+import re
+from subprocess import *
from sfa.util.rspecHelper import RSpec
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()
SfaData.__init__(self)
self.registry = "http://www.planet-lab.org:12345"
self.slicemgr = "http://www.vini-veritas.net:12346"
+ self.rspec = None
- def getRSpec(self):
+ def refreshRSpec(self):
xml = SfaData.getRSpec(self)
- return RSpec(xml)
+ self.rspec = RSpec(xml)
- def applyRSpec(self, rspec):
- xml = rspec.toxml()
+ def getRSpec(self):
+ if self.rspec is None:
+ self.refreshRSpec()
+ return self.rspec
+
+ def applyRSpec(self):
+ xml = self.rspec.toxml()
SfaData.applyRSpec(self, xml)
class PlanetLabData(SfaData):
SfaData.__init__(self)
self.registry = "http://www.planet-lab.org:12345"
self.slicemgr = "http://www.planet-lab.org:12346"
+ self.rspec = None
- def getRSpec(self):
+ def refreshRSpec(self):
xml = SfaData.getRSpec(self)
- return RSpec(xml)
+ self.rspec = RSpec(xml)
- def applyRSpec(self, rspec):
- xml = rspec.toxml()
+ def getRSpec(self):
+ if self.rspec is None:
+ self.refreshRSpec()
+ return self.rspec
+
+ def applyRSpec(self):
+ xml = self.rspec.toxml()
SfaData.applyRSpec(self, xml)
class OpenCirrusData(SfaData):