group db-related stuff in sfa/storage
[sfa.git] / sfa / methods / reset_slice.py
1 from sfa.util.xrn import urn_to_hrn
2 from sfa.util.method import Method
3
4 from sfa.storage.parameter import Parameter, Mixed
5
6 class reset_slice(Method):
7     """
8     Reset the specified slice      
9
10     @param cred credential string specifying the rights of the caller
11     @param xrn human readable name of slice to instantiate (hrn or urn)
12     @return 1 is successful, faults otherwise  
13     """
14
15     interfaces = ['aggregate', 'slicemgr', 'component']
16     
17     accepts = [
18         Parameter(str, "Credential string"),
19         Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
20         Mixed(Parameter(str, "Human readable name of the original caller"),
21               Parameter(None, "Origin hrn not specified"))
22         ]
23
24     returns = Parameter(int, "1 if successful")
25     
26     def call(self, cred, xrn, origin_hrn=None):
27         hrn, type = urn_to_hrn(xrn)
28         self.api.auth.check(cred, 'resetslice', hrn)
29         self.api.manager.reset_slice (self.api, xrn)
30         return 1