merged namespace
[sfa.git] / sfa / methods / RedeemTicket.py
1 ### $Id: reset_slice.py 15428 2009-10-23 15:28:03Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfacomponent/methods/reset_slice.py $
3 import xmlrpclib
4 from sfa.util.faults import *
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7
8 class RedeemTicket(Method):
9     """
10
11     @param cred credential string specifying the rights of the caller
12     @param ticket 
13     @return 1 is successful, faults otherwise  
14     """
15
16     interfaces = ['component']
17     
18     accepts = [
19         Parameter(str, "Ticket  string representation of SFA ticket"),
20         Mixed(Parameter(str, "Credential string"),
21               Parameter(type([str]), "List of credentials")),
22         ]
23
24     returns = [Parameter(int, "1 if successful")]
25     
26     def call(self, ticket, creds):
27         valid_creds = self.api.auth.checkCredentials(cred, 'redeemticket')
28         self.api.auth.check_ticket(ticket)
29
30         
31         # send the call to the right manager
32         manager = self.api.get_interface_manager()
33         manager.redeem_ticket(self.api, ticket) 
34         return 1