from sfa.util.faults import *
-from sfa.util.misc import *
-from sfa.util.rspec import RSpec
+from sfa.util.namespace import *
from sfa.server.registry import Registries
from sfa.plc.nodes import *
+from sfa.plc.api import *
from sfa.rspecs.aggregates.vini.utils import *
-from sfa.rspecs.aggregates.vini.rspec import *
import sys
-SFA_VINI_WHITELIST = '/etc/sfa/vini.whitelist'
-
"""
Copied from create_slice_aggregate() in sfa.plc.slices
"""
def create_slice_vini_aggregate(api, hrn, nodes):
- # Get the slice record from geni
+ # Get the slice record
slice = {}
registries = Registries(api)
registry = registries[api.hrn]
return 1
-def get_rspec(api, hrn):
+def get_rspec(api, xrn, origin_hrn):
+ hrn = urn_to_hrn(xrn)[0]
topo = Topology(api)
if (hrn):
slicename = hrn_to_pl_slicename(hrn)
"""
Hook called via 'sfi.py create'
"""
-def create_slice(api, hrn, xml):
- ### Check the whitelist
- ### It consists of lines of the form: <slice hrn> <bw>
- whitelist = {}
- f = open(SFA_VINI_WHITELIST)
- for line in f.readlines():
- (slice, maxbw) = line.split()
- whitelist[slice] = maxbw
-
- if hrn in whitelist:
- maxbw = whitelist[hrn]
- else:
- raise PermissionError("%s not in VINI whitelist" % hrn)
-
- rspec = RSpec(xml)
+def create_slice(api, xrn, xml):
+ hrn = urn_to_hrn(xrn)[0]
topo = Topology(api)
-
- topo.nodeTopoFromRSpec(rspec)
+ topo.nodeTopoFromRSpec(xml)
# Check request against current allocations
- topo.verifyNodeTopo(hrn, topo, maxbw)
+ topo.verifyNodeTopo(hrn, topo)
nodes = topo.nodesInTopo()
hostnames = []
if slice:
topo.updateSliceTags(slice)
+ # print topo.toxml(hrn)
+
return True
"""
return base_context
def main():
- r = RSpec()
- r.parseFile(sys.argv[1])
- rspec = r.toDict()
- create_slice(None,'plc',rspec)
+ api = SfaAPI()
+ #rspec = get_rspec(api, "plc.princeton.iias", None)
+ #print rspec
+ f = open(sys.argv[1])
+ xml = f.read()
+ f.close()
+ create_slice(api, "plc.princeton.iias", xml)
if __name__ == "__main__":
main()