Skip to content

Commit

Permalink
Fix IP detection in AutoYaST rules (SLE 12 SP2) (#245)
Browse files Browse the repository at this point in the history
* Fix IP detection in AutoYaST rules
* Bump version and update changes file
  • Loading branch information
imobachgs committed Sep 9, 2016
1 parent 5511b97 commit 1e54251
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions package/autoyast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Sep 7 07:27:53 UTC 2016 - igonzalezsosa@suse.com

- Fix IP detection in AutoYaST installation rules
in order to find the correct profile when "ip route"
mentions "metric" (bnc#997548).
- 3.1.150

-------------------------------------------------------------------
Fri Aug 26 09:39:55 UTC 2016 - kanderssen@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: autoyast2
Version: 3.1.149
Version: 3.1.150
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
7 changes: 5 additions & 2 deletions src/modules/AutoInstallRules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1111,14 +1111,17 @@ def AutoInstallRules
nil
end

# Regexp to extract the IP from the routes table
HOSTADDRESS_REGEXP = /src ([\w.]+) /.freeze

# Return the IP through iproute2 tools
#
# @return [String] IP address
def hostaddress
return @hostaddress unless @hostaddress.nil?
ip_route = SCR.Execute(path(".target.bash_output"), "/usr/sbin/ip route")
regexp = /src ([\w.]+) \n/
if ret = ip_route["stdout"][regexp, 1]
if ret = ip_route["stdout"][HOSTADDRESS_REGEXP, 1]
log.info "Found IP address: #{ret}"
ret
else
log.warn "Cannot evaluate IP address: #{ip_route}"
Expand Down
5 changes: 3 additions & 2 deletions test/fixtures/output/ip_route.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
10.13.32.0/24 dev eth0 proto kernel scope link src 10.13.32.195
default via 10.13.32.1 dev eth0 proto dhcp
10.13.32.0/24 dev eth0 proto kernel scope link src 10.13.32.195 metric 600
10.163.0.1 dev tun0 proto kernel scope link src 10.163.0.6
10.163.2.0/28 dev eth1 proto kernel scope link src 10.163.2.1
10.163.2.0/28 dev eth1 proto kernel scope link src 10.163.2.1

0 comments on commit 1e54251

Please sign in to comment.