From 251ac118bd2412f142c1a37cabc623b94f76cd4e Mon Sep 17 00:00:00 2001 From: skiranh Date: Fri, 3 Jul 2015 16:00:20 +0530 Subject: [PATCH] Modifying scripts to accomodate pagination changes Recent pagination changes to ifmap requires changes to our script. Modifying the script to get only the exact match. Correcting re requirement Change-Id: I7a0ea83c040f6f304ad94747addc623346f94780 Closes-Bug: 1457216 --- scripts/scale/control-node/cn_introspect_bgp.py | 5 ++++- tcutils/control/cn_introspect_utils.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/scale/control-node/cn_introspect_bgp.py b/scripts/scale/control-node/cn_introspect_bgp.py index 473436d6c..3a673e424 100755 --- a/scripts/scale/control-node/cn_introspect_bgp.py +++ b/scripts/scale/control-node/cn_introspect_bgp.py @@ -38,7 +38,10 @@ def http_get(self, path): def _get_if_map_table_entry(self, match): d = None - p = self.http_get('Snh_IFMapTableShowReq') + #Changes to paging will require fetching particular element rather than entire data + table_name = re.match('(\S+?):', match) + new_table_req = 'Snh_IFMapTableShowReq?table_name=' + table_name.group(1) + '&search_string=' + match + p = self.dict_get(new_table_req) xp = p.xpath('./IFMapTableShowResp/ifmap_db/list/IFMapNodeShowInfo') f = filter(lambda x: x.xpath('./node_name')[0].text == match, xp) if 1 == len(f): diff --git a/tcutils/control/cn_introspect_utils.py b/tcutils/control/cn_introspect_utils.py index c324b9681..bebccb6cf 100644 --- a/tcutils/control/cn_introspect_utils.py +++ b/tcutils/control/cn_introspect_utils.py @@ -1,6 +1,6 @@ import logging as LOG from lxml import etree - +import re from tcutils.verification_util import * from tcutils.util import is_v6 from netaddr import IPNetwork, AddrFormatError @@ -20,7 +20,10 @@ def _join(self, *args): def _get_if_map_table_entry(self, match): d = None - p = self.dict_get('Snh_IFMapTableShowReq') + #Changes to paging will require fetching particular element rather than entire data + table_name = re.match('(\S+?):', match) + new_table_req = 'Snh_IFMapTableShowReq?table_name=' + table_name.group(1) + '&search_string=' + match + p = self.dict_get(new_table_req) xp = p.xpath('./IFMapTableShowResp/ifmap_db/list/IFMapNodeShowInfo') if not xp: # sometime ./xpath dosen't work; work around