removed another bunch of references to geni
[sfa.git] / sfa / methods / update.py
1 ### $Id$
2 ### $URL$
3
4 import time
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
10
11 class update(Method):
12     """
13     Update an object in the registry. Currently, this only updates the
14     PLC information associated with the record. The SFA fields (name, type,
15     GID) are fixed.
16     
17     @param cred credential string specifying rights of the caller
18     @param record a record dictionary to be updated
19
20     @return 1 if successful, faults otherwise 
21     """
22
23     interfaces = ['registry']
24     
25     accepts = [
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"))
30         ]
31
32     returns = Parameter(int, "1 if successful")
33     
34     def call(self, cred, record_dict, origin_hrn=None):
35         user_cred = Credential(string=cred)
36     
37             #log the call
38         if not origin_hrn:
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))
41         
42         # validate the cred
43         self.api.auth.check(cred, "update")
44         
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)
51