Skip to content

Commit

Permalink
Fixed logic to find out if anything changed during update
Browse files Browse the repository at this point in the history
Change-Id: I786a21876b4c198a71d6a7f6d2e7d0fc30c28029
Closes-Bug: 1674514
  • Loading branch information
Sachin Bansal committed Apr 10, 2017
1 parent 97facea commit 46c36f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
9 changes: 6 additions & 3 deletions src/config/common/vnc_amqp.py
Expand Up @@ -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:
Expand Down
26 changes: 9 additions & 17 deletions src/config/schema-transformer/config_db.py
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 46c36f7

Please sign in to comment.