4 from geni.trust.certificate import Keypair
6 from geni.util.faults import *
7 from geni.util.method import Method
8 from geni.util.parameter import Parameter, Mixed
9 from geni.util.auth import Auth
11 class create_gid(Method):
13 Create a new GID. For MAs and SAs that are physically located on the
14 registry, this allows a owner/operator/PI to create a new GID and have it
15 signed by his respective authority.
17 @param cred credential of caller
18 @param name hrn for new GID
19 @param uuid unique identifier for new GID
20 @param pkey_string public-key string (TODO: why is this a string and not a keypair object?)
22 @return the string representation of a GID object
25 interfaces = ['registry']
28 Parameter(str, "Credential string"),
29 Parameter(str, "Human readable name (hrn)"),
30 Mixed(Parameter(str, "Unique identifier for new GID (uuid)"),
31 Parameter(None, "Unique identifier (uuid) not specified")),
32 Parameter(str, "public-key string")
35 returns = Parameter(str, "String represeneation of a GID object")
37 def call(self, cred, hrn, uuid, pubkey_str):
38 self.api.auth.check(cred, "getcredential")
39 self.api.auth.verify_object_belongs_to_me(hrn)
40 self.api.auth.verify_object_permission(hrn)
46 pkey.load_pubkey_from_string(pubkey_str)
47 gid = self.api.auth.hierarchy.create_gid(hrn, uuid, pkey)
49 return gid.save_to_string(save_parents=True)