1 from sfa.util.xrn import urn_to_hrn
2 from sfa.util.method import Method
3 from sfa.util.sfatablesRuntime import run_sfatables
5 from sfa.trust.credential import Credential
7 from sfa.storage.parameter import Parameter, Mixed
9 class GetTicket(Method):
11 Retrieve a ticket. This operation is currently implemented on PLC
12 only (see SFA, engineering decisions); it is not implemented on
15 The ticket is filled in with information from the PLC database. This
16 information includes resources, and attributes such as user keys and
19 @param cred credential string
20 @param name name of the slice to retrieve a ticket for (hrn or urn)
21 @param rspec resource specification dictionary
23 @return the string representation of a ticket object
26 interfaces = ['aggregate', 'slicemgr']
29 Parameter(str, "Human readable name of slice to retrive a ticket for (hrn or urn)"),
30 Mixed(Parameter(str, "Credential string"),
31 Parameter(type([str]), "List of credentials")),
32 Parameter(str, "Resource specification (rspec)"),
33 Parameter(type([]), "List of user information"),
34 Parameter(dict, "Options")
37 returns = Parameter(str, "String representation of a ticket object")
39 def call(self, xrn, creds, rspec, users, options):
40 hrn, type = urn_to_hrn(xrn)
41 # Find the valid credentials
42 valid_creds = self.api.auth.checkCredentials(creds, 'getticket', hrn)
43 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
46 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
48 # filter rspec through sfatables
49 if self.api.interface in ['aggregate']:
50 chain_name = 'OUTGOING'
51 elif self.api.interface in ['slicemgr']:
52 chain_name = 'FORWARD-OUTGOING'
53 rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec)
55 # remove nodes that are not available at this interface from the rspec
56 return self.api.manager.GetTicket(self.api, xrn, creds, rspec, users, options)