Skip to content

Commit

Permalink
Modifying scripts to accomodate pagination changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
skiranh committed Jul 13, 2015
1 parent 4f8a37c commit 8900959
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion scripts/scale/control-node/cn_introspect_bgp.py
Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions 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
Expand All @@ -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
Expand Down

0 comments on commit 8900959

Please sign in to comment.