DeleteSliver supports call_id
[sfa.git] / sfa / methods / DeleteSliver.py
1 from sfa.util.faults import *
2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5 from sfa.trust.auth import Auth
6 from sfa.trust.credential import Credential
7
8 class DeleteSliver(Method):
9     """
10     Remove the slice from all nodes and free the allocated resources        
11
12     @param xrn human readable name of slice to instantiate (hrn or urn)
13     @param cred credential string specifying the rights of the caller
14     @return 1 is successful, faults otherwise  
15     """
16
17     interfaces = ['aggregate', 'slicemgr', 'component']
18     
19     accepts = [
20         Parameter(str, "Human readable name of slice to delete (hrn or urn)"),
21         Mixed(Parameter(str, "Credential string"),
22               Parameter(type([str]), "List of credentials")),
23         Parameter(str, "call_id"),
24         ]
25
26     returns = Parameter(int, "1 if successful")
27     
28     def call(self, xrn, creds, call_id=""):
29         hrn, type = urn_to_hrn(xrn)
30         valid_creds = self.api.auth.checkCredentials(creds, 'deletesliver', hrn)
31
32         #log the call
33         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
34         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
35
36         manager = self.api.get_interface_manager() 
37         manager.DeleteSliver(self.api, xrn, creds, call_id)
38  
39         return 1