Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor network.send_icmp to use deafult OS ping size #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rrmngmnt/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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():
Copy link
Owner

@lukas-bednar lukas-bednar Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change that condition to size is not None, and use str(size) in following line. I don't like approach to ignore parameter when it has wrong form - it is always better to fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you

cmd.extend(["-s", "size", "-M", "do"])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that there should be size (without quotes)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, it is there by mistake... Thanks for noticing :)

if extra_args is not None:
for ar in extra_args.split():
cmd.extend(ar.split())
Expand Down