4 from sfa.util.faults import *
5 from sfa.util.namespace import *
6 from sfa.util.method import Method
7 from sfa.util.parameter import Parameter, Mixed
8 from sfa.util.debug import log
9 from sfa.trust.credential import Credential
13 Remove an object from the registry. If the object represents a PLC object,
14 then the PLC records will also be removed.
16 @param cred credential string
17 @param type record type
18 @param xrn human readable name of record to remove (hrn or urn)
20 @return 1 if successful, faults otherwise
23 interfaces = ['registry']
26 Parameter(str, "Credential string"),
27 Parameter(str, "Record type"),
28 Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
29 Mixed(Parameter(str, "Human readable name of the original caller"),
30 Parameter(None, "Origin hrn not specified"))
33 returns = Parameter(int, "1 if successful")
35 def call(self, cred, type, xrn, origin_hrn=None):
36 user_cred = Credential(string=cred)
40 hrn = urn_to_hrn(xrn)[0]
42 hrn, type = urn_to_hrn(xrn)
46 origin_hrn = user_cred.get_gid_caller().get_hrn()
47 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
50 self.api.auth.check(cred, "remove")
51 self.api.auth.verify_object_permission(hrn)
53 # send the call to the right manager
54 manager_base = 'sfa.managers'
55 mgr_type = self.api.config.SFA_REGISTRY_TYPE
56 manager_module = manager_base + ".registry_manager_%s" % mgr_type
57 manager = __import__(manager_module, fromlist=[manager_base])
58 return manager.remove(self.api, xrn, type, origin_hrn)