2 from sfa.trust.certificate import Keypair, convert_public_key
3 from sfa.trust.gid import *
4 from sfa.util.faults import *
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7 from sfa.util.record import SfaRecord
8 from sfa.trust.auth import Auth
9 from sfa.trust.gid import create_uuid
10 from sfa.trust.credential import Credential
12 class Register(Method):
14 Register an object with the registry. In addition to being stored in the
15 SFA database, the appropriate records will also be created in the
18 @param cred credential string
19 @param record_dict dictionary containing record fields
21 @return gid string representation
24 interfaces = ['registry']
27 Parameter(dict, "Record dictionary containing record fields"),
28 Mixed(Parameter(str, "Credential string"),
29 Parameter(type([str]), "List of credentials")),
32 returns = Parameter(int, "String representation of gid object")
34 def call(self, record, creds):
36 valid_creds = self.api.auth.checkCredentials(creds, 'register')
39 hrn = record.get('hrn', '')
40 self.api.auth.verify_object_permission(hrn)
43 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
44 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
46 manager = self.api.get_interface_manager()
48 return manager.register(self.api, record)