need to pass creds to manager modules
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 24 Aug 2012 16:04:18 +0000 (12:04 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 24 Aug 2012 16:04:18 +0000 (12:04 -0400)
sfa/managers/aggregate_manager.py
sfa/managers/slice_manager.py
sfa/methods/Delete.py
sfa/methods/Renew.py
sfa/methods/Shutdown.py
sfa/methods/Status.py

index d947c3f..9ec3775 100644 (file)
@@ -120,7 +120,7 @@ class AggregateManager:
         return self.driver.describe(urns, rspec_version, options)
         
     
-    def Status (self, api, urns, options):
+    def Status (self, api, urns, creds, options):
         call_id = options.get('call_id')
         if Callids().already_handled(call_id): return {}
         return self.driver.status (urns, options=options)
@@ -135,7 +135,7 @@ class AggregateManager:
         if Callids().already_handled(call_id): return ""
         return self.driver.allocate(xrn, creds, rspec_string, options)
  
-    def Provision(self, api, xrns, options):
+    def Provision(self, api, xrns, creds, options):
         """
         Create the sliver[s] (slice) at this aggregate.    
         Verify HRN and initialize the slice record in PLC if necessary.
@@ -144,22 +144,22 @@ class AggregateManager:
         if Callids().already_handled(call_id): return ""
         return self.driver.provision(xrns, creds, options)
     
-    def Delete(self, api, xrns, options):
+    def Delete(self, api, xrns, creds, options):
         call_id = options.get('call_id')
         if Callids().already_handled(call_id): return True
         return self.driver.delete_sliver (xrns, options)
 
-    def Renew(self, api, xrns, expiration_time, options):
+    def Renew(self, api, xrns, creds, expiration_time, options):
         call_id = options.get('call_id')
         if Callids().already_handled(call_id): return True
         return self.driver.renew(xrns, expiration_time, options)
 
-    def PerformOperationalAction(self, api, xrns, action, options={}):
+    def PerformOperationalAction(self, api, xrns, creds, action, options={}):
         call_id = options.get('call_id')
         if Callids().already_handled(call_id): return True
         return self.driver.performOperationalAction(xrns, action, options) 
 
-    def Shutdown(self, api, xrn, options={}):
+    def Shutdown(self, api, xrn, creds, options={}):
         call_id = options.get('call_id')
         if Callids().already_handled(call_id): return True
         return self.driver.shutdown(xrn, options) 
index dcd5e5e..0e758ab 100644 (file)
@@ -519,11 +519,10 @@ class SliceManager:
         threads.get_results()    
         return 1
      
-    def stop_slice(self, api, xrn, creds):
-        hrn, type = urn_to_hrn(xrn)
-    
+    def Shutdown(self, api, xrn, creds, options={}):
+        xrn = Xrn(xrn)  
         # get the callers hrn
-        valid_cred = api.auth.checkCredentials(creds, 'stopslice', hrn)[0]
+        valid_cred = api.auth.checkCredentials(creds, 'stopslice', xrn.hrn)[0]
         caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
     
         # attempt to use delegated credential first
@@ -538,25 +537,7 @@ class SliceManager:
                 continue
             interface = api.aggregates[aggregate]
             server = api.server_proxy(interface, cred)
-            threads.run(server.Stop, xrn, cred)
+            threads.run(server.Shutdown, xrn.urn, cred)
         threads.get_results()    
         return 1
     
-    def reset_slice(self, api, xrn):
-        """
-        Not implemented
-        """
-        return 1
-    
-    def shutdown(self, api, xrn, creds):
-        """
-        Not implemented   
-        """
-        return 1
-    
-    def status(self, api, xrn, creds):
-        """
-        Not implemented 
-        """
-        return 1
-
index 9dfebda..dd6cceb 100644 (file)
@@ -17,8 +17,7 @@ class Delete(Method):
     
     accepts = [
         Parameter([str], "Human readable name of slice to delete (hrn or urn)"),
-        Mixed(Parameter(str, "Credential string"),
-              Parameter(type([str]), "List of credentials")),
+        Parameter(dict), "Credentials")),
         Parameter(dict, "options"),
         ]
 
@@ -31,6 +30,6 @@ class Delete(Method):
         origin_hrn = Credential(string=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, xrns, self.name))
 
-        self.api.manager.Delete(self.api, xrns, options)
+        self.api.manager.Delete(self.api, xrns, creds, options)
  
         return 1 
index ee951c0..5de5380 100644 (file)
@@ -42,5 +42,5 @@ class Renew(Method):
             raise InsufficientRights('Renewsliver: Credential expires before requested expiration time')
         if requested_time > datetime.datetime.utcnow() + datetime.timedelta(days=max_renew_days):
             raise Exception('Cannot renew > %s days from now' % max_renew_days)
-        return self.api.manager.Renew(self.api, urns, expiration_time, options)
+        return self.api.manager.Renew(self.api, urns, creds, expiration_time, options)
     
index 17c6636..d288036 100644 (file)
@@ -13,7 +13,7 @@ class Shutdown(Method):
     interfaces = ['aggregate', 'slicemgr']
     accepts = [
         Parameter(str, "Slice URN"),
-        Parameter(type([str]), "List of credentials"),
+        Parameter(type(dict), "Credentials"),
         ]
     returns = Parameter(bool, "Success or Failure")
 
index 6935d01..951871d 100644 (file)
@@ -12,20 +12,15 @@ class Status(Method):
     """
     interfaces = ['aggregate', 'slicemgr', 'component']
     accepts = [
-        Parameter(str, "Slice URN"),
-        Mixed(Parameter(str, "Credential string"),
-              Parameter(type([str]), "List of credentials")),
+        Parameter([str], "Slice or sliver URNs"),
+        Parameter(dict), "credentials")),
         Parameter(dict, "Options")
         ]
     returns = Parameter(dict, "Status details")
 
-    def call(self, slice_xrn, creds, options):
-        hrn, type = urn_to_hrn(slice_xrn)
-        valid_creds = self.api.auth.checkCredentials(creds, 'sliverstatus', hrn)
+    def call(self, xrns, creds, options):
+        valid_creds = self.api.auth.checkCredentials(creds, 'sliverstatus', xrns)
 
-        self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
-    
-        status = self.api.manager.Status(self.api, hrn, valid_creds, options)
-
-        return status
+        self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, xrns, self.name))
+        return self.api.manager.Status(self.api, xrns, creds, options)