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
11 from sfa.trust.credential import Credential
15 Remove an object from the registry. If the object represents a PLC object,
16 then the PLC records will also be removed.
18 @param cred credential string
19 @param type record type
20 @param hrn human readable name of record to remove
22 @return 1 if successful, faults otherwise
25 interfaces = ['registry']
28 Parameter(str, "Credential string"),
29 Parameter(str, "Record type"),
30 Parameter(str, "Human readable name (hrn) of record to be removed")
33 returns = Parameter(int, "1 if successful")
35 def call(self, cred, type, hrn, caller_cred=None):
36 self.api.auth.check(cred, "remove")
41 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), hrn, self.name))
42 self.api.auth.verify_object_permission(hrn)
45 if type not in ['all', '*']:
47 records = table.find(filter)
49 raise RecordNotFound(hrn)
54 persons = self.api.plshell.GetPersons(self.api.plauth, record['pointer'])
55 # only delete this person if he has site ids. if he doesnt, it probably means
56 # he was just removed from a site, not actually deleted
57 if persons and persons[0]['site_ids']:
58 self.api.plshell.DeletePerson(self.api.plauth, record['pointer'])
60 if self.api.plshell.GetSlices(self.api.plauth, record['pointer']):
61 self.api.plshell.DeleteSlice(self.api.plauth, record['pointer'])
63 if self.api.plshell.GetNodes(self.api.plauth, record['pointer']):
64 self.api.plshell.DeleteNode(self.api.plauth, record['pointer'])
65 elif type == "authority":
66 if self.api.plshell.GetSites(self.api.plauth, record['pointer']):
67 self.api.plshell.DeleteSite(self.api.plauth, record['pointer'])
69 raise UnknownGeniType(type)