f6f1841f9095ba9388361bd59efd2bd52ae1feef
[sfa.git] / sfa / methods / Shutdown.py
1 from sfa.storage.parameter import Parameter
2 from sfa.trust.credential import Credential
3 from sfa.util.method import Method
4
5 class Shutdown(Method):
6     """
7     Perform an emergency shut down of a sliver. This operation is intended for administrative use. 
8     The sliver is shut down but remains available for further forensics.
9
10     @param slice_urn (string) URN of slice to renew
11     @param credentials ([string]) of credentials    
12     """
13     interfaces = ['aggregate', 'slicemgr']
14     accepts = [
15         Parameter(str, "Slice URN"),
16         Parameter(type([dict]), "Credentials"),
17         ]
18     returns = Parameter(bool, "Success or Failure")
19
20     def call(self, xrn, creds):
21
22         valid_creds = self.api.auth.checkCredentials(creds, 'stopslice', xrn,
23                                                      check_sliver_callback = self.api.driver.check_sliver_credentials)
24         #log the call
25         origin_hrn = Credential(cred=valid_creds[0]).get_gid_caller().get_hrn()
26         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, xrn, self.name))
27
28         return self.api.manager.Shutdown(self.api, xrn, creds)
29