logging and call tracing features
[sfa.git] / sfa / methods / delete_slice.py
1 ### $Id$
2 ### $URL$
3
4 from sfa.util.faults import *
5 from sfa.util.misc import *
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 from sfa.plc.slices import Slices
12
13 class delete_slice(Method):
14     """
15     Remove the slice from all nodes.      
16
17     @param cred credential string specifying the rights of the caller
18     @param hrn human readable name specifying the slice to delete
19     @return 1 if successful, faults otherwise  
20     """
21
22     interfaces = ['aggregate', 'slicemgr']
23     
24     accepts = [
25         Parameter(str, "Credential string"),
26         Parameter(str, "Human readable name of slice to delete"),
27         ]
28
29     returns = Parameter(int, "1 if successful")
30     
31     def call(self, cred, hrn, caller_cred=None):
32        
33         if caller_cred==None:
34            caller_cred=cred
35         #log the call
36         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), hrn, self.name))
37
38         self.api.auth.check(cred, 'deleteslice')
39         slices = Slices(self.api, caller_cred=caller_cred)
40         slices.delete_slice(hrn)
41         return 1