Registries/Aggregates are accessed through api object now
authorTony Mack <tmack@cs.princeton.edu>
Tue, 6 Apr 2010 20:50:13 +0000 (20:50 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 6 Apr 2010 20:50:13 +0000 (20:50 +0000)
sfa/managers/registry_manager_pl.py
sfa/managers/slice_manager_pl.py
sfa/plc/nodes.py
sfa/plc/slices.py

index 7c96927..1af2caf 100644 (file)
@@ -1,6 +1,5 @@
 import types
 import time 
-from sfa.server.registry import Registries
 from sfa.util.prefixTree import prefixTree
 from sfa.util.record import SfaRecord
 from sfa.util.table import SfaTable
@@ -76,8 +75,7 @@ def resolve(api, xrns, type=None, origin_hrn=None, full=True):
     # create a dict whre key is an registry hrn and its value is a
     # hrns at that registry (determined by the known prefix tree).  
     xrn_dict = {}
-    # XX Preload this into the api module
-    registries = Registries(api)
+    registries = api.registries
     tree = prefixTree()
     registry_hrns = registries.keys()
     tree.load(registry_hrns)
@@ -126,7 +124,7 @@ def list(api, xrn, origin_hrn=None):
     # load all know registry names into a prefix tree and attempt to find
     # the longest matching prefix
     records = []
-    registries = Registries(api)
+    registries = api.registries
     registry_hrns = registries.keys()
     tree = prefixTree()
     tree.load(registry_hrns)
@@ -367,7 +365,7 @@ def remove(api, xrn, type, origin_hrn=None):
     type = record['type']
 
     credential = api.getCredential()
-    registries = Registries(api)
+    registries = api.registries
 
     # Try to remove the object from the PLCDB of federated agg.
     # This is attempted before removing the object from the local agg's PLCDB and sfa table
index b3854a0..ee60941 100644 (file)
@@ -20,13 +20,11 @@ from sfa.util.prefixTree import prefixTree
 from sfa.util.rspec import *
 from sfa.util.sfaticket import *
 from sfa.util.debug import log
-from sfa.server.registry import Registries
-from sfa.server.aggregate import Aggregates
 import sfa.plc.peers as peers
 
 def delete_slice(api, xrn, origin_hrn=None):
     credential = api.getCredential()
-    aggregates = Aggregates(api)
+    aggregates = api.aggregates
     for aggregate in aggregates:
         success = False
         # request hash is optional so lets try the call without it
@@ -60,7 +58,7 @@ def create_slice(api, xrn, rspec, origin_hrn=None):
             message = "%s (line %s)" % (error.message, error.line)
             raise InvalidRSpec(message)
 
-    aggs = Aggregates(api)
+    aggs = api.aggregates
     cred = api.getCredential()                                                 
     for agg in aggs:
         if agg not in [api.auth.client_cred.get_gid_caller().get_hrn()]:      
@@ -91,7 +89,7 @@ def get_ticket(api, xrn, rspec, origin_hrn=None):
         rspecs[net_hrn] = temp_rspec.toxml() 
     
     # send the rspec to the appropiate aggregate/sm
-    aggregates = Aggregates(api)
+    aggregates = api.aggregates
     credential = api.getCredential()
     tickets = {}
     for net_hrn in rspecs:
@@ -198,7 +196,7 @@ def get_rspec(api, xrn=None, origin_hrn=None):
     hrn, type = urn_to_hrn(xrn)
     rspec = None
 
-    aggs = Aggregates(api)
+    aggs = api.aggregates
     cred = api.getCredential()                                                 
     for agg in aggs:
         if agg not in [api.auth.client_cred.get_gid_caller().get_hrn()]:      
index 9c5cf62..190ee63 100644 (file)
@@ -16,7 +16,6 @@ from sfa.util.debug import log
 from sfa.util.rspec import *
 from sfa.util.specdict import * 
 from sfa.util.policy import Policy
-from sfa.server.aggregate import Aggregates 
 
 class Nodes(SimpleStorage):
 
@@ -107,7 +106,7 @@ class Nodes(SimpleStorage):
         end_time = int(threshold.strftime("%s"))
         duration = end_time - start_time
 
-        aggregates = Aggregates(self.api)
+        aggregates = self.api.aggregates
         rspecs = {}
         networks = []
         rspec = RSpec()
index d8c48b7..9730e97 100644 (file)
@@ -16,8 +16,6 @@ from sfa.util.record import SfaRecord
 from sfa.util.policy import Policy
 from sfa.util.prefixTree import prefixTree
 from sfa.util.debug import log
-from sfa.server.aggregate import Aggregates
-from sfa.server.registry import Registries
 
 MAXINT =  2L**31-1
 
@@ -212,30 +210,17 @@ class Slices(SimpleStorage):
 
     def refresh_slices_smgr(self):
         slice_hrns = []
-        aggregates = Aggregates(self.api)
         credential = self.api.getCredential()
-        for aggregate in aggregates:
+        for aggregate in self.api.aggregates:
             success = False
-            # request hash is optional so lets try the call without it 
             try:
-                slices = aggregates[aggregate].get_slices(credential)
+                slices = self.api.aggregates[aggregate].get_slices(credential)
                 slice_hrns.extend(slices)
                 success = True
             except:
                 print >> log, "%s" % (traceback.format_exc())
                 print >> log, "Error calling slices at aggregate %(aggregate)s" % locals()
 
-            # try sending the request hash if the previous call failed 
-            if not success:
-                arg_list = [credential]
-                try:
-                    slices = aggregates[aggregate].get_slices(credential)
-                    slice_hrns.extend(slices)
-                    success = True
-                except:
-                    print >> log, "%s" % (traceback.format_exc())
-                    print >> log, "Error calling slices at aggregate %(aggregate)s" % locals()
-
         # update timestamp and threshold
         timestamp = datetime.datetime.now()
         hr_timestamp = timestamp.strftime(self.api.time_format)
@@ -420,8 +405,7 @@ class Slices(SimpleStorage):
         slicename = hrn_to_pl_slicename(hrn) 
         slice = {}
         slice_record = None
-        registries = Registries(self.api)
-        registry = registries[self.api.hrn]
+        registry = self.api.registries[self.api.hrn]
         credential = self.api.getCredential()
 
         site_id, remote_site_id = self.verify_site(registry, credential, hrn, peer, sfa_peer)