namespace module is gone, plxrn provides PL-specific translations
[sfa.git] / sfa / methods / Start.py
1 ### $Id: stop_slice.py 17732 2010-04-19 21:10:45Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/stop_slice.py $
3
4 from sfa.util.faults import *
5 from sfa.util.xrn import urn_to_hrn
6 from sfa.util.method import Method
7 from sfa.util.parameter import Parameter, Mixed
8 from sfa.trust.auth import Auth
9 from sfa.trust.credential import Credential
10
11 class Start(Method):
12     """
13     Start the specified slice      
14
15     @param xrn human readable name of slice to instantiate (hrn or urn)
16     @param cred credential string specifying the rights of the caller
17     @return 1 is successful, faults otherwise  
18     """
19
20     interfaces = ['aggregate', 'slicemgr', 'component']
21     
22     accepts = [
23         Parameter(str, "Human readable name of slice to start (hrn or urn)"),
24         Mixed(Parameter(str, "Credential string"),
25               Parameter(type([str]), "List of credentials")),
26         ]
27
28     returns = Parameter(int, "1 if successful")
29     
30     def call(self, xrn, creds):
31         hrn, type = urn_to_hrn(xrn)
32         valid_creds = self.api.auth.checkCredentials(creds, 'startslice', hrn)
33
34         #log the call
35         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
36         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
37
38         manager = self.api.get_interface_manager() 
39         manager.start_slice(self.api, xrn, creds)
40  
41         return 1