3 from subprocess import *
4 from sfa.util.rspecHelper import RSpec
7 authority = "plc.princeton"
8 user = "plc.princeton.acb"
9 slice = "plc.princeton.sapan"
15 def getAuthority(self):
16 return SfaData.authority
21 def setUser(self, user):
24 # Should probably get authority from user record instead...
25 a = SfaData.user.split('.')
26 SfaData.authority = '.'.join(a[:len(a)-1])
31 def setSlice(self, slice):
34 def getRecord(self, hrn):
35 text = Popen(["sfi.py", "-u", self.getUser(), "-a",
36 self.getAuthority(), "-r", self.registry,
37 "-s", self.slicemgr, "show", hrn],
38 stdout=PIPE).communicate()[0]
41 def listChildren(self, hrn):
43 text = Popen(["sfi.py", "-u", self.getUser(), "-a",
44 self.getAuthority(), "-r", self.registry,
45 "-s", self.slicemgr, "list", hrn],
46 stdout=PIPE).communicate()[0]
47 lines = text.split('\n')
50 (hrn, kind) = line.split()
51 children.append((hrn, kind))
56 slice = self.getSlice()
57 # Write RSpec to file for testing.
58 filename = os.path.expanduser("~/.sfi/" + slice + ".rspec")
60 call(["sfi.py", "-u", self.getUser(), "-a", self.getAuthority(),
61 "-r", self.registry, "-s", self.slicemgr, "resources",
63 f = open(filename, "r")
68 def applyRSpec(self, xml):
69 slice = self.getSlice()
70 filename = os.path.expanduser("~/.sfi/" + slice + ".rspec")
72 f = open(filename, "w")
75 call(["sfi.py", "-u", self.getUser(), "-a", self.getAuthority(),
76 "-r", self.registry, "-s", self.slicemgr, "create",
79 class PlanetLabData(SfaData):
81 SfaData.__init__(self)
82 self.registry = "http://www.planet-lab.org:12345"
83 self.slicemgr = "http://www.planet-lab.org:12346"
86 def refreshRSpec(self):
87 xml = SfaData.getRSpec(self)
88 self.rspec = RSpec(xml)
91 if self.rspec is None:
96 xml = self.rspec.toxml()
97 SfaData.applyRSpec(self, xml)
99 class PLEData(PlanetLabData):
101 PlanetLabData.__init__(self)
102 self.slicemgr = "http://www.planet-lab.eu:12346"
104 class PLJData(PlanetLabData):
106 PlanetLabData.__init__(self)
107 self.slicemgr = "http://www.planet-lab.jp:12346"
109 class ViniData(PlanetLabData):
111 PlanetLabData.__init__(self)
112 self.slicemgr = "http://www.vini-veritas.net:12346"
114 class GpENIData(PlanetLabData):
116 PlanetLabData.__init__(self)
117 self.slicemgr = "http://198.248.241.100:12346"
119 class OpenCirrusData(SfaData):
121 SfaData.__init__(self)
122 self.registry = "http://198.55.37.29:12345"
123 self.slicemgr = "http://198.55.37.29:12346"
125 def refreshRSpec(self):
126 xml = SfaData.getRSpec(self)
130 if self.rspec is None:
134 def applyRSpec(self):
136 SfaData.applyRSpec(self, xml)