Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2017-02-04 15:18:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-network" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2017-01-23 11:26:12.672978570 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2017-02-04 16:52:31.453298541 +0100 @@ -1,0 +2,14 @@ +Thu Jan 19 15:22:03 UTC 2017 - [email protected] + +- Added network proposal using the new summary api and the new + proposal_client flag 'label_proposal' for CASP special formmating + (fate#322328). +- 3.2.19 + +------------------------------------------------------------------- +Wed Jan 18 07:54:01 UTC 2017 - [email protected] + +- Added summaries for the configured interfaces, particulary an one + line summary. (fate#322328) + +------------------------------------------------------------------- Old: ---- yast2-network-3.2.18.tar.bz2 New: ---- yast2-network-3.2.19.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.JZ9zZR/_old 2017-02-04 16:52:31.961226223 +0100 +++ /var/tmp/diff_new_pack.JZ9zZR/_new 2017-02-04 16:52:31.961226223 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.2.18 +Version: 3.2.19 Release: 0 BuildArch: noarch ++++++ yast2-network-3.2.18.tar.bz2 -> yast2-network-3.2.19.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/package/yast2-network.changes new/yast2-network-3.2.19/package/yast2-network.changes --- old/yast2-network-3.2.18/package/yast2-network.changes 2017-01-16 17:29:44.020382000 +0100 +++ new/yast2-network-3.2.19/package/yast2-network.changes 2017-01-31 09:53:13.843173433 +0100 @@ -1,4 +1,18 @@ ------------------------------------------------------------------- +Thu Jan 19 15:22:03 UTC 2017 - [email protected] + +- Added network proposal using the new summary api and the new + proposal_client flag 'label_proposal' for CASP special formmating + (fate#322328). +- 3.2.19 + +------------------------------------------------------------------- +Wed Jan 18 07:54:01 UTC 2017 - [email protected] + +- Added summaries for the configured interfaces, particulary an one + line summary. (fate#322328) + +------------------------------------------------------------------- Wed Jan 11 00:56:09 UTC 2017 - [email protected] - Fixed the assignment of udev rules to Lan Items when a previous diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/package/yast2-network.spec new/yast2-network-3.2.19/package/yast2-network.spec --- old/yast2-network-3.2.18/package/yast2-network.spec 2017-01-16 17:29:44.020382000 +0100 +++ new/yast2-network-3.2.19/package/yast2-network.spec 2017-01-31 09:53:13.843173433 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.2.18 +Version: 3.2.19 Release: 0 BuildArch: noarch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/src/clients/network_proposal.rb new/yast2-network-3.2.19/src/clients/network_proposal.rb --- old/yast2-network-3.2.18/src/clients/network_proposal.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.2.19/src/clients/network_proposal.rb 2017-01-31 09:53:13.935173433 +0100 @@ -0,0 +1,2 @@ +require "network/clients/network_proposal" +Yast::NetworkProposal.run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/src/lib/network/clients/network_proposal.rb new/yast2-network-3.2.19/src/lib/network/clients/network_proposal.rb --- old/yast2-network-3.2.18/src/lib/network/clients/network_proposal.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.2.19/src/lib/network/clients/network_proposal.rb 2017-01-31 09:53:14.063173433 +0100 @@ -0,0 +1,47 @@ +require "installation/proposal_client" + +module Yast + # Proposal client for Network configuration + class NetworkProposal < ::Installation::ProposalClient + include Yast::I18n + include Yast::Logger + + def initialize + Yast.import "UI" + Yast.import "Lan" + Yast.import "LanItems" + + textdomain "installation" + end + + def description + { + "rich_text_title" => _("Network Configuration"), + "menu_title" => _("Network Configuration"), + "id" => "network" + } + end + + def make_proposal(_) + { + "preformatted_proposal" => Yast::Lan.Summary("summary"), + "label_proposal" => [Yast::LanItems.summary("one_line")] + } + end + + def ask_user(args) + log.info "Launching network configuration" + begin + Yast::Wizard.OpenAcceptDialog + + result = Yast::WFM.CallFunction("inst_lan", [args.merge("skip_detection" => true)]) + + log.info "Returning from the network configuration with: #{result}" + ensure + Yast::Wizard.CloseDialog + end + + { "workflow_sequence" => result } + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/src/lib/network/lan_items_summary.rb new/yast2-network-3.2.19/src/lib/network/lan_items_summary.rb --- old/yast2-network-3.2.18/src/lib/network/lan_items_summary.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.2.19/src/lib/network/lan_items_summary.rb 2017-01-31 09:53:14.067173433 +0100 @@ -0,0 +1,112 @@ +# 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 Yast + # This class creates a summary of the configured lan items supporting + # different types of summaries. + class LanItemsSummary + include I18n + + def initialize + Yast.import "LanItems" + Yast.import "Summary" + end + + # Generates a summary in RichText format for the configured interfaces + # + # @example + # LanItemsSummary.new.default + # => "<ul><li><p>eth0<br>DHCP</p></li><li><p>eth1<br>NONE</p></li></ul>" + # + # @see Summary + # @return [String] summary in RichText + def default + items = [] + + LanItems.Items.each do |item, conf| + next if !Yast::LanItems.IsItemConfigured(item) + + ifcfg = LanItems.GetDeviceMap(item) || {} + items << Summary.Device(conf["ifcfg"], ifcfg_protocol(ifcfg)) + end + + return Summary.NotConfigured if items.empty? + + Summary.DevicesList(items) + end + + # Generates a one line text summary for the configured interfaces. + # + # @example with one configured interface + # LanItemsSummary.new.one_line + # => "DHCP / eth1" + # + # @example with many configured interfaces + # LanItemsSummary.new.one_line + # => "Multiple Interfaces" + # + # @return [String] summary in just one line and in plain text + def one_line + protocols = [] + configured = [] + output = [] + + Yast::LanItems.Items.each do |item, conf| + next if !LanItems.IsItemConfigured(item) + + ifcfg = LanItems.GetDeviceMap(item) || {} + protocols << ifcfg_protocol(ifcfg) + + configured << conf["ifcfg"] + end + + output << protocols.first if protocols.uniq.size == 1 + + case configured.size + when 0 + return Summary.NotConfigured + when 1 + output << configured.join(", ") + else + # TRANSLATORS: informs that multiple interfaces are configured + output << _("Multiple Interfaces") + end + + output.join(" / ") + end + + private + + def ifcfg_protocol(ifcfg) + protocol = LanItems.DeviceProtocol(ifcfg) + + if protocol =~ /DHCP/ + "DHCP" + elsif IP.Check(protocol) + "STATIC" + else + LanItems.DeviceProtocol(ifcfg) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/src/modules/LanItems.rb new/yast2-network-3.2.19/src/modules/LanItems.rb --- old/yast2-network-3.2.18/src/modules/LanItems.rb 2017-01-16 17:29:44.200382000 +0100 +++ new/yast2-network-3.2.19/src/modules/LanItems.rb 2017-01-31 09:53:14.091173433 +0100 @@ -25,6 +25,7 @@ require "yaml" require "network/install_inf_convertor" require "network/wicked" +require "network/lan_items_summary" module Yast # Does way too many things. @@ -1366,6 +1367,17 @@ [startmode_descr] end + # Creates a summary of the configured items. + # + # It supports differents types of summaries depending on the options[:type] + # + # @see LanItemsSummary + # @param options [Hash] summary options + # @return [String] summary of the configured items + def summary(type = "default") + LanItemsSummary.new.send(type) + end + # Creates details for device's overview based on ip configuration type # # Produces list of strings. Strings are intended for "bullet" list, e.g.: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/test/lan_items_summary_test.rb new/yast2-network-3.2.19/test/lan_items_summary_test.rb --- old/yast2-network-3.2.18/test/lan_items_summary_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.2.19/test/lan_items_summary_test.rb 2017-01-31 09:53:14.215173433 +0100 @@ -0,0 +1,92 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" +require "network/lan_items_summary" + +Yast.import "LanItems" + +describe Yast::LanItemsSummary do + MULTIPLE_INTERFACES = N_("Multiple Interfaces") + + let(:dhcp_maps) do + [ + { "BOOTPROTO" => "dhcp" }, + { "BOOTPROTO" => "none" }, + { "IPADDR" => "1.2.3.4", "NETMASK" => "255.255.255.0" } + ].freeze + end + + let(:items) do + { + 0 => { "ifcfg" => "eth0" }, + 1 => { "ifcfg" => "eth1" }, + 2 => { "ifcfg" => "br0" } + }.freeze + end + + before do + allow(Yast::LanItems).to receive(:Items).and_return(items) + allow(Yast::LanItems).to receive(:IsItemConfigured).and_return(true) + dhcp_maps.each_with_index do |item, index| + allow(Yast::LanItems).to receive(:GetDeviceMap).with(index).and_return(item) + end + end + + describe "#default" do + it "returns a Richtext summary of the configured interfaces" do + expect(subject.default) + .to eql "<ul>" \ + "<li><p>eth0<br>DHCP</p></li>" \ + "<li><p>eth1<br>NONE</p></li>" \ + "<li><p>br0<br>STATIC</p></li>" \ + "</ul>" + end + + it "returns Summary.NotConfigured in case of not configured interfaces" do + allow(Yast::LanItems).to receive(:IsItemConfigured).and_return(false) + + expect(subject.default).to eql Yast::Summary.NotConfigured + end + end + + describe "#one_line" do + it "returns a plain text summary of the configured interfaces in one line" do + expect(subject.one_line).to eql(MULTIPLE_INTERFACES) + end + + context "when there are no configured interfaces" do + let(:items) { {} } + it "returns Summary.NotConfigured" do + expect(subject.one_line).to eql(Yast::Summary.NotConfigured) + end + end + + context "when there is only one configured interface" do + let(:items) { { 0 => { "ifcfg" => "eth0" } } } + + it "returns the interface bootproto and interface name" do + expect(subject.one_line).to eql "DHCP / eth0" + end + end + + context "when there are multiple interfaces" do + let(:items) { { 0 => { "ifcfg" => "eth0" }, 1 => { "ifcfg" => "eth1" } } } + + context "sharing the same bootproto" do + let(:dhcp_maps) { [{ "BOOTPROTO" => "dhcp" }, { "BOOTPROTO" => "dhcp" }] } + + it "returns the bootproto and 'Multiple Interfaces'" do + expect(subject.one_line).to eql("DHCP / #{MULTIPLE_INTERFACES}") + end + end + + context "with different bootproto" do + let(:dhcp_maps) { [{ "BOOTPROTO" => "DHCP" }, { "IPADDR" => "1.2.3.4" }] } + + it "returns 'Multiple Interfaces'" do + expect(subject.one_line).to eql(MULTIPLE_INTERFACES) + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/test/network_proposal_test.rb new/yast2-network-3.2.19/test/network_proposal_test.rb --- old/yast2-network-3.2.18/test/network_proposal_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.2.19/test/network_proposal_test.rb 2017-01-31 09:53:14.227173433 +0100 @@ -0,0 +1,45 @@ +require_relative "test_helper" + +require "network/clients/network_proposal" + +describe Yast::NetworkProposal do + Yast.import "LanItems" + Yast.import "Lan" + + before do + stub_const("Yast::Wizard", double.as_null_object) + allow(Yast::LanItems).to receive(:summary).with("one_line").and_return("one_line_summary") + allow(Yast::Lan).to receive(:Summary).with("summary").and_return(["rich_text_summary"]) + end + + describe "#description" do + it "returns a map with id, menu_title and rich_text_title " do + expect(subject.description).to include("id", "menu_title", "rich_text_title") + end + end + + describe "#make_proposal" do + it "returns a map with 'label_proposal' as an array with one line summary'" do + expect(subject.make_proposal({})["label_proposal"]).to eql(["one_line_summary"]) + end + + it "returns a map with 'preformatted_proposal' as an array with the network summary'" do + expect(subject.make_proposal({})["preformatted_proposal"]).to eql(["rich_text_summary"]) + end + end + + describe "#ask_user" do + it "launchs the inst_lan client forcing the manual configuration" do + expect(Yast::WFM).to receive(:CallFunction).with("inst_lan", [{ "skip_detection" => true }]) + subject.ask_user({}) + end + + it "returns a map with 'workflow_sequence' as the result of the client output" do + allow(Yast::WFM).to receive(:CallFunction) + .with("inst_lan", [{ "skip_detection" => true }]) + .and_return("result") + + expect(subject.ask_user({})).to eql("workflow_sequence" => "result") + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.2.18/test/test_helper.rb new/yast2-network-3.2.19/test/test_helper.rb --- old/yast2-network-3.2.18/test/test_helper.rb 2017-01-16 17:29:44.328382000 +0100 +++ new/yast2-network-3.2.19/test/test_helper.rb 2017-01-31 09:53:14.231173433 +0100 @@ -5,9 +5,14 @@ require "yast" require "yast/rspec" +# Ensure the tests runs with english locales +ENV["LC_ALL"] = "en_US.UTF-8" + require_relative "SCRStub" RSpec.configure do |c| + c.extend Yast::I18n # available in context/describe + c.include Yast::I18n c.include SCRStub end
