From 46c36f7079f5fc1a3087a9cd7c8a7bb3a1a4addd Mon Sep 17 00:00:00 2001 From: Sachin Bansal Date: Thu, 6 Apr 2017 16:54:02 -0700 Subject: [PATCH] Fixed logic to find out if anything changed during update Change-Id: I786a21876b4c198a71d6a7f6d2e7d0fc30c28029 Closes-Bug: 1674514 --- src/config/common/vnc_amqp.py | 9 +++++--- src/config/schema-transformer/config_db.py | 26 ++++++++-------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/config/common/vnc_amqp.py b/src/config/common/vnc_amqp.py index 18f3a6def8f..71cbdba2c2f 100644 --- a/src/config/common/vnc_amqp.py +++ b/src/config/common/vnc_amqp.py @@ -155,9 +155,12 @@ def handle_update(self): return try: - if self.obj.update() == False: - # If update returns a False it indicates nothing has changed. - # If it returns True or None, then some change was detected. + ret = self.obj.update() + if ret is not None and not ret: + # If update returns None, the function may not support a + # return value, hence treat it as if something might have + # changed. If a value is returned, use its truth value. + # If it True, then some change was detected. # If no change, then terminate dependency tracker return except NoIdError: diff --git a/src/config/schema-transformer/config_db.py b/src/config/schema-transformer/config_db.py index 8c8ca75588d..e31d1770f30 100644 --- a/src/config/schema-transformer/config_db.py +++ b/src/config/schema-transformer/config_db.py @@ -146,7 +146,8 @@ class GlobalSystemConfigST(DBBaseST): _dict = {} obj_type = 'global_system_config' _autonomous_system = 0 - _ibgp_auto_mesh = None + ibgp_auto_mesh = None + prop_fields = ['autonomous_system', 'ibgp_auto_mesh'] @classmethod def reinit(cls): @@ -165,10 +166,10 @@ def __init__(self, name, obj): # end __init__ def update(self, obj=None): - self.obj = obj or self.read_vnc_obj(uuid=self.uuid) - ret = self.update_autonomous_system(self.obj.autonomous_system) - ret = self.update_ibgp_auto_mesh(self.obj.ibgp_auto_mesh) or ret - return ret + changed = self.update_vnc_obj(obj) + if 'autonomous_system' in changed : + self.update_autonomous_system(self.obj.autonomous_system) + return changed # end update @classmethod @@ -178,7 +179,9 @@ def get_autonomous_system(cls): @classmethod def get_ibgp_auto_mesh(cls): - return cls._ibgp_auto_mesh + if cls.ibgp_auto_mesh is None: + return True + return cls.ibgp_auto_mesh # end get_ibgp_auto_mesh @classmethod @@ -241,17 +244,6 @@ def evaluate(self): router.update_autonomous_system(self._autonomous_system) # end for router # end evaluate - - @classmethod - def update_ibgp_auto_mesh(cls, value): - if value is None: - value = True - if cls._ibgp_auto_mesh == value: - return False - cls._ibgp_auto_mesh = value - return True - # end update_ibgp_auto_mesh - # end GlobalSystemConfigST