1 from geni.util.faults import *
2 from geni.util.excep import *
3 from geni.util.method import Method
4 from geni.util.parameter import Parameter, Mixed
5 from geni.util.auth import Auth
6 from geni.util.record import GeniRecord
7 from geni.util.debug import log
11 Remove an object from the registry. If the object represents a PLC object,
12 then the PLC records will also be removed.
14 @param cred credential string
15 @param type record type
16 @param hrn human readable name of record to remove
18 @return 1 if successful, faults otherwise
21 interfaces = ['registry']
24 Parameter(str, "Credential string"),
25 Parameter(str, "Record type")
26 Parameter(str, "Human readable name (hrn) of record to be removed")
29 returns = Parameter(int, "1 if successful")
31 def call(self, cred, type, hrn):
32 self.api.auth.decode_authentication(cred, "remove")
33 self.api.auth.verify_object_permission(hrn)
34 auth_name = self.api.auth.get_authority(hrn)
35 table = self.api.auth.get_auth_table(auth_name)
36 record_list = table.resolve(type, hrn)
38 raise RecordNotFound(hrn)
39 record = record_list[0]
43 self.api.plshell.DeletePerson(self.api.plauth, record.get_pointer())
45 self.api.plshell.DeleteSlice(self.api.plauth, record.get_pointer())
47 self.api.plshell.DeleteNode(self.api.plauth, record.get_pointer())
48 elif (type == "sa") or (type == "ma"):
50 other_rec = table.resolve("ma", record.get_name())
52 other_rec = table.resolve("sa", record.get_name())
55 # sa and ma both map to a site, so if we are deleting one
56 # but the other still exists, then do not delete the site
57 print >> log, "not removing site", record.get_name(), "because either sa or ma still exists"
60 print >> log, "removing site", record.get_name()
61 self.api.plshell.DeleteSite(self.api.plauth, record.get_pointer())
63 raise UnknownGeniType(type)