From 9269e9a67b2a23e874791ffbf5a857259ca22d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89douard=20Thuleau?= Date: Thu, 7 Apr 2016 10:14:55 +0200 Subject: [PATCH] [schema] Return None if cannot locate resource When the schema locates a resource from database, it stores the id/fq_name mapping in memory but in case the resource does not exist, it tries to get id from a None value that results to 'AttributeError' exception. Closes-bug: #1567267 Change-Id: If9387252b9da9093a939651fed8f7a5cbb09be04 --- src/config/schema-transformer/config_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/schema-transformer/config_db.py b/src/config/schema-transformer/config_db.py index 08a9a188360..6f8d6f5ed2b 100644 --- a/src/config/schema-transformer/config_db.py +++ b/src/config/schema-transformer/config_db.py @@ -102,7 +102,7 @@ def reinit(cls): @classmethod def locate(cls, key, *args): obj = super(DBBaseST, cls).locate(key, *args) - if obj.obj.uuid not in cls._uuid_fq_name_map: + if obj and obj.obj.uuid not in cls._uuid_fq_name_map: cls._uuid_fq_name_map[obj.obj.uuid] = key return obj # end locate @@ -370,7 +370,7 @@ def delete_inactive_service_chains(self, old_scs, new_scs=None): # Delete the service chains that are no longer active for remote_vn_name in old_scs: - # Get the Remote VNs in this VN's service chain and + # Get the Remote VNs in this VN's service chain and # get a list of the remote service chains in the remote # VNs which has this VNs name. remote_vn = VirtualNetworkST.get(remote_vn_name)