-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add network configuration check and report to ros2doctor #319
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0a55cfa
add network checks and report
9f2428e
network shenanigens
f1d4071
network shenanigens
eee518c
network shenanigens
0a13602
add network check and report
f0b0ce9
update code format
5dec7e1
revised code format
0e3f0b6
add ifcfg-pip rosdep key
871a350
added rosdep key ifcfg-pip
3373522
Merge branch 'claire/ros2doctor-network' of https://github.com/ros2/r…
2389097
revise code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2019 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
def print_term(k, v): | ||
"""Print term only if it exists.""" | ||
if v: | ||
# TODO(clairewang): 20 padding needs to be dynamically set | ||
print('{:20}: {}'.format(k, v)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2019 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import sys | ||
|
||
import ifcfg | ||
|
||
from ros2doctor.api.format import print_term | ||
|
||
|
||
def _is_unix_like_platform(): | ||
"""Return True if conforms to UNIX/POSIX-style APIs.""" | ||
return os.name == 'posix' | ||
|
||
|
||
def check_network_config_helper(): | ||
"""Check if loopback and multicast IP addresses are found.""" | ||
has_loopback, has_non_loopback, has_multicast = False, False, False | ||
for name, iface in ifcfg.interfaces().items(): | ||
flags = iface.get('flags') | ||
if 'LOOPBACK' in flags: | ||
has_loopback = True | ||
else: | ||
has_non_loopback = True | ||
if 'MULTICAST' in flags: | ||
has_multicast = True | ||
return has_loopback, has_non_loopback, has_multicast | ||
|
||
|
||
def check_network_config(): | ||
"""Conduct network checks and output error/warning messages.""" | ||
has_loopback, has_non_loopback, has_multicast = check_network_config_helper() | ||
if not has_loopback: | ||
sys.stderr.write('ERROR: No loopback IP address is found.\n') | ||
if not has_non_loopback: | ||
sys.stderr.write('WARNING: Only loopback IP address is found.\n') | ||
if not has_multicast: | ||
sys.stderr.write('WARNING: No multicast IP address is found.\n') | ||
return has_loopback and has_non_loopback and has_multicast | ||
|
||
|
||
def print_network(): | ||
"""Print all system and ROS network information.""" | ||
print('NETWORK CONFIGURATION') | ||
for name, iface in ifcfg.interfaces().items(): | ||
for k, v in iface.items(): | ||
print_term(k, v) | ||
print('\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely an improvement. I still think it would be good if the
reports
just returned information and the command was responsible for outputting it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about making that change as a feature in the next PR. Like you suggested last time, I'd like to add arguments like
--report_all
or--report_failed
to let users control what they would like to see based on the check results.