Changed Rspec --> RSpec throughout.
[sfa.git] / sfa / rspecs / aggregates / rspec_manager_max.py
index 6d54f7d..e4ff71a 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-from sfa.util.rspec import Rspec
+from sfa.util.rspec import RSpec
 import sys
 import pdb
 from sfa.util.misc import *
@@ -27,7 +27,7 @@ class GeniOutOfResource(GeniFault):
         faultString = "Interface " + interface + " not available"
         GeniFault.__init__(self, 100, faultString, '')
 
-class GeniNoPairRspec(GeniFault):
+class GeniNoPairRSpec(GeniFault):
     def __init__(self, interface, interface2):
         faultString = "Interface " + interface + " should be paired with " + interface2
         GeniFault.__init__(self, 100, faultString, '')
@@ -36,7 +36,7 @@ class GeniNoPairRspec(GeniFault):
 # i -> node,i_peer
 
 def get_interface_map():
-    r = Rspec()
+    r = RSpec()
     r.parseFile(SFA_MAX_DEFAULT_RSPEC)
     rspec = r.toDict()
     capacity = rspec['rspec']['capacity']
@@ -121,16 +121,20 @@ def collapse_alloc_dict(d):
     return ret
 
 
-def alloc_links(api, links_to_add, links_to_drop, foo):
-    #for l in links_to_add:
-        #(node1,ip1,node2,ip2) = l
-        #api.plshell.AddSliceTag(api.plauth, [slicename], ['node_ids'])
+def alloc_links(api, hrn, links_to_add, links_to_drop):
+    slicename=hrn_to_pl_slicename(hrn)
+    for (iface,ip) in links_to_add:
+        node = topology[iface][0][0]
+        try:
+            api.plshell.AddSliceTag(api.plauth, slicename, "ip_addresses", ip, node)
+            api.plshell.AddSliceTag(api.plauth, slicename, "vsys", "getvlan", node)
+        except Exception: 
+            # Probably a duplicate tag. XXX July 21
+            pass
     return True
 
 def alloc_nodes(api,hrn, requested_ifs):
-    
     requested_nodes = if_endpoints(requested_ifs)
-
     create_slice_max_aggregate(api, hrn, requested_nodes)
 
 # Taken from slices.py
@@ -263,7 +267,7 @@ def create_slice(api, hrn, rspec_xml):
 
     # Check if everything in rspec is either allocated by hrn
     # or not allocated at all.
-    r = Rspec()
+    r = RSpec()
     r.parseString(rspec_xml)
     rspec = r.toDict()
 
@@ -286,7 +290,7 @@ def create_slice(api, hrn, rspec_xml):
         if (a not in current_hrn_interfaces and a in current_interfaces):
             raise GeniOutOfResource(a)
         if (topology[a][1] not in requested_interfaces):
-            raise GeniNoPairRspec(a,topology[a][1])
+            raise GeniNoPairRSpec(a,topology[a][1])
     # Request OK
 
     # Allocations to delete
@@ -312,16 +316,16 @@ def rspec_to_allocations(rspec):
         for l in ifspecs:
             ifs.extend([(l['name'].replace('tns:',''),l['ip'])])
     except KeyError:
-        # Bad Rspec
+        # Bad RSpec
         pass
     return ifs
 
 def main():
     t = get_interface_map()
-    r = Rspec()
+    r = RSpec()
     rspec_xml = open(sys.argv[1]).read()
     #get_rspec(None,'foo')
-    create_slice(None, "foo", rspec_xml)
+    create_slice(None, "plc.princeton.sap0", rspec_xml)
     
 if __name__ == "__main__":
     main()