commit yast2-services-manager for openSUSE:Factory
Hello community, here is the log from the commit of package yast2-services-manager for openSUSE:Factory checked in at 2014-04-26 11:44:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-services-manager (Old) and /work/SRC/openSUSE:Factory/.yast2-services-manager.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-services-manager" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-services-manager/yast2-services-manager.changes 2014-03-21 12:14:17.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-services-manager.new/yast2-services-manager.changes 2014-04-26 11:44:52.000000000 +0200 @@ -1,0 +2,7 @@ +Thu Apr 10 14:31:57 UTC 2014 - vmoravec@suse.com + +- Add support for legacy runlevel autoyast profile and improve + profile specifications (bnc#865347) +- 3.1.12 + +------------------------------------------------------------------- Old: ---- yast2-services-manager-3.1.11.tar.bz2 New: ---- yast2-services-manager-3.1.12.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-services-manager.spec ++++++ --- /var/tmp/diff_new_pack.2bLswL/_old 2014-04-26 11:44:52.000000000 +0200 +++ /var/tmp/diff_new_pack.2bLswL/_new 2014-04-26 11:44:52.000000000 +0200 @@ -24,8 +24,9 @@ ###################################################################### Name: yast2-services-manager -Version: 3.1.11 +Version: 3.1.12 Release: 0 + BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -38,6 +39,7 @@ Conflicts: yast2-installation < 3.1.32 Obsoletes: yast2-runlevel +Conflicts: yast2-runlevel BuildRequires: ruby BuildRequires: update-desktop-files @@ -82,6 +84,7 @@ %dir %{yast_dir}/lib/ %{yast_dir}/lib/services-manager/ %{_prefix}/share/applications/YaST2/services-manager.desktop +%{_prefix}/share/applications/YaST2/runlevel.desktop %dir %_docdir/ %_docdir/%name/ ++++++ yast2-services-manager-3.1.11.tar.bz2 -> yast2-services-manager-3.1.12.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/README.md new/yast2-services-manager-3.1.12/README.md --- old/yast2-services-manager-3.1.11/README.md 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/README.md 2014-04-14 13:07:39.000000000 +0200 @@ -2,8 +2,59 @@ Systemd target and services configuration library for Yast -Running -======= +## Autoyast profile - sudo yast2 services-manager +### Current profile for services and default target + +```xml +<services-manager> + <default_target>multi-user</default_target> + <services> + <enable config:type="list"> + <service>postfix</service> + <service>rsyslog</service> + <service>sshd</service> + </enable> + <disable config:type="list"> + <service>libvirtd</service> + </disable> + </services> + </services-manager> +``` +### Legacy runlevel profile [DEPRECATED] + +```xml +<runlevel> + <default>3</default> + <services config:type="list"> + <service> + <service_name>sshd</service_name> + <service_status>enable</service_status> + <service_start>3</service_start> + </service> + </services> +</runlevel> +``` + +### Legacy list of services [DEPRECATED] + +```xml + <services-manager> + <default_target>multi-user</default_target> + <services config:type="list"> + <service>cron</service> + <service>postfix</service> + <service>rsyslog</service> + <service>sshd</service> + </services> + </services-manager> +``` + +## Running + +`sudo yast services-manager` + +or + +`sudo yast services` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/package/yast2-services-manager.changes new/yast2-services-manager-3.1.12/package/yast2-services-manager.changes --- old/yast2-services-manager-3.1.11/package/yast2-services-manager.changes 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/package/yast2-services-manager.changes 2014-04-14 13:07:39.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Apr 10 14:31:57 UTC 2014 - vmoravec@suse.com + +- Add support for legacy runlevel autoyast profile and improve + profile specifications (bnc#865347) +- 3.1.12 + +------------------------------------------------------------------- Tue Mar 18 13:37:40 UTC 2014 - vmoravec@suse.com - Do not crash installation with empty services list (bnc#868614) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/package/yast2-services-manager.spec new/yast2-services-manager-3.1.12/package/yast2-services-manager.spec --- old/yast2-services-manager-3.1.11/package/yast2-services-manager.spec 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/package/yast2-services-manager.spec 2014-04-14 13:07:39.000000000 +0200 @@ -24,7 +24,8 @@ ###################################################################### Name: yast2-services-manager -Version: 3.1.11 +Version: 3.1.12 + Release: 0 BuildArch: noarch @@ -38,6 +39,7 @@ Conflicts: yast2-installation < 3.1.32 Obsoletes: yast2-runlevel +Conflicts: yast2-runlevel BuildRequires: ruby BuildRequires: update-desktop-files @@ -82,6 +84,7 @@ %dir %{yast_dir}/lib/ %{yast_dir}/lib/services-manager/ %{_prefix}/share/applications/YaST2/services-manager.desktop +%{_prefix}/share/applications/YaST2/runlevel.desktop %dir %_docdir/ %_docdir/%name/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/src/autoyast_rnc/services-manager.rnc new/yast2-services-manager-3.1.12/src/autoyast_rnc/services-manager.rnc --- old/yast2-services-manager-3.1.11/src/autoyast_rnc/services-manager.rnc 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/src/autoyast_rnc/services-manager.rnc 2014-04-14 13:07:39.000000000 +0200 @@ -2,15 +2,57 @@ namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" namespace config = "http://www.suse.com/1.0/configns" +# runlevel legacy schema + +runlevel_service_name = element service_name { text } +runlevel_service_status = element service_status { text } +runlevel_service_start = element service_start { text } +runlevel_service_stop = element service_stop { text } + +runlevel_service = + element service { + attribute config:type { text }? & + runlevel_service_name? & + runlevel_service_start? & + runlevel_service_stop? & + runlevel_service_status? + } + +runlevel_services = + element services { + attribute config:type { "list" }?, + runlevel_service* + } + +runlevel_default = element \default { text } + +runlevel_content = element runlevel { runlevel_default? & runlevel_services? } + +# current services-manager schema + service = element service { text } -services = element services { - attribute config:type { text }?, - service* -} +enabled = + element enabled { + attribute config:type { text }? & + service* + } + +disabled = + element disabled { + attribute config:type { text }? & + service* + } + +services = + element services { attribute config:type { text }? & enabled } | + element services { attribute config:type { text }? & disabled } | + element services { attribute config:type { text }? & service* } default_target = element default_target { text } -services-manager = element services-manager { - default_target? & services? -} +services_manager_content = default_target? & services? + +services-manager = + element services-manager { services_manager_content } | + element runlevel { runlevel_content } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/src/desktop/runlevel.desktop new/yast2-services-manager-3.1.12/src/desktop/runlevel.desktop --- old/yast2-services-manager-3.1.11/src/desktop/runlevel.desktop 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-services-manager-3.1.12/src/desktop/runlevel.desktop 2014-04-14 13:07:39.000000000 +0200 @@ -0,0 +1,23 @@ +[Desktop Entry] +Type=Application +Categories=Settings;System;Qt;X-SuSE-YaST;X-SuSE-YaST-System; + +X-KDE-ModuleType=Library +X-KDE-HasReadOnlyMode=true +X-KDE-Library=yast2 +X-SuSE-YaST-Call=services-manager +X-SuSE-YaST-AutoInstClient=services-manager_auto + +X-SuSE-YaST-Group=System +X-SuSE-YaST-Argument= +X-SuSE-YaST-RootOnly=true +X-SuSE-YaST-AutoInst=all +X-SuSE-YaST-Geometry= +X-SuSE-YaST-SortKey= + +Icon=yast-runlevel +Exec=xdg-su -c "/sbin/yast2 services-manager" + +Name=Services Manager +GenericName=Configure running services and the default target +StartupNotify=true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/src/lib/services-manager/services_manager_profile.rb new/yast2-services-manager-3.1.12/src/lib/services-manager/services_manager_profile.rb --- old/yast2-services-manager-3.1.11/src/lib/services-manager/services_manager_profile.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-services-manager-3.1.12/src/lib/services-manager/services_manager_profile.rb 2014-04-14 13:07:39.000000000 +0200 @@ -0,0 +1,155 @@ +module Yast + import "Report" + + ### Supported profiles + # + # @example Extended profile with list of services to be enabled and disabled + # + # <services-manager> + # <default_target>multi-user</default_target> + # <services> + # <enable config:type="list"> + # <service>at</service> + # <service>cron</service> + # <service>nscd</service> + # <service>openct</service> + # <service>postfix</service> + # <service>rsyslog</service> + # <service>sshd</service> + # </enable> + # <disable config:type="list"> + # <service>libvirtd</service> + # </disable> + # </services> + # </services-manager> + # + # @deprecated Legacy profile with incomplete support for services + # @example Simple list of services + # Supported are only services to be enabled. This profile is missing + # services which are going to be disabled. + # + # <services-manager> + # <default_target>multi-user</default_target> + # <services config:type="list"> + # <service>cron</service> + # <service>postfix</service> + # <service>sshd</service> + # </services> + # </services-manager> + # + # @deprecated Legacy runlevel profile + # @example Runlevel profle + # + # <runlevel> + # <default>3</default> + # <services config:type="list"> + # <service> + # <service_name>sshd</service_name> + # <service_status>enable</service_status> + # <service_start>3</service_start> + # </service> + # </services> + # </runlevel> + # + ### + + class ServicesManagerProfile + include Yast::Logger + + ENABLE = 'enable' + DISABLE = 'disable' + + # Service object with two attributes: + # @attr [String] name of the service unit. Suffix '.service' is optional. + # @attr [String] required status on the target system. Can be 'enable' or 'disable'. + Service = Struct.new(:name, :status) + + # Profile data passed from autoyast, a Hash expected + # @return [Hash] + attr_reader :autoyast_profile + + # List of Service structs + # @return [Array<Service>] + attr_reader :services + + # Name of the systemd default target unit. Suffix '.target' is optional. + # @return [String] if the target has been specified in the profile. Can be nil. + attr_reader :target + + def initialize autoyast_profile + @autoyast_profile = autoyast_profile + @services = [] + extract_services + extract_target + end + + private + + def extract_services + services = autoyast_profile['services'] + return if services.nil? || services.empty? + + if services.all? {|item| item.is_a?(::String) } + load_from_simple_list(services) + elsif services.is_a?(Hash) && ( services.key?(ENABLE) || services.key?(DISABLE)) + load_from_extended_list(services) + elsif services.all? {|i| i.is_a?(Hash) && (i.key?('service_name') || i.key?('service_status')) } + load_from_runlevel_list(services) + else + Yast::Report.Error _("Unknown autoyast services profile schema for 'services-manager'") + return + end + log.info "Extracted services from autoyast profile: #{self.services}" + end + + def extract_target + if autoyast_profile.key?('default_target') + @target = autoyast_profile['default_target'] + elsif autoyast_profile.key?('default') + @target = case autoyast_profile['default'] + when "2", "3", "4" + "multi-user" + when "5" + "graphical" + when "0" + log.error "You can't set the default target to 'poweroff' in autoyast profile" + nil + when "1" + log.error "You can't set the default target to 'rescue' in autoyast profile" + nil + else + log.error "Target '#{autoyast_profile['default']}' is not valid" + nil + end + end + end + + def load_from_simple_list services + self.services.concat( + services.map {|service_name| Service.new(service_name, ENABLE)} + ) + end + + def load_from_runlevel_list services + self.services.concat( + services.map do |service| + Service.new(service['service_name'], service['service_status']) + end + ) + end + + def load_from_extended_list services + self.services.concat( + services.fetch(ENABLE, []).map do |service_name| + Service.new(service_name, ENABLE) + end + ) + + self.services.concat( + services.fetch(DISABLE, []).map do |service_name| + Service.new(service_name, DISABLE) + end + ) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/src/modules/services_manager.rb new/yast2-services-manager-3.1.12/src/modules/services_manager.rb --- old/yast2-services-manager-3.1.11/src/modules/services_manager.rb 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/src/modules/services_manager.rb 2014-04-14 13:07:39.000000000 +0200 @@ -1,4 +1,5 @@ require 'yast' +require 'services-manager/services_manager_profile' module Yast import "ServicesManagerTarget" @@ -23,8 +24,9 @@ end def import data - ServicesManagerTarget.import data[TARGET] - ServicesManagerService.import data[SERVICES] + profile = ServicesManagerProfile.new(data) + ServicesManagerTarget.import(profile) + ServicesManagerService.import(profile) end def reset diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/src/modules/services_manager_service.rb new/yast2-services-manager-3.1.12/src/modules/services_manager_service.rb --- old/yast2-services-manager-3.1.11/src/modules/services_manager_service.rb 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/src/modules/services_manager_service.rb 2014-04-14 13:07:39.000000000 +0200 @@ -233,23 +233,23 @@ exported_services.keys end - def import imported_services=[] - if imported_services.nil? || imported_services.empty? - Builtins.y2error("No services for import provided.") - return false - end - Builtins.y2milestone("Imported services: #{imported_services}") + def import profile + Builtins.y2milestone("List of services from autoyast profile: #{profile.services.map(&:name)}") non_existent_services = [] - # All imported will be enabled - imported_services.each do |service| - if exists?(service) - enable(service) + profile.services.each do |service| + case service.status + when 'enable' + exists?(service.name) ? enable(service.name) : non_existent_services << service.name + when 'disable' + exists?(service.name) ? disable(service.name) : non_existent_services << service.name else - non_existent_services << service - Builtins.y2error("Service '#{service}' doesn't exist on this system") + Builtins.y2error("Unknown status '#{service.status}' for service '#{service.name}'") end end - non_existent_services.empty? + return true if non_existent_services.empty? + + Builtins.y2error("Services #{non_existent_services.inspect} don't exist on this system") + false end # Saves the current configuration in memory diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/src/modules/services_manager_target.rb new/yast2-services-manager-3.1.12/src/modules/services_manager_target.rb --- old/yast2-services-manager-3.1.11/src/modules/services_manager_target.rb 2014-03-18 14:51:41.000000000 +0100 +++ new/yast2-services-manager-3.1.12/src/modules/services_manager_target.rb 2014-04-14 13:07:39.000000000 +0200 @@ -65,12 +65,9 @@ default_target end - def import new_target - if new_target.to_s.empty? - Builtins.y2error("New default target not provided") - return - end - self.default_target = new_target + def import profile + return false if profile.target.nil? || profile.target.empty? + self.default_target = profile.target end def inspect diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-services-manager-3.1.11/test/services_manager_profile_test.rb new/yast2-services-manager-3.1.12/test/services_manager_profile_test.rb --- old/yast2-services-manager-3.1.11/test/services_manager_profile_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-services-manager-3.1.12/test/services_manager_profile_test.rb 2014-04-14 13:07:39.000000000 +0200 @@ -0,0 +1,142 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" + +require 'services-manager/services_manager_profile' + +module Yast + describe ServicesManagerProfile do + attr_reader :profile, :autoyast_profile + + context "legacy runlevel autoyast profile" do + before do + @autoyast_profile = { + 'default' => '3', + 'services' => [ + { + 'service_name' => 'sshd', + 'service_status' => 'enable', + 'service_start' => '3' + }, + { + 'service_name' => 'libvirt', + 'service_status' => 'disable', + 'service_start' => '5' + }, + ] + } + @profile = ServicesManagerProfile.new(autoyast_profile) + end + + it "returns profile object with services collection" do + expect(profile.services).not_to be_empty + expect(profile.services.size).to eq(2) + end + + it "provides the original data from autoyast" do + expect(profile.autoyast_profile).to equal(autoyast_profile) + end + + it "provides collection of services to be enabled" do + service = profile.services.find {|s| s.name == 'sshd'} + expect(service).not_to be_nil + expect(service.status).to eq('enable') + end + + it "provides collection of services to be disabled" do + service = profile.services.find {|s| s.name == 'libvirt'} + expect(service).not_to be_nil + expect(service.status).to eq('disable') + end + + it "provides default target" do + expect(profile.target).not_to be_empty + expect(profile.target).to eq('multi-user') + end + end + + context "simplified services profile" do + before do + @autoyast_profile = { + 'default_target'=>'graphical', + 'services' => [ 'sshd', 'iscsi' ] + } + @profile = ServicesManagerProfile.new(autoyast_profile) + end + + it "returns profile object that provides services collection" do + expect(profile.services).not_to be_empty + expect(profile.services.size).to eq(2) + end + + it "provides the original data from autoyast" do + expect(profile.autoyast_profile).to equal(autoyast_profile) + end + + it "provides collection of services to be enabled" do + service = profile.services.find {|s| s.name == 'sshd'} + expect(service).not_to be_nil + expect(service.status).to eq('enable') + end + + it "provides default target" do + expect(profile.target).not_to be_empty + expect(profile.target).to eq('graphical') + end + end + + context "extended services autoyast profile" do + before do + @autoyast_profile = { + 'default_target' => 'multi-user', + 'services' => { + 'enable' => ['sshd', 'iscsi' ], + 'disable' => ['nginx', 'libvirt'] + } + } + @profile = ServicesManagerProfile.new(autoyast_profile) + end + + it "returns profile object that provides services collection" do + expect(profile.services).not_to be_empty + expect(profile.services.size).to eq(4) + end + + it "provides the original data from autoyast" do + expect(profile.autoyast_profile).to equal(autoyast_profile) + end + + it "provides collection of services to be disabled" do + service = profile.services.find {|s| s.name == 'nginx'} + expect(service).not_to be_nil + expect(service.status).to eq('disable') + end + + it "provides collection of services to be enabled" do + service = profile.services.find {|s| s.name == 'sshd'} + expect(service).not_to be_nil + expect(service.status).to eq('enable') + end + + it "provides default target" do + expect(profile.target).not_to be_empty + expect(profile.target).to eq('multi-user') + end + end + + context "missing services and target entries in profile" do + before do + @autoyast_profile = {} + @profile = ServicesManagerProfile.new(autoyast_profile) + end + + it "provides not target information" do + expect(profile.target).to be_nil + end + + it "provides empty list of services" do + expect(profile.services).to be_empty + end + end + end +end -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de