Skip to content

Commit

Permalink
Merge pull request #521 from teclator/fix_dashed_url
Browse files Browse the repository at this point in the history
Fix dashed url (bsc#1024965)
  • Loading branch information
teclator committed Feb 13, 2017
2 parents 7480713 + 3d0ddd5 commit 15c9492
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 19 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Feb 13 13:00:42 UTC 2017 - kanderssen@suse.com

- CaaSP: do not crash when used a dashed url for the controller
node location (bsc#1024965)
- 3.1.217.21

-------------------------------------------------------------------
Wed Feb 8 16:42:29 UTC 2017 - kanderssen@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.1.217.20
Version: 3.1.217.21
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
8 changes: 7 additions & 1 deletion src/lib/installation/system_roles/handlers.rb
Expand Up @@ -19,11 +19,14 @@
# current contact information at www.suse.com.
# ------------------------------------------------------------------------------

require "yast"
require "installation/cfa/salt"

module Installation
module SystemRoleHandlers
class WorkerRoleFinish
include Yast::Logger

def self.run
role = SystemRole.find("worker_role")
master_conf = CFA::MinionMasterConf.new
Expand All @@ -34,7 +37,10 @@ def self.run
log.info("The minion master.conf file does not exist, it will be created")
end
log.info("The controller node for this worker role is: #{master}")
master_conf.master = master
# FIXME: the cobblersettings lense does not support dashes in the url
# without single quotes, we need to use a custom lense for salt conf.
# As Salt can use also 'url' just use in case of dashed.
master_conf.master = master.include?("-") ? "'#{master}'" : master
master_conf.save
end
end
Expand Down
17 changes: 0 additions & 17 deletions test/roles_finish_test.rb
Expand Up @@ -6,23 +6,6 @@
require "fileutils"

describe ::Installation::Clients::RolesFinish do
MASTER_CONF = FIXTURES_DIR.join("minion.d/master.conf").freeze
MASTER_CONF_EXISTENT = FIXTURES_DIR.join("minion.d/master.conf_existent").freeze
MASTER_CONF_EXPECTED = FIXTURES_DIR.join("minion.d/master.conf_expected").freeze

let(:master_conf) { ::Installation::CFA::MinionMasterConf.new }
let(:master_conf_path) { MASTER_CONF }

after do
FileUtils.remove_file(MASTER_CONF, true)
end

before do
allow(Yast::Stage).to receive(:initial).and_return(true)
allow(subject).to receive(:master).and_return("salt_controller")
stub_const("Installation::CFA::MinionMasterConf::PATH", master_conf_path)
end

describe "#title" do
it "returns string with title" do
expect(subject.title).to be_a ::String
Expand Down
45 changes: 45 additions & 0 deletions test/system_role_handlers_test.rb
@@ -0,0 +1,45 @@
#! /usr/bin/env rspec

require_relative "./test_helper"
require "installation/system_role"
require "installation/system_roles/handlers"

describe Installation::SystemRoleHandlers::WorkerRoleFinish do
let(:role) { instance_double("::Installation::SystemRole") }
let(:conf) do
instance_double("::Installation::CFA::MinionMasterConf", load: true, save: true)
end

before do
allow(::Installation::SystemRole).to receive("find")
.with("worker_role").and_return(role)
allow(::Installation::CFA::MinionMasterConf).to receive(:new).and_return(conf)
end

describe ".run" do
context "if the worker role controller node location contains dashes" do
it "surrounds the url with single quotes before save" do
expect(role).to receive(:[]).with("controller_node").and_return("controller-url")
expect(conf).to receive(:master=).with("'controller-url'")
described_class.run
end

end

context "if the worker role controller node location does not contain dashes" do
it "saves the url as defined" do
expect(role).to receive(:[]).with("controller_node").and_return("controller")
expect(conf).to receive(:master=).with("controller")
described_class.run
end
end

it "saves the controller node location into the minion master.conf file" do
expect(role).to receive(:[]).with("controller_node").and_return("controller")
expect(conf).to receive(:master=).with("controller")
expect(conf).to receive(:save)

described_class.run
end
end
end

0 comments on commit 15c9492

Please sign in to comment.