X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Frspecs%2Faggregates%2Frspec_manager_vini.py;h=2875a4047de3137c8361e00400b33739d296f175;hb=73b163a7ea35209e0675a7c7cef367946928a96f;hp=e519970808e2a389542fb67890ed131d816ad71f;hpb=cbfcd01963fd69149937551f9d225ec825554384;p=sfa.git diff --git a/sfa/rspecs/aggregates/rspec_manager_vini.py b/sfa/rspecs/aggregates/rspec_manager_vini.py index e5199708..2875a404 100644 --- a/sfa/rspecs/aggregates/rspec_manager_vini.py +++ b/sfa/rspecs/aggregates/rspec_manager_vini.py @@ -1,6 +1,6 @@ from sfa.util.faults import * from sfa.util.misc import * -from sfa.util.rspec import Rspec +from sfa.util.rspec import RSpec from sfa.server.registry import Registries from sfa.plc.nodes import * from sfa.rspecs.aggregates.vini.utils import * @@ -148,32 +148,6 @@ def get_rspec(api, hrn): return topo.toxml(hrn) -""" -Check the requested topology against the available topology and capacity -""" -def check_request(hrn, rspec, nodes, sites, sitelinks, maxbw): - linkspecs = rspec['Rspec']['Request'][0]['NetSpec'][0]['LinkSpec'] - if linkspecs: - for l in linkspecs: - n1 = Node.lookup(l['endpoint'][0]) - n2 = Node.lookup(l['endpoint'][1]) - bw = l['bw'][0] - reqbps = get_tc_rate(bw) - maxbps = get_tc_rate(maxbw) - - if reqbps <= 0: - raise GeniInvalidArgument(bw, "BW") - if reqbps > maxbps: - raise PermissionError(" %s requested %s but max BW is %s" % - (hrn, bw, maxbw)) - - if adjacent_nodes(n1, n2, sites, sitelinks): - availbps = get_avail_bps(n1, n2, sites, sitelinks) - if availbps < reqbps: - raise PermissionError("%s: capacity exceeded" % hrn) - else: - raise PermissionError("%s: nodes %s and %s not adjacent" - % (hrn, n1.tag, n2.tag)) """ Hook called via 'sfi.py create' @@ -192,13 +166,13 @@ def create_slice(api, hrn, xml): else: raise PermissionError("%s not in VINI whitelist" % hrn) - rspec = Rspec(xml) + rspec = RSpec(xml) topo = Topology(api) - topo.nodeTopoFromRspec(rspec) + topo.nodeTopoFromRSpec(rspec) # Check request against current allocations - #check_request(hrn, rspec, nodes, sites, sitelinks, maxbw) + topo.verifyNodeTopo(hrn, topo, maxbw) nodes = topo.nodesInTopo() hostnames = [] @@ -213,12 +187,20 @@ def create_slice(api, hrn, xml): return True +""" +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 = RSpec() r.parseFile(sys.argv[1]) rspec = r.toDict() create_slice(None,'plc',rspec) - + if __name__ == "__main__": main()