using the correct root_ssh_key to reach the node
[sfa.git] / sfa / methods / redeem_ticket.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 redeem_ticket(Method):
9     """
10     Reset the specified slice      
11
12     @param cred credential string specifying the rights of the caller
13     @param ticket 
14     @return 1 is successful, faults otherwise  
15     """
16
17     interfaces = ['component']
18     
19     accepts = [
20         Parameter(str, "Credential string representation of SFA credential"),
21         Parameter(str, "Ticket  string representation of SFA ticket")
22         ]
23
24     returns = [Parameter(int, "1 if successful")]
25     
26     def call(self, cred, ticket):
27         self.api.auth.check(cred, 'redeemticket')
28         self.api.auth.check_ticket(ticket)
29
30         # send the call to the right manager
31         manager_base = 'sfa.managers'
32         mgr_type = self.api.config.SFA_CM_TYPE
33         manager_module = manager_base + ".component_manager_%s" % mgr_type
34         manager = __import__(manager_module, fromlist=[manager_base])
35         manager.redeem_ticket(self.api, ticket) 
36         return 1