add slice id to geniticket; create geni slices as delegated by default
[sfa.git] / plc / plc.py
index c44acf7..a9391e7 100644 (file)
@@ -1,9 +1,10 @@
 ##
 # Geni PLC Wrapper
 #
-# This wrapper implements the Geni Registry and Slice Interfaces.
+# This wrapper implements the Geni Registry and Slice Interfaces on PLC.
 #
-# There are several items that need to be done before starting the registry.
+# There are several items that need to be done before starting the wrapper
+# server.
 #
 # 1) Update util/config.py to match the parameters of your PLC installation.
 #
@@ -57,7 +58,7 @@ def geni_fields_to_pl_fields(type, hrn, geni_fields, pl_fields):
 
     elif type == "slice":
         if not "instantiation" in pl_fields:
-            pl_fields["instantiation"] = "plc-instantiated"
+            pl_fields["instantiation"] = "delegated"  # "plc-instantiated"
         if not "name" in pl_fields:
             pl_fields["name"] = hrn_to_pl_slicename(hrn)
         if not "max_nodes" in pl_fields:
@@ -88,10 +89,7 @@ def geni_fields_to_pl_fields(type, hrn, geni_fields, pl_fields):
             pl_fields["is_public"] = True
 
 ##
-# Registry is a GeniServer that serves registry requests. It also serves
-# component and slice operations that are implemented on the registry
-# due to SFA engineering decisions
-#
+# Registry is a GeniServer that serves registry and slice operations at PLC.
 
 class Registry(GeniServer):
     ##
@@ -243,6 +241,7 @@ class Registry(GeniServer):
         # for example, the top level authority records which are
         # authorities, but not PL "sites"
         if pointer == -1:
+            record.set_pl_info({})
             return
 
         if (type == "sa") or (type == "ma"):
@@ -543,7 +542,17 @@ class Registry(GeniServer):
             self.shell.UpdateSlice(self.pl_auth, pointer, record.get_pl_info())
 
         elif type == "user":
-            self.shell.UpdatePerson(self.pl_auth, pointer, record.get_pl_info())
+            # SMBAKER: UpdatePerson only allows a limited set of fields to be
+            #    updated. Ideally we should have a more generic way of doing
+            #    this. I copied the field names from UpdatePerson.py...
+            update_fields = {}
+            all_fields = record.get_pl_info()
+            for key in all_fields.keys():
+                if key in ['first_name', 'last_name', 'title', 'email',
+                           'password', 'phone', 'url', 'bio', 'accepted_aup',\r
+                           'enabled']:
+                    update_fields[key] = all_fields[key]
+            self.shell.UpdatePerson(self.pl_auth, pointer, update_fields)
 
         elif type == "node":
             self.shell.UpdateNode(self.pl_auth, pointer, record.get_pl_info())
@@ -829,6 +838,9 @@ class Registry(GeniServer):
 
     # ------------------------------------------------------------------------
     # Slice Interface
+    #
+    # All but get_ticket are currently stubbed out
+    #
 
     ##
     # Convert a PLC record into the slice information that will be stored in
@@ -858,6 +870,7 @@ class Registry(GeniServer):
         attributes['instantiation'] = record.pl_info['instantiation']
         attributes['vref'] = 'default'
         attributes['timestamp'] = time.time()
+        attributes['slice_id'] = record.pl_info['slice_id']
 
         rspec = {}
 
@@ -884,8 +897,8 @@ class Registry(GeniServer):
     ##
     # GENI API: get_ticket
     #
-    # Retrieve a ticket. This operation is currently implemented on the
-    # registry (see SFA, engineering decisions), and is not implemented on
+    # Retrieve a ticket. This operation is currently implemented on PLC
+    # only (see SFA, engineering decisions); it is not implemented on
     # components.
     #
     # The ticket is filled in with information from the PLC database. This
@@ -946,6 +959,7 @@ class Registry(GeniServer):
     def stop_slice(self, cred_str):
         self.decode_authentication(cred_str, "stopslice")
         slicename = hrn_to_pl_slicename(self.object_gid.get_hrn())
+        # TODO: stop the slice
 
     ##
     # GENI API: start_slice