summaryrefslogtreecommitdiffstats
path: root/scripts/automation
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-04-15 19:02:17 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-04-15 19:02:17 +0300
commit9c1dfed4edc4a4d3f51fc7f9ac9cab58657ab818 (patch)
treef80615f1b0bad8acc6f1593f3cb14edb0d911444 /scripts/automation
parentd605980b0f4f8e03dc75db5fa42084afd5da9b4e (diff)
regression: improve clear NAT translations
Diffstat (limited to 'scripts/automation')
-rwxr-xr-xscripts/automation/regression/CPlatform.py14
-rwxr-xr-xscripts/automation/regression/platform_cmd_link.py13
2 files changed, 17 insertions, 10 deletions
diff --git a/scripts/automation/regression/CPlatform.py b/scripts/automation/regression/CPlatform.py
index 7727b3ce..ba1168f0 100755
--- a/scripts/automation/regression/CPlatform.py
+++ b/scripts/automation/regression/CPlatform.py
@@ -388,7 +388,7 @@ class CPlatform(object):
cache.add('CONF', conf_t_command_set)
# deploy the configs (order is important!)
- self.cmd_link.run_single_command( cache )
+ return self.cmd_link.run_single_command( cache )
def config_no_nat (self, nat_obj = None):
@@ -575,6 +575,9 @@ class CPlatform(object):
response = self.cmd_link.run_single_command('show ip nat statistics')
return CShowParser.parse_nat_stats(response)
+ def get_nat_trans (self):
+ return self.cmd_link.run_single_command('show ip nat translation')
+
def get_cvla_memory_usage(self):
response = self.cmd_link.run_single_command('show platform hardware qfp active infrastructure cvla client handles')
# (res, res2) = CShowParser.parse_cvla_memory_usage(response)
@@ -584,8 +587,15 @@ class CPlatform(object):
# clear methods
def clear_nat_translations(self):
pre_commit_cache = CCommandCache()
+ # prevent new NAT entries
+ # http://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/13779-clear-nat-comments.html
+ for dual_if in self.if_mngr.get_dual_if_list(is_duplicated = False):
+ pre_commit_cache.add('IF', "no ip nat inside", dual_if.client_if.get_name())
+ pre_commit_cache.add('IF', "no ip nat outside", dual_if.server_if.get_name())
+ # clear the translation
pre_commit_cache.add('EXEC', 'clear ip nat translation *')
- self.cmd_link.run_single_command( pre_commit_cache )
+ self.cmd_link.run_single_command(pre_commit_cache)
+ time.sleep(1)
def clear_cft_counters (self):
""" clear_cft_counters(self) -> None
diff --git a/scripts/automation/regression/platform_cmd_link.py b/scripts/automation/regression/platform_cmd_link.py
index ceb0b1de..7d74a8f8 100755
--- a/scripts/automation/regression/platform_cmd_link.py
+++ b/scripts/automation/regression/platform_cmd_link.py
@@ -419,7 +419,7 @@ class CIosTelnet(telnetlib.Telnet):
except Exception as inst:
raise
- def write_ios_cmd (self, cmd_list, result_from = 0, timeout = 10, **kwargs):
+ def write_ios_cmd (self, cmd_list, result_from = 0, timeout = 3, **kwargs):
assert (isinstance (cmd_list, list) == True)
self.read_until(self.pr, timeout = 1)
@@ -429,23 +429,20 @@ class CIosTelnet(telnetlib.Telnet):
else:
wf = self.pr
- start_time = time.time()
for idx, cmd in enumerate(cmd_list):
self.write(cmd+'\r\n')
if idx < result_from:
# don't care for return string
if type(wf) is list:
- self.expect(wf, timeout = 3)[2]
+ self.expect(wf, timeout)[2]
else:
- self.read_until(wf, timeout = 3)
+ self.read_until(wf, timeout)
else:
# care for return string
if type(wf) is list:
- res += self.expect(wf, timeout = 3)[2]
+ res += self.expect(wf, timeout)[2]
else:
- res += self.read_until(wf, timeout = 3)
- if time.time() - start_time >= timeout:
- raise Exception('A timeout error has occured at command %s' % cmd_list)
+ res += self.read_until(wf, timeout)
# return res.split('\r\n')
return res # return the received response as a string, each line is seperated by '\r\n'.