5 from sfa.util.faults 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 Update an object in the registry. Currently, this only updates the
14 PLC information associated with the record. The SFA fields (name, type,
17 @param cred credential string specifying rights of the caller
18 @param record a record dictionary to be updated
20 @return 1 if successful, faults otherwise
23 interfaces = ['registry']
26 Parameter(str, "Credential string"),
27 Parameter(dict, "Record dictionary to be updated"),
28 Mixed(Parameter(str, "Human readable name of the original caller"),
29 Parameter(None, "Origin hrn not specified"))
32 returns = Parameter(int, "1 if successful")
34 def call(self, cred, record_dict, origin_hrn=None):
35 user_cred = Credential(string=cred)
39 origin_hrn = user_cred.get_gid_caller().get_hrn()
40 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, None, self.name))
43 self.api.auth.check(cred, "update")
45 # send the call to the right manager
46 manager_base = 'sfa.managers'
47 mgr_type = self.api.config.SFA_REGISTRY_TYPE
48 manager_module = manager_base + ".registry_manager_%s" % mgr_type
49 manager = __import__(manager_module, fromlist=[manager_base])
50 return manager.update(self.api, record_dict)