From 29989cf78371e18ddaaca8246ef5bd5575596678 Mon Sep 17 00:00:00 2001 From: Moshe Sheena Date: Wed, 24 Oct 2018 11:34:13 +0300 Subject: [PATCH 1/2] Refactor network.send_icmp to use deafult OS ping size This refactoring allows the function to use the default host OS ping size in case the 'size' parameter was not passed and does not rely on a default size of 1500 --- rrmngmnt/network.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rrmngmnt/network.py b/rrmngmnt/network.py index 0bb373a..e0d4250 100644 --- a/rrmngmnt/network.py +++ b/rrmngmnt/network.py @@ -485,7 +485,7 @@ def delete_ifcfg_file(self, nic, ifcfg_path=IFCFG_PATH): return False return True - def send_icmp(self, dst, count="5", size="1500", extra_args=None): + def send_icmp(self, dst, count="5", size=None, extra_args=None): """ Send ICMP to destination IP/FQDN @@ -500,9 +500,9 @@ def send_icmp(self, dst, count="5", size="1500", extra_args=None): :return: True/False :rtype: bool """ - cmd = ["ping", dst, "-c", count, "-s", size] - if size != "1500": - cmd.extend(["-M", "do"]) + cmd = ["ping", dst, "-c", count] + if size and size.isdigit(): + cmd.extend(["-s", "size", "-M", "do"]) if extra_args is not None: for ar in extra_args.split(): cmd.extend(ar.split()) From 924869a8d361cb5575e444f10ec70d3cd130649a Mon Sep 17 00:00:00 2001 From: Moshe Sheena Date: Wed, 24 Oct 2018 11:34:13 +0300 Subject: [PATCH 2/2] Refactor network.send_icmp to use deafult OS ping size This refactoring allows the function to use the default host OS ping size in case the 'size' parameter was not passed and does not rely on a default size of 1500 --- rrmngmnt/network.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rrmngmnt/network.py b/rrmngmnt/network.py index 0bb373a..6fed612 100644 --- a/rrmngmnt/network.py +++ b/rrmngmnt/network.py @@ -485,7 +485,7 @@ def delete_ifcfg_file(self, nic, ifcfg_path=IFCFG_PATH): return False return True - def send_icmp(self, dst, count="5", size="1500", extra_args=None): + def send_icmp(self, dst, count="5", size=None, extra_args=None): """ Send ICMP to destination IP/FQDN @@ -500,9 +500,9 @@ def send_icmp(self, dst, count="5", size="1500", extra_args=None): :return: True/False :rtype: bool """ - cmd = ["ping", dst, "-c", count, "-s", size] - if size != "1500": - cmd.extend(["-M", "do"]) + cmd = ["ping", dst, "-c", count] + if size is not None: + cmd.extend(["-s", str(size), "-M", "do"]) if extra_args is not None: for ar in extra_args.split(): cmd.extend(ar.split())