renamed create_slice into CreateSliver on the managers side
[sfa.git] / sfa / managers / aggregate_manager_openflow.py
index a745b6e..7a965dc 100755 (executable)
@@ -1,18 +1,20 @@
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.rspec import RSpec
-from sfa.server.registry import Registries
-from sfa.util.config import Config
-from sfa.plc.nodes import *
 import sys
 
+import socket
+import struct
+
 #The following is not essential
 #from soaplib.wsgi_soap import SimpleWSGISoapApp
 #from soaplib.serializers.primitive import *
 #from soaplib.serializers.clazz import *
 
-import socket
-import struct
+from sfa.util.faults import *
+from sfa.util.xrn import urn_to_hrn
+from sfa.util.rspec import RSpec
+from sfa.server.registry import Registries
+from sfa.util.config import Config
+from sfa.plc.nodes import *
+from sfa.util.callids import Callids
 
 # Message IDs for all the SFA light calls
 # This will be used by the aggrMgr controller
@@ -89,24 +91,31 @@ def msg_aggrMgr(cred, hrn, msg_id):
         print "IO error"
     return 0
 
-def start_slice(cred, hrn):
+def start_slice(cred, xrn):
+    hrn = urn_to_hrn(xrn)[0]
     if DEBUG: print "Received start_slice call"
     return msg_aggrMgr(SFA_START_SLICE)
 
-def stop_slice(cred, hrn):
+def stop_slice(cred, xrn):
+    hrn = urn_to_hrn(xrn)[0]
     if DEBUG: print "Received stop_slice call"
     return msg_aggrMgr(SFA_STOP_SLICE)
 
-def delete_slice(cred, hrn):
+def delete_slice(cred, xrn):
+    hrn = urn_to_hrn(xrn)[0]
     if DEBUG: print "Received delete_slice call"
     return msg_aggrMgr(SFA_DELETE_SLICE)
 
-def reset_slices(cred, hrn):
+def reset_slices(cred, xrn):
+    hrn = urn_to_hrn(xrn)[0]
     if DEBUG: print "Received reset_slices call"
     return msg_aggrMgr(SFA_RESET_SLICES)
 
-def create_slice(cred, hrn, rspec):
-    if DEBUG: print "Received create_slice call"
+def CreateSliver(cred, xrn, rspec, call_id):
+    if Callids().already_handled(call_id): return False
+
+    hrn = urn_to_hrn(xrn)[0]
+    if DEBUG: print "Received CreateSliver call"
     slice_id = generate_slide_id(cred, hrn)
 
     msg = struct.pack('> B%ds%ds' % (len(slice_id)+1, len(rspec)), SFA_CREATE_SLICE, slice_id, rspec)
@@ -126,8 +135,10 @@ def create_slice(cred, hrn, rspec):
         print "IO error"
     return 0
 
-def get_rspec(cred, hrn=None):
-    if DEBUG: print "Received get_rspec call"
+# Thierry : this would need to handle call_id like the other AMs but is outdated...
+def ListResources(cred, xrn=None):
+    hrn = urn_to_hrn(xrn)[0]
+    if DEBUG: print "Received ListResources call"
     slice_id = generate_slide_id(cred, hrn)
 
     msg = struct.pack('> B%ds' % len(slice_id), SFA_GET_RESOURCES, slice_id)
@@ -160,7 +171,7 @@ def main():
     r = RSpec()
     r.parseFile(sys.argv[1])
     rspec = r.toDict()
-    create_slice(None,'plc',rspec)
+    CreateSliver(None,'plc',rspec,'call-id-plc')
     
 if __name__ == "__main__":
     main()