UpdateSlice needs input in plc format
[sfa.git] / geni / methods / update.py
index 5a0bfa6..e9866e3 100644 (file)
@@ -12,12 +12,6 @@ class update(Method):
     PLC information associated with the record. The Geni fields (name, type,
     GID) are fixed.
     
-    The record is expected to have the pl_info field filled in with the data
-    that should be updated.
-    
-    TODO: The geni_info member of the record should be parsed and the pl_info
-    adjusted as necessary (add/remove users from a slice, etc)
-    
     @param cred credential string specifying rights of the caller
     @param record a record dictionary to be updated
 
@@ -34,7 +28,7 @@ class update(Method):
     returns = Parameter(int, "1 if successful")
     
     def call(self, cred, record_dict):
-        self.api.auth.decode_authentication(cred, "update")
+        self.api.auth.check(cred, "update")
         record = GeniRecord(dict = record_dict)
         type = record.get_type()
         self.api.auth.verify_object_permission(record.get_name())
@@ -59,18 +53,20 @@ class update(Method):
 
         # update the PLC information that was specified with the record
 
-        if (type == "sa") or (type == "ma"):
-            self.api.plshell.UpdateSite(self.api.plauth, pointer, record.get_pl_info())
+        if (type == "authority"):
+            self.api.plshell.UpdateSite(self.api.plauth, pointer, record)
 
         elif type == "slice":
-            self.api.plshell.UpdateSlice(self.api.plauth, pointer, record.get_pl_info())
+            hrn=record.get_name()
+            pl_record=self.api.geni_fields_to_pl_fields(type, hrn, record)
+            self.api.plshell.UpdateSlice(self.api.plauth, pointer, pl_record)
 
         elif type == "user":
             # 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()
+            all_fields = record
             for key in all_fields.keys():
                 if key in ['first_name', 'last_name', 'title', 'email',
                            'password', 'phone', 'url', 'bio', 'accepted_aup',
@@ -78,13 +74,13 @@ class update(Method):
                     update_fields[key] = all_fields[key]
             self.api.plshell.UpdatePerson(self.api.plauth, pointer, update_fields)
 
-         elif type == "node":
-            self.api.plshell.UpdateNode(self.api.plauth, pointer, record.get_pl_info())
+        elif type == "node":
+            self.api.plshell.UpdateNode(self.api.plauth, pointer, record)
 
         else:
             raise UnknownGeniType(type)
 
-        # update membership for researchers, pis, owners, operators^M
+        # update membership for researchers, pis, owners, operators
         self.api.update_membership(existing_record, record)
 
-        return 1    
+        return 1