1 from sfa.util.method import Method
2 from sfa.util.sfalogging import logger
4 from sfa.trust.credential import Credential
6 from sfa.storage.parameter import Parameter, Mixed
9 class Register(Method):
11 Register an object with the registry. In addition to being stored in the
12 SFA database, the appropriate records will also be created in the
15 @param cred credential string
16 @param record_dict dictionary containing record fields
18 @return gid string representation
21 interfaces = ['registry']
24 Parameter(dict, "Record dictionary containing record fields"),
25 Mixed(Parameter(str, "Credential string"),
26 Parameter(type([str]), "List of credentials")),
29 returns = Parameter(int, "String representation of gid object")
31 def call(self, record, creds):
33 valid_creds = self.api.auth.checkCredentials(creds, 'register')
36 hrn = record.get('hrn', '')
37 self.api.auth.verify_object_permission(hrn)
40 origin_hrn = Credential(
41 string=valid_creds[0]).get_gid_caller().get_hrn()
42 logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s" %
43 (self.api.interface, origin_hrn, hrn, self.name))
45 return self.api.manager.Register(self.api, record)