get caller's hrn from the credentials gid_origin_caller object
authorTony Mack <tmack@cs.princeton.edu>
Thu, 31 Dec 2009 00:19:11 +0000 (00:19 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Thu, 31 Dec 2009 00:19:11 +0000 (00:19 +0000)
sfa/managers/aggregate_manager_pl.py
sfa/managers/slice_manager_pl.py
sfa/methods/get_ticket.py

index 9e17a51..3dd860b 100644 (file)
@@ -43,7 +43,7 @@ def create_slice(api, hrn, rspec):
     slices = Slices(api)
     slices.create_slice(hrn, rspec)
 
-def get_ticket(api, slice_hrn, rspec, origin_hrn=None):
+def get_ticket(api, slice_hrn, rspec, gid_origin_caller=None):
     # the the slice record
     registries = Registries(api)
     registry = registries[api.hrn]
index dda726a..78c110a 100644 (file)
@@ -129,7 +129,7 @@ def create_slice(api, hrn, rspec, gid_origin_caller=None):
             traceback.print_exc()
     return 1
 
-def get_ticket(api, slice_hrn, rspec, origin_hrn=None):
+def get_ticket(api, slice_hrn, rspec, gid_origin_caller=None):
     
     # get the netspecs contained within the clients rspec
     client_rspec = RSpec(xml=rspec)
@@ -149,6 +149,7 @@ def get_ticket(api, slice_hrn, rspec, origin_hrn=None):
     # send the rspec to the appropiate aggregate/sm
     aggregates = Aggregates(api)
     credential = api.getCredential()
+    credential.set_gid_origin_caller(gid_origin_caller)
     tickets = {}
     for net_hrn in rspecs:    
         try:
@@ -158,13 +159,13 @@ def get_ticket(api, slice_hrn, rspec, origin_hrn=None):
             if net_hrn in aggregates:
                 try:
                     ticket = aggregates[net_hrn].get_ticket(credential, slice_hrn, \
-                                rspecs[net_hrn], None, origin_hrn)
+                                rspecs[net_hrn], None)
                     tickets[net_hrn] = ticket
                 except:
                     arg_list = [credential,hrn,rspecs[net_hrn]]
                     request_hash = api.key.compute_hash(arg_list)
                     ticket = aggregates[net_hrn].get_ticket(credential, slice_hrn, \
-                                rspecs[net_hrn], request_hash, origin_hrn)
+                                rspecs[net_hrn], request_hash)
                     tickets[net_hrn] = ticket 
             else:
                 # lets forward this rspec to a sm that knows about the network
@@ -180,13 +181,13 @@ def get_ticket(api, slice_hrn, rspec, origin_hrn=None):
                     if network_found:
                         try:
                             ticket = aggregates[aggregate].get_ticket(credential, \
-                                        slice_hrn, rspecs[net_hrn], None, origin_hrn)
+                                        slice_hrn, rspecs[net_hrn], None)
                             tickets[aggregate] = ticket
                         except:
                             arg_list = [credential, hrn, rspecs[net_hrn]]
                             request_hash = api.key.compute_hash(arg_list)
                             aggregates[aggregate].get_ticket(credential, slice_hrn, \
-                                    rspecs[net_hrn], request_hash, origin_hrn)
+                                    rspecs[net_hrn], request_hash)
                             tickets[aggregate] = ticket
         except:
             print >> log, "Error getting ticket for %(slice_hrn)s at aggregate %(net_hrn)s" % \
index 62861e9..62e0d30 100644 (file)
@@ -42,16 +42,17 @@ class get_ticket(Method):
 
     returns = Parameter(str, "String represeneation of a ticket object")
     
-    def call(self, cred, hrn, rspec, request_hash=None, origin_hrn=None):
+    def call(self, cred, hrn, rspec, request_hash=None):
+        user_cred = Credential(string=cred)
+
+        #log the call
+        gid_origin_caller = user_cred.get_gid_origin_caller()
+        origin_hrn = gid_origin_caller.get_hrn()
+        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
+
         self.api.auth.authenticateCred(cred, [cred, hrn, rspec], request_hash)
         self.api.auth.check(cred, "getticket")
        
-       if origin_hrn==None:
-           origin_hrn=Credential(string=cred).get_gid_caller().get_hrn()
-
-       #log the call
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
-   
         # set the right outgoing rules
         manager_base = 'sfa.managers'
         if self.api.interface in ['aggregate']:
@@ -80,7 +81,7 @@ class get_ticket(Method):
         rspec_object = RSpec(xml=rspec)
         rspec_object.filter(tagname='NodeSpec', attribute='name', whitelist=valid_hostnames)
         rspec = rspec_object.toxml() 
-        ticket = manager.get_ticket(self.api, hrn, rspec, origin_hrn)
+        ticket = manager.get_ticket(self.api, hrn, rspec, gid_origin_caller)
         
         return ticket