4 from sfa.util.faults import *
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7 from sfa.trust.auth import Auth
8 from sfa.util.record import GeniRecord
9 from sfa.util.genitable import GeniTable
10 from sfa.util.debug import log
14 Remove an object from the registry. If the object represents a PLC object,
15 then the PLC records will also be removed.
17 @param cred credential string
18 @param type record type
19 @param hrn human readable name of record to remove
21 @return 1 if successful, faults otherwise
24 interfaces = ['registry']
27 Parameter(str, "Credential string"),
28 Parameter(str, "Record type"),
29 Parameter(str, "Human readable name (hrn) of record to be removed")
32 returns = Parameter(int, "1 if successful")
34 def call(self, cred, type, hrn):
35 self.api.auth.check(cred, "remove")
36 self.api.auth.verify_object_permission(hrn)
39 if type not in ['all', '*']:
41 records = table.find(filter)
43 raise RecordNotFound(hrn)
48 persons = self.api.plshell.GetPersons(self.api.plauth, record['pointer'])
49 # only delete this person if he has site ids. if he doesnt, it probably means
50 # he was just removed from a site, not actually deleted
51 if persons and persons[0]['site_ids']:
52 self.api.plshell.DeletePerson(self.api.plauth, record['pointer'])
54 if self.api.plshell.GetSlices(self.api.plauth, record['pointer']):
55 self.api.plshell.DeleteSlice(self.api.plauth, record['pointer'])
57 if self.api.plshell.GetNodes(self.api.plauth, record['pointer']):
58 self.api.plshell.DeleteNode(self.api.plauth, record['pointer'])
59 elif type == "authority":
60 if self.api.plshell.GetSites(self.api.plauth, record['pointer']):
61 self.api.plshell.DeleteSite(self.api.plauth, record['pointer'])
63 raise UnknownGeniType(type)