Skip to content

Commit

Permalink
Merge 5f34741 into 1c63b75
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Mar 24, 2020
2 parents 1c63b75 + 5f34741 commit c9e7924
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
6 changes: 0 additions & 6 deletions src/modules/Lan.rb
Expand Up @@ -862,20 +862,14 @@ def activate_network_service
# ssh, we should not restart network because systemctl
# hangs in that case. (bnc#885640)
action = :reload_restart if Stage.normal || !Linuxrc.usessh
action = :force_restart if LanItems.force_restart
action = :remote_installer if Stage.initial && (Linuxrc.usessh || Linuxrc.vnc)

case action
when :force_restart
log.info("Network service activation forced")
NetworkService.Restart

when :reload_restart
log.info("Attempting to reload network service, normal stage #{Stage.normal}, " \
"ssh: #{Linuxrc.usessh}")

NetworkService.ReloadOrRestart if Stage.normal || !Linuxrc.usessh

when :remote_installer
connection_names = yast_config&.connections&.map(&:name) || []

Expand Down
4 changes: 0 additions & 4 deletions src/modules/LanItems.rb
Expand Up @@ -65,9 +65,6 @@ def main
# Which operation is pending?
@operation = nil

# in special cases when rcnetwork reload is not enought
@force_restart = false

@description = ""

@type = ""
Expand Down Expand Up @@ -800,7 +797,6 @@ def yast_config
publish_variable :driver_options, "map <string, any>"
publish_variable :autoinstall_settings, "map"
publish_variable :operation, "symbol"
publish_variable :force_restart, "boolean"
publish_variable :description, "string"
publish_variable :type, "string"
# note: read-only param. Any modification is ignored.
Expand Down
23 changes: 4 additions & 19 deletions test/lan_test.rb
Expand Up @@ -90,12 +90,10 @@
let(:eth0) { Y2Network::ConnectionConfig::Ethernet.new.tap { |c| c.name = "eth0" } }
let(:eth1) { Y2Network::ConnectionConfig::Ethernet.new.tap { |c| c.name = "eth1" } }

let(:force_restart) { false }
let(:installation) { false }

before do
subject.add_config(:yast, yast_config)
allow(Yast::LanItems).to receive(:force_restart).and_return(force_restart)
allow(Yast::Stage).to receive(:normal).and_return(!installation)
allow(Yast::Stage).to receive(:initial).and_return(installation)
end
Expand All @@ -109,24 +107,11 @@
end

context "when asked in normal mode" do
context "and a restart is not forced" do
it "tries to reload network service" do
expect(Yast::NetworkService)
.to receive(:ReloadOrRestart)

Yast::Lan.send(:activate_network_service)
end
end
it "tries to reload network service" do
expect(Yast::NetworkService)
.to receive(:ReloadOrRestart)

context "and a restart is forced" do
let(:force_restart) { true }

it "tries to restart the network service" do
expect(Yast::NetworkService)
.to receive(:Restart)

Yast::Lan.send(:activate_network_service)
end
Yast::Lan.send(:activate_network_service)
end
end

Expand Down

0 comments on commit c9e7924

Please sign in to comment.