From 8900959c699cc20e5e38ffb3515ab02d2113abdd Mon Sep 17 00:00:00 2001 From: skiranh Date: Mon, 13 Jul 2015 15:37:31 +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: I93b57a6418cb75c6dec7d1e6aed30a64724d2e3f 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 4e57de5fe..af82c6983 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