Verify request against capacity
[sfa.git] / sfa / rspecs / aggregates / rspec_manager_vini.py
index ab82c13..70131d7 100644 (file)
@@ -134,51 +134,20 @@ def create_slice_vini_aggregate(api, hrn, nodes):
     return 1
 
 def get_rspec(api, hrn):
-    rspec = ViniRspec()  
-    topo = Topology(api)  
-
-    rspec.updateCapacity(topo)
-    
+    topo = Topology(api)      
     if (hrn):
         slicename = hrn_to_pl_slicename(hrn)
         slice = get_slice(api, slicename)
         if slice:
             slice.hrn = hrn
             topo.nodeTopoFromSliceTags(slice)
-            rspec.updateRequest(slice, topo)
         else:
             # call the default sfa.plc.nodes.get_rspec() method
             return Nodes(api).get_rspec(hrn)     
 
-    return rspec.toxml()
+    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'
@@ -197,13 +166,13 @@ def create_slice(api, hrn, xml):
     else:
         raise PermissionError("%s not in VINI whitelist" % hrn)
         
-    rspec = ViniRspec(xml)
+    rspec = Rspec(xml)
     topo = Topology(api)
     
     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 = []