-
Notifications
You must be signed in to change notification settings - Fork 35
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 netplan config parding sh utility for ubuntu static ip #1026
Conversation
c36f80e
to
b0d181a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1026 +/- ##
=======================================
Coverage ? 16.47%
=======================================
Files ? 107
Lines ? 19645
Branches ? 0
=======================================
Hits ? 3237
Misses ? 16117
Partials ? 291
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
GOLD for bash/dash yaml parsing.
But let's eval to use netplan generate
or netplan get
to avoid this parsing.
With the following script we loop over all configured interfaces and output the one for the given IP address $ IP_TO_FIND=10.0.2.15
$ netplan get ethernets | grep -Eo "^[^[:space:]]+[^:]" | while read IFNAME ; do netplan get ethernets.$IFNAME.addresses | grep -q $IP_TO_FIND && echo $IFNAME ; done |
8fc6c77
to
ec77001
Compare
Signed-off-by: yaacov <[email protected]>
ec77001
to
c237860
Compare
while IFS= read -r line; do | ||
echo "$line" | ||
done < "$V2V_MAP_FILE" |
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 think this is equal to cat $V2V_MAP_FILE
as we just echo every line without modifications.
In the original code I was modifying the line to convert them into ENV_KEY=VALUE format to then export them iwth export
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.
thanks ! replaced ...
# Loop through all interfaces and check for the given IP address | ||
netplan_get ethernets | grep -Eo "^[^[:space:]]+[^:]" | while read IFNAME; do | ||
if netplan_get ethernets."$IFNAME".addresses | grep -q "$target_ip"; then | ||
echo "$IFNAME" |
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.
either we should return
here
or later we need to check that we only found one ifname
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.
added return here
|
||
# If S_HW and S_IP were not extracted, skip the line | ||
if [ -z "$S_HW" ] || [ -z "$S_IP" ]; then | ||
continue |
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.
worth adding a log message?
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.
added logs for invalid mac to ip lines
|
||
# If no interface is found, skip this entry | ||
if [ -z "$interface_name" ]; then | ||
continue |
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.
worth adding a log message?
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.
added logs for device not found
Signed-off-by: yaacov <[email protected]>
Signed-off-by: yaacov <[email protected]>
Signed-off-by: yaacov <[email protected]>
Signed-off-by: yaacov <[email protected]>
Quality Gate passedIssues Measures |
Add netplan config parding sh utility for ubuntu static ip