fixed up the names of new site names/slices to be more PLC compatible
[sfa.git] / sfa / methods / remove.py
index 673047e..3419603 100644 (file)
@@ -2,20 +2,21 @@
 ### $URL$
 
 from sfa.util.faults import *
+from sfa.util.namespace import *
 from sfa.util.method import Method
 from sfa.util.parameter import Parameter, Mixed
-from sfa.trust.auth import Auth
-from sfa.util.record import GeniRecord
-from sfa.util.debug import log
+from sfa.methods.Remove import Remove
 
-class remove(Method):
+class remove(Remove):
     """
+    Deprecated. Use Remove instead.
+
     Remove an object from the registry. If the object represents a PLC object,
     then the PLC records will also be removed.
     
     @param cred credential string
     @param type record type
-    @param hrn human readable name of record to remove
+    @param xrn human readable name of record to remove (hrn or urn)
 
     @return 1 if successful, faults otherwise 
     """
@@ -25,44 +26,13 @@ class remove(Method):
     accepts = [
         Parameter(str, "Credential string"),
         Parameter(str, "Record type"),
-        Parameter(str, "Human readable name (hrn) of record to be removed")
+        Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
+        Mixed(Parameter(str, "Human readable name of the original caller"),
+              Parameter(None, "Origin hrn not specified"))
         ]
 
     returns = Parameter(int, "1 if successful")
     
-    def call(self, cred, type, hrn):
-        self.api.auth.check(cred, "remove")
-        self.api.auth.verify_object_permission(hrn)
-        auth_name = self.api.auth.get_authority(hrn)
-        table = self.api.auth.get_auth_table(auth_name)
-        record_list = table.resolve(type, hrn)
-        if not record_list:
-            raise RecordNotFound(hrn)
-        record = record_list[0]
+    def call(self, cred, type, xrn, origin_hrn=None):
         
-        type = record['type']
-        # TODO: sa, ma
-        if type == "user":
-         if self.api.plshell.GetPersons(self.api.plauth, record.get_pointer()):
-            self.api.plshell.DeletePerson(self.api.plauth, record.get_pointer())
-        elif type == "slice":
-            self.api.plshell.DeleteSlice(self.api.plauth, record.get_pointer())
-        elif type == "node":
-            self.api.plshell.DeleteNode(self.api.plauth, record.get_pointer())
-        elif (type in ['authority', 'sa', 'ma']):
-            other_rec = table.resolve(type, record.get_name())
-                
-            if other_rec:
-                # sa and ma both map to a site, so if we are deleting one
-                # but the other still exists, then do not delete the site
-                print >> log, "not removing site", record.get_name(), "because either sa or ma still exists"
-                pass
-            else:
-                print >> log, "removing site", record.get_name()
-                self.api.plshell.DeleteSite(self.api.plauth, record.get_pointer())
-        else:
-            raise UnknownGeniType(type)
-
-        table.remove(record)
-
-        return 1
+        return Remove.call(self, xrn, cred, type)