Skip to content

Commit

Permalink
Merge pull request #546 from yast/caasp_merge
Browse files Browse the repository at this point in the history
Caasp merge
  • Loading branch information
jreidinger committed Aug 10, 2017
2 parents 9c25bd0 + 3da3767 commit c5e518a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
25 changes: 20 additions & 5 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Tue Aug 1 07:48:25 UTC 2017 - mfilka@suse.com

- bnc#1037727
- fixed device name recognition during AY installation
- 3.1.182

-------------------------------------------------------------------
Fri Jul 28 06:44:13 UTC 2017 - mfilka@suse.com

- bnc1039532
- configure static IPs to resolve to system wide hostname during
installation
- 3.1.181

-------------------------------------------------------------------
Expand Down Expand Up @@ -49,14 +57,21 @@ Wed Feb 22 10:49:17 UTC 2017 - mfilka@suse.com
- 3.1.175

-------------------------------------------------------------------
Thu Jan 19 15:22:03 UTC 2017 - kanderssen@suse.com
Tue Jan 24 15:38:14 UTC 2017 - kanderssen@suse.com

- Backported
- Added network proposal using the new summary api and the new
proposal_client flag 'label_proposal' for CASP special formmating
(fate#322328).
- Backport fix for bnc#1013605
- Enable DHCP_HOSTNAME listbox only when wicked service is used.
- Fixed displaying the "keep current settings" option.
- 3.1.174

-------------------------------------------------------------------
Thu Jan 19 15:22:03 UTC 2017 - kanderssen@suse.com

- Added network proposal using the new summary api and the new
proposal_client flag 'label_proposal' for CASP special formmating
(fate#322328).
- 3.1.173.1

-------------------------------------------------------------------
Wed Jan 18 07:54:01 UTC 2017 - kanderssen@suse.com

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


Name: yast2-network
Version: 3.1.181
Version: 3.1.182
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
17 changes: 9 additions & 8 deletions src/modules/Host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ def Update(oldhn, newhn, iplist)
)
@modified = true

nick = Ops.get(Hostname.SplitFQ(newhn), 0, "")

# Remove old hostname from hosts
if !oldhn.empty?
Builtins.foreach(@hosts) do |ip, hs|
Expand All @@ -301,12 +299,14 @@ def Update(oldhn, newhn, iplist)

# Add hostname/ip for all ips
nickadded = false
nick = Hostname.SplitFQ(newhn)[0] || ""

Builtins.maplist(ips) do |ip|
# Omit some IP addresses
next if ip == "" || ip.nil? || ip == "127.0.0.1"
name = newhn
# Add nick for the first one
if !nickadded && name != ""
if !nickadded && name != "" && name != nick
nickadded = true
name = Ops.add(Ops.add(newhn, " "), nick)
end
Expand Down Expand Up @@ -351,11 +351,12 @@ def StaticIPs
# if we have a static address,
# make sure /etc/hosts resolves it to our, bnc#664929
def ResolveHostnameToStaticIPs
static_ips = StaticIPs()
if Ops.greater_than(Builtins.size(static_ips), 0)
fqhostname = Hostname.MergeFQ(DNS.hostname, DNS.domain)
Update(fqhostname, fqhostname, static_ips)
end
# reject those static ips which have particular hostnames already configured
static_ips = StaticIPs().reject { |sip| !names(sip).empty? }
return if static_ips.empty?

fqhostname = Hostname.MergeFQ(DNS.hostname, DNS.domain)
Update(fqhostname, fqhostname, static_ips)

nil
end
Expand Down
32 changes: 32 additions & 0 deletions test/host_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,37 @@
tested_ip = "10.0.0.1"
expect(host.name_map[tested_ip]).to eql etc_hosts[tested_ip]
end

it "doesn't write entry with duplicate hostname" do
ip = "1.1.1.1"
hostname = "linux"

Yast::Host.Update(hostname, hostname, [ip])
expect(Yast::Host.name_map[ip]).not_to eql ["#{hostname} #{hostname}"]
end
end

describe ".ResolveHostnameToStaticIPs" do
let(:static_ips) { ["1.1.1.1", "2.2.2.2"] }
let(:fqhostname) { "sles.suse.de" }

before(:each) do
allow(Yast::Host)
.to receive(:StaticIPs)
.and_return(static_ips)
allow(Yast::Hostname).to receive(:MergeFQ).and_return(fqhostname)
end

it "doesn't call .Update when an IP already has a hostname" do
hostname = "linux"

Yast::Host.Update(hostname, hostname, [static_ips[0]])

expect(Yast::Host)
.not_to receive(:Update)
.with(fqhostname, fqhostname, static_ips)

Yast::Host.ResolveHostnameToStaticIPs
end
end
end

0 comments on commit c5e518a

Please sign in to comment.