review and clean up the speaks_for mess
[sfa.git] / sfa / methods / Shutdown.py
index cd36532..f6f1841 100644 (file)
@@ -1,8 +1,6 @@
-from sfa.util.faults import *
-from sfa.util.namespace import *
+from sfa.storage.parameter import Parameter
+from sfa.trust.credential import Credential
 from sfa.util.method import Method
-from sfa.util.parameter import Parameter
-
 
 class Shutdown(Method):
     """
@@ -12,28 +10,20 @@ class Shutdown(Method):
     @param slice_urn (string) URN of slice to renew
     @param credentials ([string]) of credentials    
     """
-    interfaces = ['geni_am']
+    interfaces = ['aggregate', 'slicemgr']
     accepts = [
         Parameter(str, "Slice URN"),
-        Parameter(type([str]), "List of credentials"),
+        Parameter(type([dict]), "Credentials"),
         ]
     returns = Parameter(bool, "Success or Failure")
 
-    def call(self, slice_xrn, creds):
-        hrn, type = urn_to_hrn(slice_xrn)
-
-        self.api.logger.info("interface: %s\ttarget-hrn: %s\tcaller-creds: %s\tmethod-name: %s"%(self.api.interface, hrn, creds, self.name))
-
-        # Find the valid credentials
-        ValidCreds = self.api.auth.checkCredentials(creds, 'shutdown', hrn)
-
-        manager_base = 'sfa.managers'
+    def call(self, xrn, creds):
 
-        if self.api.interface in ['geni_am']:
-            mgr_type = self.api.config.SFA_GENI_AGGREGATE_TYPE
-            manager_module = manager_base + ".geni_am_%s" % mgr_type
-            manager = __import__(manager_module, fromlist=[manager_base])
-            return manager.Shutdown(self.api, slice_xrn, ValidCreds)
+        valid_creds = self.api.auth.checkCredentials(creds, 'stopslice', xrn,
+                                                     check_sliver_callback = self.api.driver.check_sliver_credentials)
+        #log the call
+        origin_hrn = Credential(cred=valid_creds[0]).get_gid_caller().get_hrn()
+        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, xrn, self.name))
 
-        return ''
+        return self.api.manager.Shutdown(self.api, xrn, creds)