diff --git a/src/Makefile.am b/src/Makefile.am index 7088cdbf3..4ab9ca92c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -219,15 +219,6 @@ ylibwidget_DATA = \ lib/installation/widgets/overview.rb \ lib/installation/widgets/system_role.rb -ylibcfadir = "${yast2dir}/lib/installation/cfa" -ylibcfa_DATA = \ - lib/installation/cfa/salt.rb - -ylibrolehandlerdir = "${yast2dir}/lib/installation/system_role_handlers" -ylibrolehandler_DATA = \ - lib/installation/system_role_handlers/dashboard_role_finish.rb \ - lib/installation/system_role_handlers/worker_role_finish.rb - -EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) $(schemafiles_DATA) $(desktop_DATA) $(fillup_DATA) $(ylibdialog_DATA) $(ylib_DATA) $(ylibtransfer_DATA) $(ylibcfa_DATA) $(ylibrolehandler_DATA) +EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) $(schemafiles_DATA) $(desktop_DATA) $(fillup_DATA) $(ylibdialog_DATA) $(ylib_DATA) $(ylibtransfer_DATA) include $(top_srcdir)/Makefile.am.common diff --git a/src/lib/installation/cfa/salt.rb b/src/lib/installation/cfa/salt.rb deleted file mode 100644 index 05eb693cb..000000000 --- a/src/lib/installation/cfa/salt.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "cfa/base_model" -require "cfa/augeas_parser" -require "cfa/matcher" - -module Installation - module CFA - # Represents a Salt Minion master configuration file. - class MinionMasterConf < ::CFA::BaseModel - attributes(master: "master") - - # Configuration parser - # - # FIXME: At this time, we're using Augeas' cobblersettings lense because, - # although the file is in yaml format, it doesn't have a YAML header - # which is required by the yaml lense. - PARSER = ::CFA::AugeasParser.new("cobblersettings.lns") - # Path to configuration file - PATH = "/etc/salt/minion.d/master.conf".freeze - - # Constructor - # - # @param file_handler [.read, .write, nil] an object able to read/write a string. - def initialize(file_handler: nil) - super(PARSER, PATH, file_handler: file_handler) - end - end - end -end diff --git a/src/lib/installation/system_role_handlers/dashboard_role_finish.rb b/src/lib/installation/system_role_handlers/dashboard_role_finish.rb deleted file mode 100644 index 0e78fc3cb..000000000 --- a/src/lib/installation/system_role_handlers/dashboard_role_finish.rb +++ /dev/null @@ -1,38 +0,0 @@ -# encoding: utf-8 - -# ------------------------------------------------------------------------------ -# Copyright (c) 2017 SUSE LLC -# -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of version 2 of the GNU General Public License as published by the -# Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, contact SUSE. -# -# To contact SUSE about this file by physical or electronic mail, you may find -# current contact information at www.suse.com. -# ------------------------------------------------------------------------------ - -require "yast" -require "yast2/execute" - -module Installation - module SystemRoleHandlers - # Implement finish handler for the "dashboard" role - class DashboardRoleFinish - # Path to the activation script - ACTIVATION_SCRIPT_PATH = "/usr/share/caasp-container-manifests/activate.sh".freeze - - # Run the activation script - def run - Yast::Execute.on_target(ACTIVATION_SCRIPT_PATH) - end - end - end -end diff --git a/src/lib/installation/system_role_handlers/worker_role_finish.rb b/src/lib/installation/system_role_handlers/worker_role_finish.rb deleted file mode 100644 index 9bacaf227..000000000 --- a/src/lib/installation/system_role_handlers/worker_role_finish.rb +++ /dev/null @@ -1,49 +0,0 @@ -# encoding: utf-8 - -# ------------------------------------------------------------------------------ -# Copyright (c) 2017 SUSE LLC -# -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of version 2 of the GNU General Public License as published by the -# Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, contact SUSE. -# -# To contact SUSE about this file by physical or electronic mail, you may find -# current contact information at www.suse.com. -# ------------------------------------------------------------------------------ - -require "yast" - -module Installation - module SystemRoleHandlers - # Implement finish handler for the "worker" role - class WorkerRoleFinish - include Yast::Logger - - # Configure Salt minion - def run - role = SystemRole.find("worker_role") - master_conf = CFA::MinionMasterConf.new - master = role["controller_node"] - begin - master_conf.load - rescue Errno::ENOENT - 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}") - # 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 - end -end diff --git a/src/lib/installation/system_role_handlers_runner.rb b/src/lib/installation/system_role_handlers_runner.rb index 4c255cc40..6e01bcf1b 100644 --- a/src/lib/installation/system_role_handlers_runner.rb +++ b/src/lib/installation/system_role_handlers_runner.rb @@ -20,7 +20,6 @@ # ------------------------------------------------------------------------------ require "yast" -require "installation/cfa/salt" module Installation # Run system roles handlers @@ -36,7 +35,7 @@ def finish(role_id) return unless require_handler(role_id) class_name_role = role_id.split("_").map(&:capitalize).join - handler = "::Installation::SystemRoleHandlers::#{class_name_role}Finish" + handler = "Y2SystemRoleHandlers::#{class_name_role}Finish" if Object.const_defined?(handler) Object.const_get(handler).new.run @@ -51,7 +50,7 @@ def finish(role_id) # # @return [Boolean] True if the file was loaded; false otherwise. def require_handler(role_id) - filename = "installation/system_role_handlers/#{role_id}_finish" + filename = "y2system_role_handlers/#{role_id}_finish" require filename true rescue LoadError diff --git a/test/Makefile.am b/test/Makefile.am index aaa9522e3..35186af41 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -35,9 +35,7 @@ TESTS = \ updates_manager_test.rb \ widgets_overview_test.rb \ widgets_system_role_test.rb \ - lib/system_role_handlers_runner_test.rb \ - lib/system_role_handlers/dashboard_role_finish_test.rb \ - lib/system_role_handlers/worker_role_finish_test.rb + lib/system_role_handlers_runner_test.rb TEST_EXTENSIONS = .rb RB_LOG_COMPILER = rspec diff --git a/test/fixtures/minion.d/master.conf_existent b/test/fixtures/minion.d/master.conf_existent deleted file mode 100644 index 500fa2900..000000000 --- a/test/fixtures/minion.d/master.conf_existent +++ /dev/null @@ -1 +0,0 @@ -master: previous_controller diff --git a/test/fixtures/minion.d/master.conf_expected b/test/fixtures/minion.d/master.conf_expected deleted file mode 100644 index c383b8723..000000000 --- a/test/fixtures/minion.d/master.conf_expected +++ /dev/null @@ -1 +0,0 @@ -master: salt_controller diff --git a/test/lib/system_role_handlers/dashboard_role_finish_test.rb b/test/lib/system_role_handlers/dashboard_role_finish_test.rb deleted file mode 100755 index d685a0ed7..000000000 --- a/test/lib/system_role_handlers/dashboard_role_finish_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -#! /usr/bin/env rspec - -require_relative "../../test_helper" -require "installation/system_role_handlers/dashboard_role_finish" - -describe Installation::SystemRoleHandlers::DashboardRoleFinish do - subject(:handler) { Installation::SystemRoleHandlers::DashboardRoleFinish.new } - - describe "#run" do - it "runs the activation script" do - expect(Yast::Execute).to receive(:on_target).with(/activate.sh/) - handler.run - end - end -end diff --git a/test/lib/system_role_handlers/worker_role_finish_test.rb b/test/lib/system_role_handlers/worker_role_finish_test.rb deleted file mode 100755 index bf93f8951..000000000 --- a/test/lib/system_role_handlers/worker_role_finish_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/env rspec - -require_relative "../../test_helper" -require "installation/system_role" -require "installation/system_role_handlers/worker_role_finish" - -describe Installation::SystemRoleHandlers::WorkerRoleFinish do - subject(:handler) { described_class.new } - 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'") - handler.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") - handler.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) - - handler.run - end - end -end diff --git a/test/lib/system_role_handlers_runner_test.rb b/test/lib/system_role_handlers_runner_test.rb index 3616fdd7e..185ed9157 100755 --- a/test/lib/system_role_handlers_runner_test.rb +++ b/test/lib/system_role_handlers_runner_test.rb @@ -11,9 +11,9 @@ let(:handler) { double("HandlerInstance") } before do - stub_const("::Installation::SystemRoleHandlers::TestRoleFinish", handler_class) + stub_const("Y2SystemRoleHandlers::TestRoleFinish", handler_class) allow(handler_class).to receive(:new).and_return(handler) - allow(runner).to receive(:require).with("installation/system_role_handlers/test_role_finish") + allow(runner).to receive(:require).with("y2system_role_handlers/test_role_finish") end it "runs the handler's 'run' method" do @@ -34,7 +34,7 @@ context "when handler class is not defined" do before do - allow(runner).to receive(:require).with("installation/system_role_handlers/undefined_role_finish") + allow(runner).to receive(:require).with("y2system_role_handlers/undefined_role_finish") end it "logs the error" do