From c1e0709e40d680d74501adde6728fef906f384bc Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 7 Apr 2011 15:57:59 +0200 Subject: [PATCH] rename should_handle_call_id into (inverted) already_handled --- sfa/managers/aggregate_manager_eucalyptus.py | 2 +- sfa/managers/aggregate_manager_max.py | 2 +- sfa/managers/aggregate_manager_pl.py | 3 ++- sfa/managers/aggregate_manager_vini.py | 2 +- sfa/managers/slice_manager_pl.py | 3 ++- sfa/util/callids.py | 10 +++++----- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sfa/managers/aggregate_manager_eucalyptus.py b/sfa/managers/aggregate_manager_eucalyptus.py index a70d0b3a..2a36ce96 100644 --- a/sfa/managers/aggregate_manager_eucalyptus.py +++ b/sfa/managers/aggregate_manager_eucalyptus.py @@ -395,7 +395,7 @@ class ZoneResultParser(object): return clusterList def get_rspec(api, creds, options, call_id): - if not Callids().should_handle_call_id(call_id): return "" + if Callids().already_handled(call_id): return "" global cloud # get slice's hrn from options xrn = options.get('geni_slice_urn', '') diff --git a/sfa/managers/aggregate_manager_max.py b/sfa/managers/aggregate_manager_max.py index 0b37bb32..9e233ff5 100644 --- a/sfa/managers/aggregate_manager_max.py +++ b/sfa/managers/aggregate_manager_max.py @@ -255,7 +255,7 @@ def create_slice_max_aggregate(api, hrn, nodes): def get_rspec(api, creds, options, call_id): - if not Callids().should_handle_call_id(call_id): return "" + if Callids().already_handled(call_id): return "" # get slice's hrn from options xrn = options.get('geni_slice_urn', '') hrn, type = urn_to_hrn(xrn) diff --git a/sfa/managers/aggregate_manager_pl.py b/sfa/managers/aggregate_manager_pl.py index 0c52d9f3..790a1e75 100644 --- a/sfa/managers/aggregate_manager_pl.py +++ b/sfa/managers/aggregate_manager_pl.py @@ -293,8 +293,9 @@ def get_slices(api, creds): # xxx Thierry : caching at the aggregate level sounds wrong... caching=True +#caching=False def get_rspec(api, creds, options,call_id): - if not Callids().should_handle_call_id(call_id): return "" + if Callids().already_handled(call_id): return "" # get slice's hrn from options xrn = options.get('geni_slice_urn', '') (hrn, type) = urn_to_hrn(xrn) diff --git a/sfa/managers/aggregate_manager_vini.py b/sfa/managers/aggregate_manager_vini.py index e16d2010..72ff27f9 100644 --- a/sfa/managers/aggregate_manager_vini.py +++ b/sfa/managers/aggregate_manager_vini.py @@ -90,7 +90,7 @@ def create_slice(api, xrn, creds, xml, users): return True def get_rspec(api, creds, options,call_id): - if not Callids().should_handle_call_id(call_id): return "" + if Callids().already_handled(call_id): return "" # get slice's hrn from options xrn = options.get('geni_slice_urn', '') hrn, type = urn_to_hrn(xrn) diff --git a/sfa/managers/slice_manager_pl.py b/sfa/managers/slice_manager_pl.py index bc777a63..80588f79 100644 --- a/sfa/managers/slice_manager_pl.py +++ b/sfa/managers/slice_manager_pl.py @@ -325,9 +325,10 @@ def get_slices(api, creds): # Thierry : caching at the slicemgr level makes sense to some extent caching=True +#caching=False def get_rspec(api, creds, options, call_id): - if not Callids().should_handle_call_id(call_id): + if Callids().already_handled(call_id): api.logger.info("%d received get_rspec with known call_id %s"%(api.interface,call_id)) return "" diff --git a/sfa/util/callids.py b/sfa/util/callids.py index 23e0c534..904c42b4 100644 --- a/sfa/util/callids.py +++ b/sfa/util/callids.py @@ -28,9 +28,9 @@ class _call_ids_impl (dict): # the only primitive # return True if the callid is unknown, False otherwise - def should_handle_call_id (self,call_id): + def already_handled (self,call_id): # if not provided in the call... - if not call_id: return True + if not call_id: return False has_lock=False for attempt in range(_call_ids_impl.retries): if debug: sfa_logger().debug("Waiting for lock (%d)"%attempt) @@ -42,17 +42,17 @@ class _call_ids_impl (dict): # in the unlikely event where we can't get the lock if not has_lock: sfa_logger().warning("_call_ids_impl.should_handle_call_id: could not acquire lock") - return True + return False # we're good to go if self.has_key(call_id): self._purge() self._lock.release() - return False + return True self[call_id]=time.time() self._purge() self._lock.release() if debug: sfa_logger().debug("released lock") - return True + return False def _purge(self): now=time.time() -- 2.47.0