Hello community,

here is the log from the commit of package yast2-network for openSUSE:Factory 
checked in at 2020-12-15 12:30:38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-network (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-network.new.2328 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-network"

Tue Dec 15 12:30:38 2020 rev:440 rq:855743 version:4.3.34

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes      
2020-12-12 20:29:49.589693165 +0100
+++ /work/SRC/openSUSE:Factory/.yast2-network.new.2328/yast2-network.changes    
2020-12-15 12:32:53.420121453 +0100
@@ -1,0 +2,15 @@
+Mon Dec 14 09:36:40 UTC 2020 - Knut Anderssen <kanders...@suse.com>
+
+- Write also connections in case that the hostname mapped to a
+  connection primary IP address is changed through the DNS
+  standalone client (bsc#1174431)
+- 4.3.34
+
+-------------------------------------------------------------------
+Mon Dec 14 08:27:46 UTC 2020 - Knut Anderssen <kanders...@suse.com>
+
+- Allow to modify the hostname mapped to a connection primary IP
+  address when the associated hostname is modified (bsc#1174431)
+- 4.3.33
+
+-------------------------------------------------------------------
@@ -10566 +10580,0 @@
-

Old:
----
  yast2-network-4.3.32.tar.bz2

New:
----
  yast2-network-4.3.34.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-network.spec ++++++
--- /var/tmp/diff_new_pack.HJiGfR/_old  2020-12-15 12:32:54.188122072 +0100
+++ /var/tmp/diff_new_pack.HJiGfR/_new  2020-12-15 12:32:54.192122075 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-network
-Version:        4.3.32
+Version:        4.3.34
 Release:        0
 Summary:        YaST2 - Network Configuration
 License:        GPL-2.0-only

++++++ yast2-network-4.3.32.tar.bz2 -> yast2-network-4.3.34.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-network-4.3.32/package/yast2-network.changes 
new/yast2-network-4.3.34/package/yast2-network.changes
--- old/yast2-network-4.3.32/package/yast2-network.changes      2020-12-10 
16:33:41.000000000 +0100
+++ new/yast2-network-4.3.34/package/yast2-network.changes      2020-12-14 
13:02:50.000000000 +0100
@@ -1,4 +1,19 @@
 -------------------------------------------------------------------
+Mon Dec 14 09:36:40 UTC 2020 - Knut Anderssen <kanders...@suse.com>
+
+- Write also connections in case that the hostname mapped to a
+  connection primary IP address is changed through the DNS
+  standalone client (bsc#1174431)
+- 4.3.34
+
+-------------------------------------------------------------------
+Mon Dec 14 08:27:46 UTC 2020 - Knut Anderssen <kanders...@suse.com>
+
+- Allow to modify the hostname mapped to a connection primary IP
+  address when the associated hostname is modified (bsc#1174431)
+- 4.3.33
+
+-------------------------------------------------------------------
 Thu Dec 10 10:43:48 UTC 2020 - Knut Anderssen <kanders...@suse.com>
 
 - Fix bonding slaves sorting (bsc#1178950)
@@ -10563,4 +10578,3 @@
 Fri May 19 09:44:08 CEST 2000 - kkae...@suse.de
 
 - initial version
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-network-4.3.32/package/yast2-network.spec 
new/yast2-network-4.3.34/package/yast2-network.spec
--- old/yast2-network-4.3.32/package/yast2-network.spec 2020-12-10 
16:33:41.000000000 +0100
+++ new/yast2-network-4.3.34/package/yast2-network.spec 2020-12-14 
13:02:50.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-network
-Version:        4.3.32
+Version:        4.3.34
 Release:        0
 Summary:        YaST2 - Network Configuration
 License:        GPL-2.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/include/network/services/dns.rb 
new/yast2-network-4.3.34/src/include/network/services/dns.rb
--- old/yast2-network-4.3.32/src/include/network/services/dns.rb        
2020-12-10 16:33:41.000000000 +0100
+++ new/yast2-network-4.3.34/src/include/network/services/dns.rb        
2020-12-14 13:02:50.000000000 +0100
@@ -20,8 +20,13 @@
 #
 # **************************************************************************
 
+require "ui/text_helpers"
+require "y2network/dialogs/update_hostname_hosts"
+
 module Yast
   module NetworkServicesDnsInclude
+    include ::UI::TextHelpers
+
     # CWM wants id-value pairs
     CUSTOM_RESOLV_POLICIES = {
       "STATIC"          => "STATIC",
@@ -260,7 +265,7 @@
     # @param value [String]
     # @return [String] stored hostname
     def store_hostname(value)
-      hostname = Yast::Lan.yast_config.hostname
+      hostname = config.hostname
       hostname.static = value
       hostname.installer = value if Stage.initial
 
@@ -280,7 +285,9 @@
         " ,\n\t"
       )
 
-      store_hostname(settings["HOSTNAME"] || "")
+      hostname = settings["HOSTNAME"] || ""
+      update_hostname_hosts(hostname)
+      store_hostname(hostname)
 
       valid_nameservers = NonEmpty(nameservers).each_with_object([]) do 
|ip_str, all|
         all << IPAddr.new(ip_str) if IP.Check(ip_str)
@@ -292,6 +299,26 @@
       nil
     end
 
+    def current_hostname
+      config&.hostname&.static || ""
+    end
+
+    def update_hostname_hosts(hostname)
+      return false if hostname == current_hostname
+      return false if current_hostname.empty?
+
+      conn = config.connections.find { |c| 
c.hostnames&.include?(current_hostname) }
+
+      update_hostname = conn && Popup.YesNo(
+        wrap_text(
+          format(_("The interface '%s' static IP address is mapped to the 
hostname '%s'.\n\n" \
+                "Would you like to adapt it now?"), conn.name, 
current_hostname)
+        )
+      )
+
+      Y2Network::Dialogs::UpdateHostnameHosts.new(conn).run if update_hostname
+    end
+
     # Stores actual hostname settings.
     def StoreHnSettings
       StoreSettings(@hn_settings)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/clients/dns.rb 
new/yast2-network-4.3.34/src/lib/y2network/clients/dns.rb
--- old/yast2-network-4.3.32/src/lib/y2network/clients/dns.rb   2020-12-10 
16:33:41.000000000 +0100
+++ new/yast2-network-4.3.34/src/lib/y2network/clients/dns.rb   2020-12-14 
13:02:50.000000000 +0100
@@ -276,7 +276,7 @@
       end
 
       def write_config
-        Yast::Lan.write_config(only: [:dns, :hostname])
+        Yast::Lan.write_config(only: [:dns, :hostname, :connections])
       end
     end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/connection_config/base.rb 
new/yast2-network-4.3.34/src/lib/y2network/connection_config/base.rb
--- old/yast2-network-4.3.32/src/lib/y2network/connection_config/base.rb        
2020-12-10 16:33:41.000000000 +0100
+++ new/yast2-network-4.3.34/src/lib/y2network/connection_config/base.rb        
2020-12-14 13:02:50.000000000 +0100
@@ -68,8 +68,8 @@
       attr_accessor :ethtool_options
       # @return [String] assigned firewall zone to interface
       attr_accessor :firewall_zone
-      # @return [String] interface's hostname
-      attr_accessor :hostname
+      # @return [Array<String>] interface's hostnames
+      attr_accessor :hostnames
       # @return [Boolean, nil] set to true if dhcp from this interface sets 
machine hostname,
       #   false if not and nil if not specified
       attr_accessor :dhclient_set_hostname
@@ -91,6 +91,7 @@
         @description = ""
         @ethtool_options = ""
         @firewall_zone = ""
+        @hostnames = []
       end
 
       # Compares ConnectionConfigs
@@ -204,6 +205,25 @@
         bootproto ? bootproto.static? : true
       end
 
+      # Return the first hostname associated with the primary IP address.
+      #
+      # @return [String, nil] returns the hostname associated with the primary
+      #   IP address or nil
+      def hostname
+        hostnames&.first
+      end
+
+      # Convenience method in order to modify the canonical hostname mapped to
+      # the primary IP address.
+      #
+      # @param hname [String, nil] hostnamme mapped to the primary IP address
+      def hostname=(hname)
+        short_name = hname&.split(".")&.first
+
+        @hostnames = [hname, short_name].uniq.compact
+        log.info("Assigned hostnames #{@hostnames.inspect} to connection 
#{name}")
+      end
+
     private
 
       def replace_ifplugd?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/dialogs/update_hostname_hosts.rb 
new/yast2-network-4.3.34/src/lib/y2network/dialogs/update_hostname_hosts.rb
--- old/yast2-network-4.3.32/src/lib/y2network/dialogs/update_hostname_hosts.rb 
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-network-4.3.34/src/lib/y2network/dialogs/update_hostname_hosts.rb 
2020-12-14 13:02:50.000000000 +0100
@@ -0,0 +1,71 @@
+# Copyright (c) [2020] SUSE LLC
+#
+# All Rights Reserved.
+#
+# 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 LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require "cwm/popup"
+require "y2network/widgets/hostname"
+
+module Y2Network
+  module Dialogs
+    # A popup dialog which permits to modify the hostname mapped to the given
+    # connection primary IP address
+    class UpdateHostnameHosts < CWM::Popup
+      def initialize(connection)
+        textdomain "network"
+
+        @connection = connection
+      end
+
+      def title
+        format(_("Edit '%s' hostname"), @connection.name)
+      end
+
+      def contents
+        VBox(
+          Left(Label(_("IP Address"))),
+          Left(Label(ip_address)),
+          VSpacing(0.5),
+          hostname_widget,
+          VSpacing(0.5)
+        )
+      end
+
+      def buttons
+        [ok_button, cancel_button]
+      end
+
+      def ok_button_label
+        Yast::Label.ModifyButton
+      end
+
+      def min_height
+        8
+      end
+
+      def ip_address
+        @connection&.ip&.address&.address&.to_s
+      end
+
+    private
+
+      def hostname_widget
+        @hostname_widget ||= Widgets::Hostname.new(@connection)
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/interface_config_builders/bridge.rb 
new/yast2-network-4.3.34/src/lib/y2network/interface_config_builders/bridge.rb
--- 
old/yast2-network-4.3.32/src/lib/y2network/interface_config_builders/bridge.rb  
    2020-12-10 16:33:41.000000000 +0100
+++ 
new/yast2-network-4.3.34/src/lib/y2network/interface_config_builders/bridge.rb  
    2020-12-14 13:02:50.000000000 +0100
@@ -70,7 +70,7 @@
 
       def configure_from(connection)
         [:bootproto, :ip, :ip_aliases, :startmode, :description,
-         :firewall_zone, :hostname].all? do |method|
+         :firewall_zone, :hostnames].all? do |method|
           @connection_config.public_send("#{method}=", 
connection.public_send(method))
         end
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/sysconfig/connection_config_readers/base.rb
 
new/yast2-network-4.3.34/src/lib/y2network/sysconfig/connection_config_readers/base.rb
--- 
old/yast2-network-4.3.32/src/lib/y2network/sysconfig/connection_config_readers/base.rb
      2020-12-10 16:33:41.000000000 +0100
+++ 
new/yast2-network-4.3.34/src/lib/y2network/sysconfig/connection_config_readers/base.rb
      2020-12-14 13:02:50.000000000 +0100
@@ -61,7 +61,7 @@
             if file.dhclient_set_hostname
               conn.dhclient_set_hostname = file.dhclient_set_hostname == "yes"
             end
-            conn.hostname = hostname(conn)
+            conn.hostnames = hostnames(conn)
             conn.mtu = file.mtu
 
             update_connection_config(conn)
@@ -122,16 +122,15 @@
           ipaddr
         end
 
-        # Returns the hostname for the given connection
+        # Returns the hostnames for the given connection
         #
-        # @return [String,nil]
-        def hostname(conn)
-          return nil unless conn.ip
+        # @return [Array<String>]
+        def hostnames(conn)
+          return [] unless conn.ip
 
           Yast::Host.Read
           aliases = Yast::Host.names(conn.ip.address.address.to_s).first
-          # Use the fqdn when defined
-          aliases.to_s.split(" ").first
+          aliases.to_s.split(" ")
         end
       end
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/sysconfig/connection_config_writers/base.rb
 
new/yast2-network-4.3.34/src/lib/y2network/sysconfig/connection_config_writers/base.rb
--- 
old/yast2-network-4.3.32/src/lib/y2network/sysconfig/connection_config_writers/base.rb
      2020-12-10 16:33:41.000000000 +0100
+++ 
new/yast2-network-4.3.34/src/lib/y2network/sysconfig/connection_config_writers/base.rb
      2020-12-14 13:02:50.000000000 +0100
@@ -100,7 +100,8 @@
         #
         # @param conn [Y2Network::ConnectionConfig::Base] Connection to take 
settings from
         def add_hostname(conn)
-          return unless conn.hostname && conn.ip
+          return unless conn.hostnames && conn.ip
+          return if conn.hostnames.empty?
 
           Yast::Host.Update("", conn.hostname, conn.ip.address.address.to_s)
         end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/src/lib/y2network/widgets/hostname.rb 
new/yast2-network-4.3.34/src/lib/y2network/widgets/hostname.rb
--- old/yast2-network-4.3.32/src/lib/y2network/widgets/hostname.rb      
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-network-4.3.34/src/lib/y2network/widgets/hostname.rb      
2020-12-14 13:02:50.000000000 +0100
@@ -0,0 +1,67 @@
+# Copyright (c) [2020] SUSE LLC
+#
+# All Rights Reserved.
+#
+# 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 LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require "cwm"
+
+module Y2Network
+  module Widgets
+    # Widget that permits to modify the hostname of the given object
+    class Hostname < CWM::InputField
+      # Constructor
+      #
+      # @param settings [Object]
+      # @param empty_allowed [Boolean] whether an empty hostname should be
+      #   valid or not
+      def initialize(settings, empty_allowed: true)
+        textdomain "network"
+
+        @settings = settings
+        @empty_allowed = empty_allowed
+      end
+
+      def init
+        self.value = @settings.hostname.to_s
+      end
+
+      def label
+        _("&Hostname")
+      end
+
+      def store
+        @settings.hostname = value
+      end
+
+      def validate
+        Yast.import "Hostname"
+        return true if empty_allowed? && value.to_s.empty?
+
+        Yast::Hostname.CheckFQ(value)
+      end
+
+    private
+
+      # Return whether an empty value is allowed or not
+      #
+      # @return [Boolean]
+      def empty_allowed?
+        @empty_allowed
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/test/y2network/clients/dns_test.rb 
new/yast2-network-4.3.34/test/y2network/clients/dns_test.rb
--- old/yast2-network-4.3.32/test/y2network/clients/dns_test.rb 2020-12-10 
16:33:41.000000000 +0100
+++ new/yast2-network-4.3.34/test/y2network/clients/dns_test.rb 2020-12-14 
13:02:50.000000000 +0100
@@ -83,7 +83,7 @@
 
         it "writes the changes" do
           allow(subject).to receive(:write_config).and_call_original
-          expect(Yast::Lan).to receive(:write_config).with(only: [:dns, 
:hostname])
+          expect(Yast::Lan).to receive(:write_config).with(only: [:dns, 
:hostname, :connections])
           subject.main
         end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/test/y2network/dialogs/update_hostname_hosts_test.rb 
new/yast2-network-4.3.34/test/y2network/dialogs/update_hostname_hosts_test.rb
--- 
old/yast2-network-4.3.32/test/y2network/dialogs/update_hostname_hosts_test.rb   
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/yast2-network-4.3.34/test/y2network/dialogs/update_hostname_hosts_test.rb   
    2020-12-14 13:02:50.000000000 +0100
@@ -0,0 +1,43 @@
+# Copyright (c) [2020] SUSE LLC
+#
+# All Rights Reserved.
+#
+# 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 LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require_relative "../../test_helper"
+require "cwm/rspec"
+
+require "y2network/dialogs/update_hostname_hosts"
+
+describe Y2Network::Dialogs::UpdateHostnameHosts do
+  subject { described_class.new(eth0_conn) }
+
+  include_examples "CWM::Dialog"
+
+  let(:ip) do
+    
Y2Network::ConnectionConfig::IPConfig.new(Y2Network::IPAddress.new("192.168.122.10",
 24))
+  end
+
+  let(:eth0_conn) do
+    Y2Network::ConnectionConfig::Ethernet.new.tap do |conn|
+      conn.interface = "eth0"
+      conn.name = "eth0"
+      conn.bootproto = :static
+      conn.ip = ip
+      conn.hostnames = ["yast.suse.com", "yast"]
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-network-4.3.32/test/y2network/widgets/hostname_test.rb 
new/yast2-network-4.3.34/test/y2network/widgets/hostname_test.rb
--- old/yast2-network-4.3.32/test/y2network/widgets/hostname_test.rb    
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-network-4.3.34/test/y2network/widgets/hostname_test.rb    
2020-12-14 13:02:50.000000000 +0100
@@ -0,0 +1,74 @@
+# Copyright (c) [2020] SUSE LLC
+#
+# All Rights Reserved.
+#
+# 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 LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require_relative "../../test_helper"
+require "cwm/rspec"
+
+require "y2network/widgets/hostname"
+
+describe Y2Network::Widgets::Hostname do
+  let(:initial_hostname) { "example.suse.com" }
+  let(:settings) { Struct.new(:hostname).new(initial_hostname) }
+
+  subject { described_class.new(settings) }
+
+  include_examples "CWM::InputField"
+
+  describe "#init" do
+    it "initializes the input with the given object hostname" do
+      expect(subject).to receive("value=").with(initial_hostname)
+
+      subject.init
+    end
+  end
+
+  describe "#validate" do
+    it "return true when the input is a valid hostname" do
+      allow(subject).to receive(:value).and_return(initial_hostname)
+      expect(subject.validate).to eql(true)
+    end
+
+    it "returns false if the input is an invalid hostname" do
+      allow(subject).to receive(:value).and_return("wrong-_hostname")
+      expect(subject.validate).to eql(false)
+    end
+
+    it "considers an empty value as valid returning true" do
+      allow(subject).to receive(:value).and_return("")
+      expect(subject.validate).to eql(true)
+    end
+
+    context "when it is configured to not permit empty values" do
+      subject { described_class.new(settings, empty_allowed: false) }
+
+      it "returns false if the input is empty" do
+        allow(subject).to receive(:value).and_return("")
+        expect(subject.validate).to eql(false)
+      end
+    end
+  end
+
+  describe "#store" do
+    it "modifies the given object hostname" do
+      allow(subject).to receive(:value).and_return("modified.hostname")
+      expect { subject.store }
+        .to change { settings.hostname 
}.from(initial_hostname).to("modified.hostname")
+    end
+  end
+end
_______________________________________________
openSUSE Commits mailing list -- commit@lists.opensuse.org
To unsubscribe, email commit-le...@lists.opensuse.org
List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette
List Archives: 
https://lists.opensuse.org/archives/list/commit@lists.opensuse.org

Reply via email to