Hello community,
here is the log from the commit of package yast2-nfs-client for
openSUSE:Factory checked in at 2020-01-20 22:49:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-nfs-client (Old)
and /work/SRC/openSUSE:Factory/.yast2-nfs-client.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-nfs-client"
Mon Jan 20 22:49:46 2020 rev:82 rq:765680 version:4.2.5
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-nfs-client/yast2-nfs-client.changes
2020-01-11 14:47:42.237366394 +0100
+++
/work/SRC/openSUSE:Factory/.yast2-nfs-client.new.26092/yast2-nfs-client.changes
2020-01-20 22:49:59.935217818 +0100
@@ -1,0 +2,9 @@
+Fri Jan 17 12:49:20 UTC 2020 - José Iván López González <[email protected]>
+
+- Delegates mount/unmount actions to yast2-storage-ng.
+- Keeps mount point status for existing shares.
+- Adds an asterisk to mount point for unmounted entries.
+- Related to bsc#1006815, bsc#1151426, bsc#1060159.
+- 4.2.5
+
+-------------------------------------------------------------------
Old:
----
yast2-nfs-client-4.2.4.tar.bz2
New:
----
yast2-nfs-client-4.2.5.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-nfs-client.spec ++++++
--- /var/tmp/diff_new_pack.OuwHNy/_old 2020-01-20 22:50:01.659218481 +0100
+++ /var/tmp/diff_new_pack.OuwHNy/_new 2020-01-20 22:50:01.703218499 +0100
@@ -17,7 +17,7 @@
Name: yast2-nfs-client
-Version: 4.2.4
+Version: 4.2.5
Release: 0
Url: https://github.com/yast/yast-nfs-client
Summary: YaST2 - NFS Configuration
@@ -37,8 +37,8 @@
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
# path_matching (RSpec argument matcher)
BuildRequires: yast2-ruby-bindings >= 3.1.31
-# Y2Storage::MountPoint#active=
-BuildRequires: yast2-storage-ng >= 4.0.180
+# Y2Storage::Filesystems::LegacyNfs#configure_from
+BuildRequires: yast2-storage-ng >= 4.2.73
# Unfortunately we cannot move this to macros.yast,
# bcond within macros are ignored by osc/OBS.
%bcond_with yast_run_ci_tests
@@ -52,9 +52,9 @@
Requires: yast2-nfs-common >= 2.24.0
# showmount, #150382, #286300
Recommends: nfs-client
-# Y2Storage::MountPoint#active=
+# Y2Storage::Filesystems::LegacyNfs#configure_from
Requires: yast2-ruby-bindings >= 1.0.0
-Requires: yast2-storage-ng >= 4.0.180
+Requires: yast2-storage-ng >= 4.2.73
Provides: yast2-config-network:/usr/lib/YaST2/clients/lan_nfs_client.ycp
Provides: yast2-config-nfs
++++++ yast2-nfs-client-4.2.4.tar.bz2 -> yast2-nfs-client-4.2.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-nfs-client-4.2.4/package/yast2-nfs-client.changes
new/yast2-nfs-client-4.2.5/package/yast2-nfs-client.changes
--- old/yast2-nfs-client-4.2.4/package/yast2-nfs-client.changes 2020-01-09
16:00:38.000000000 +0100
+++ new/yast2-nfs-client-4.2.5/package/yast2-nfs-client.changes 2020-01-20
08:17:44.000000000 +0100
@@ -1,4 +1,13 @@
-------------------------------------------------------------------
+Fri Jan 17 12:49:20 UTC 2020 - José Iván López González <[email protected]>
+
+- Delegates mount/unmount actions to yast2-storage-ng.
+- Keeps mount point status for existing shares.
+- Adds an asterisk to mount point for unmounted entries.
+- Related to bsc#1006815, bsc#1151426, bsc#1060159.
+- 4.2.5
+
+-------------------------------------------------------------------
Wed Jan 8 22:49:11 UTC 2020 - David Diaz <[email protected]>
- Avoids displaying phantom NFS entries adding an action to
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/package/yast2-nfs-client.spec
new/yast2-nfs-client-4.2.5/package/yast2-nfs-client.spec
--- old/yast2-nfs-client-4.2.4/package/yast2-nfs-client.spec 2020-01-09
16:00:38.000000000 +0100
+++ new/yast2-nfs-client-4.2.5/package/yast2-nfs-client.spec 2020-01-20
08:17:44.000000000 +0100
@@ -17,7 +17,7 @@
Name: yast2-nfs-client
-Version: 4.2.4
+Version: 4.2.5
Release: 0
Url: https://github.com/yast/yast-nfs-client
Summary: YaST2 - NFS Configuration
@@ -37,8 +37,8 @@
BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)
# path_matching (RSpec argument matcher)
BuildRequires: yast2-ruby-bindings >= 3.1.31
-# Y2Storage::MountPoint#active=
-BuildRequires: yast2-storage-ng >= 4.0.180
+# Y2Storage::Filesystems::LegacyNfs#configure_from
+BuildRequires: yast2-storage-ng >= 4.2.73
# Unfortunately we cannot move this to macros.yast,
# bcond within macros are ignored by osc/OBS.
%bcond_with yast_run_ci_tests
@@ -52,8 +52,8 @@
Requires: yast2-nfs-common >= 2.24.0
# showmount, #150382, #286300
Recommends: nfs-client
-# Y2Storage::MountPoint#active=
-Requires: yast2-storage-ng >= 4.0.180
+# Y2Storage::Filesystems::LegacyNfs#configure_from
+Requires: yast2-storage-ng >= 4.2.73
Requires: yast2-ruby-bindings >= 1.0.0
Provides: yast2-config-nfs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/src/include/nfs/routines.rb
new/yast2-nfs-client-4.2.5/src/include/nfs/routines.rb
--- old/yast2-nfs-client-4.2.4/src/include/nfs/routines.rb 2020-01-09
16:00:38.000000000 +0100
+++ new/yast2-nfs-client-4.2.5/src/include/nfs/routines.rb 2020-01-20
08:17:44.000000000 +0100
@@ -1,4 +1,21 @@
-# encoding: utf-8
+# Copyright (c) [2013-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 "y2nfs_client/nfs_version"
require "y2storage"
@@ -53,15 +70,18 @@
count = 0
Builtins.maplist(fstab) do |entry|
sp = SpecToServPath(Ops.get_string(entry, "spec", ""))
+ mount_point = item_mount_point(entry)
mntops = entry["mntops"] || ""
+
it = Item(
Id(count),
- Ops.add(Ops.get_string(sp, 0, ""), " "),
- Ops.add(Ops.get_string(sp, 1, ""), " "),
- Ops.add(Ops.get_string(entry, "file", ""), " "),
- "#{nfs_version_for_table(entry)} ",
- "#{mntops} "
+ Ops.get_string(sp, 0, "") + " ",
+ Ops.get_string(sp, 1, "") + " ",
+ mount_point + " ",
+ nfs_version_for_table(entry) + " ",
+ mntops + " "
)
+
count = Ops.add(count, 1)
deep_copy(it)
end
@@ -233,6 +253,18 @@
}
end
+ # Creates a LegacyNfs object according to the given entry
+ #
+ # @param entry [Hash] NFS mount in the .etc.fstab format that uses keys
such as "spec", "file", etc.
+ # @return [Y2Storage::Filesystems::LegacyNfs]
+ def to_legacy_nfs(entry)
+ storage_hash = fstab_to_storage(entry)
+ legacy = Y2Storage::Filesystems::LegacyNfs.new_from_hash(storage_hash)
+ legacy.default_devicegraph = working_graph
+
+ legacy
+ end
+
private
# @see #FstabTableItems
@@ -266,6 +298,13 @@
storage_manager.staging
end
+ # Devicegraph representing the current system status
+ #
+ # @return [Y2Storage::Devicegraph]
+ def system_graph
+ storage_manager.probed
+ end
+
# Mount points present on /etc/fstab but not handled by the yast-nfs-client
# module.
#
@@ -275,5 +314,32 @@
mp.mountable && !mp.mountable.is?(:nfs)
end.map(&:path)
end
+
+ # Mount point to show for the given entry
+ #
+ # Note that an asterisk could be appended to the mount path when the NFS
share is not currently
+ # mounted.
+ #
+ # @param entry [Hash] NFS mount in the .etc.fstab format that uses keys
such as "spec", "file", etc.
+ # @return [String]
+ def item_mount_point(entry)
+ mount_point = entry["file"].dup || ""
+
+ mount_point << "*" if unmounted_mark?(entry)
+
+ mount_point
+ end
+
+ # Whether a mark should be added to the mount path because the device is
unmounted
+ #
+ # @param entry [Hash] NFS mount in the .etc.fstab format that uses keys
such as "spec", "file", etc.
+ # @return [Boolean]
+ def unmounted_mark?(entry)
+ return false if entry["new"]
+
+ nfs = to_legacy_nfs(entry).find_nfs_device
+
+ nfs && nfs.mount_point && nfs.mount_point.active? ? false : true
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/src/include/nfs/ui.rb
new/yast2-nfs-client-4.2.5/src/include/nfs/ui.rb
--- old/yast2-nfs-client-4.2.4/src/include/nfs/ui.rb 2020-01-09
16:00:38.000000000 +0100
+++ new/yast2-nfs-client-4.2.5/src/include/nfs/ui.rb 2020-01-20
08:17:44.000000000 +0100
@@ -1,4 +1,22 @@
-# encoding: utf-8
+# Copyright (c) [2013-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 "y2firewall/firewalld"
require "yast2/feedback"
require "yast2/popup"
@@ -51,9 +69,12 @@
# Help, part 2 of 4
_(
"<p>Each NFS share is identified by remote NFS server address and\n"
\
- "exported directory, local directory where the remote directory is
mounted, \n" \
- "version of the NFS protocol and mount options. For further
information \n" \
- "about mounting NFS and mount options, refer to <tt>man
nfs.</tt></p>"
+ "exported directory, local directory where the remote directory is
mounted, \n" \
+ "version of the NFS protocol and mount options. For further
information \n" \
+ "about mounting NFS and mount options, refer to <tt>man
nfs</tt>.</p>\n" \
+ "<p>An asterisk (*) after the mount point indicates a file system
that is \n" \
+ "currently not mounted (for example, because it has the
<tt>noauto</tt> \n" \
+ "option set in <tt>/etc/fstab</tt>).</p>"
) +
# Help, part 3 of 4
_(
@@ -219,6 +240,8 @@
ret = nil
if fstab_ent
+ new_entry = fstab_ent.fetch("new", false)
+
couple = SpecToServPath(Ops.get_string(fstab_ent, "spec", ""))
server = Ops.get_string(couple, 0, "")
pth = Ops.get_string(couple, 1, "")
@@ -227,6 +250,8 @@
servers = [server]
old = Ops.get_string(fstab_ent, "spec", "")
else
+ new_entry = true
+
proposed_server = ProposeHostname()
servers = [proposed_server] if HostnameExists(proposed_server)
end
@@ -450,6 +475,11 @@
UI.CloseDialog
Wizard.RestoreScreenShotName
+ # New entries are identify by "new" key in the hash. This is useful to
detect which entries are
+ # not created but updated. Note that this is important to keep the
current mount point status of
+ # updated entries.
+ fstab_ent["new"] = new_entry
+
return deep_copy(fstab_ent) if ret == :ok
nil
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/src/modules/Nfs.rb
new/yast2-nfs-client-4.2.5/src/modules/Nfs.rb
--- old/yast2-nfs-client-4.2.4/src/modules/Nfs.rb 2020-01-09
16:00:38.000000000 +0100
+++ new/yast2-nfs-client-4.2.5/src/modules/Nfs.rb 2020-01-20
08:17:44.000000000 +0100
@@ -1,4 +1,21 @@
-# encoding: utf-8
+# Copyright (c) [2013-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 "yast"
require "y2firewall/firewalld"
@@ -304,7 +321,8 @@
"/usr/bin/cp /etc/fstab /etc/fstab.YaST2/save"
)
- if !write_fstab
+ # Perform a storage commit to write the fstab file and mount/unmount NFS
shares.
+ if !storage_manager.commit
# error popup message
Report.Error(
_(
@@ -317,10 +335,7 @@
end
@portmapper = FindPortmapper()
- if !@nfs_entries.empty?
- Service.Enable(@portmapper)
- Service.Enable("nfs")
- end
+ Service.Enable(@portmapper) unless @nfs_entries.empty?
if @nfs4_enabled == true
SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "yes")
@@ -355,14 +370,10 @@
2,
[
# progress stage label
- _("Stop services"),
- # progress stage label
_("Start services")
],
[
# progress step label
- _("Stopping services..."),
- # progress step label
_("Starting services..."),
# final progress step label
_("Finished")
@@ -373,12 +384,8 @@
# help text
Wizard.RestoreHelp(_("Writing NFS client settings. Please wait..."))
- Progress.NextStage
-
- Service.Stop("nfs")
-
- Progress.NextStage
if Ops.greater_than(Builtins.size(@nfs_entries), 0)
+ Progress.NextStage
# portmap must not be started if it is running already (see bug # 9999)
Service.Start(@portmapper) unless Service.active?(@portmapper)
@@ -386,15 +393,8 @@
Report.Error(Message.CannotStartService(@portmapper))
return false
end
-
- Service.Start("nfs")
-
- unless Service.active?("nfs")
- # error popup message
- Report.Error(_("Unable to mount the NFS entries from /etc/fstab."))
- return false
- end
end
+
firewalld.reload
Progress.NextStage
true
@@ -653,46 +653,24 @@
end
end
- # Commits storage changes to /etc/fstab
- def write_fstab
- # By default, libstorage-ng will umount active NFS shares found in
- # probed and will mount active Nfs shares from staging.
- # Let's prevent that since we don't want libstorage-ng to perform any
- # mount/umount.
- #
- # TODO: this implies too much knowledge about how libstorage-ng works, it
- # should be moved to yast2-storage-ng (e.g. as a :skip_mount flag to
- # #commit).
- deactivate_mount_points(storage_manager.probed)
- deactivate_mount_points(storage_manager.staging)
- storage_manager.commit
- end
-
- # See {#write_fstab}
- #
- # @param graph [Y2Storage::Devicegraph]
- def deactivate_mount_points(graph)
- graph.nfs_mounts.each do |nfs|
- nfs.mount_point && nfs.mount_point.active = false
- end
- end
-
# Creates a Y2Storage::Filesystems::Nfs device in the working devicegraph
#
- # @param entry [Hash] NFS mount in the .etc.fstab format that uses keys
such
- # as "spec", "file", etc
+ # Note that for existing entries (no newly added), the NFS share will not
be mounted if it is
+ # currently unmounted. Similarly, existing shares that are not included in
the fstab will not be
+ # added to the fstab after committing the changes.
+ #
+ # @param entry [Hash] NFS mount in the .etc.fstab format that uses keys
such as "spec", "file", etc.
+ # @return [Y2Partitioner::Filesystems::Nfs]
def create_storage_device(entry)
- to_legacy_nfs(entry).create_nfs_device
- end
+ legacy_nfs = to_legacy_nfs(entry)
- # @see #create_storage_device
- #
- # @param entry [Hash] see {#create_storage_device}
- def to_legacy_nfs(entry)
- storage_hash = fstab_to_storage(entry)
- legacy = Y2Storage::Filesystems::LegacyNfs.new_from_hash(storage_hash)
- legacy.default_devicegraph = working_graph
- legacy
+ if !entry["new"]
+ probed_nfs = legacy_nfs.find_nfs_device(system_graph)
+
+ legacy_nfs.configure_from(probed_nfs) if probed_nfs
+ end
+
+ legacy_nfs.create_nfs_device
end
# Check that the required nfs-client packages are present adding them to
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/test/nfs_test.rb
new/yast2-nfs-client-4.2.5/test/nfs_test.rb
--- old/yast2-nfs-client-4.2.4/test/nfs_test.rb 2020-01-09 16:00:38.000000000
+0100
+++ new/yast2-nfs-client-4.2.5/test/nfs_test.rb 2020-01-20 08:17:44.000000000
+0100
@@ -1,21 +1,23 @@
-#! /usr/bin/env rspec
-# Copyright (c) 2014 SUSE Linux.
-# All Rights Reserved.
-
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 or 3 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.
+#!/usr/bin/env rspec
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, contact SUSE LLC.
-
-# To contact SUSE about this file by physical or electronic mail,
-# you may find current contact information at www.suse.com
+# Copyright (c) [2015-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 "spec_helper"
require "yaml"
@@ -26,9 +28,6 @@
Yast.import "Service"
describe "Yast::Nfs" do
- subject { Yast::Nfs }
- let(:firewalld) { Y2Firewall::Firewalld.instance }
-
def allow_read_side_effects
allow(subject).to receive(:ReadNfs4)
allow(subject).to receive(:ReadNfsGss)
@@ -39,7 +38,19 @@
allow(subject).to receive(:check_and_install_required_packages)
end
+ def add_nfs_devices
+ nfs1 = Y2Storage::Filesystems::Nfs.create(system_graph, "nfs.example.com",
"/foo")
+ nfs1.mount_path = "/foo"
+
+ nfs2 = Y2Storage::Filesystems::Nfs.create(system_graph, "nfs.example.com",
"/baz")
+ nfs2.mount_path = "/foo/bar/baz"
+
+ system_graph.copy(working_graph)
+ end
+
def mock_entries
+ add_nfs_devices
+
subject.skip_fstab = false
subject.Read
end
@@ -49,17 +60,21 @@
sm = Y2Storage::StorageManager.create_test_instance
sm.probe_from_yaml(File.join(DATA_PATH, "devicegraph.yaml"))
- # Add NFS entries
- Y2Storage::Filesystems::Nfs.create(sm.staging, "nfs.example.com",
"/foo").mount_path = "/foo"
- Y2Storage::Filesystems::Nfs.create(sm.staging, "nfs.example.com",
"/baz").mount_path = "/foo/bar/baz"
-
# Prevent further reprobing
allow(sm).to receive(:probe).and_return true
# prevent storage-commit
- allow(subject).to receive(:write_fstab)
+ allow(sm).to receive(:commit)
end
+ subject { Yast::Nfs }
+
+ let(:firewalld) { Y2Firewall::Firewalld.instance }
+
+ let(:working_graph) { Y2Storage::StorageManager.instance.staging }
+
+ let(:system_graph) { Y2Storage::StorageManager.instance.probed }
+
describe ".Import" do
let(:profile) do
{
@@ -139,6 +154,13 @@
end
describe ".Export" do
+ before do
+ mock_entries
+ subject.nfs4_enabled = true
+ subject.nfs_gss_enabled = false
+ subject.idmapd_domain = "example.com"
+ end
+
let(:expected_profile) do
{
"enable_nfs4" => true,
@@ -160,12 +182,6 @@
]
}
end
- before do
- mock_entries
- subject.nfs4_enabled = true
- subject.nfs_gss_enabled = false
- subject.idmapd_domain = "example.com"
- end
it "exports the current nfs settings as a map" do
profile = subject.Export()
@@ -259,9 +275,31 @@
mock_entries
end
+ def nfs(share)
+ working_graph.nfs_mounts.find { |n| n.share == share }
+ end
+
+ def probed_nfs(share)
+ system_graph.nfs_mounts.find { |n| n.share == share }
+ end
+
+ def entry(spec)
+ subject.nfs_entries.find { |e| e["spec"] == spec }
+ end
+
+ def create_entry(spec)
+ {
+ "spec" => spec,
+ "file" => "/home/test",
+ "freq" => 0,
+ "mntops" => "defaults",
+ "passno" => 0,
+ "vfstype" => "nfs"
+ }
+ end
+
def find_mp(path)
- staging = Y2Storage::StorageManager.instance.staging
- staging.filesystems.find { |fs| fs.mount_path == path }.mount_point
+ working_graph.filesystems.find { |fs| fs.mount_path == path }.mount_point
end
it "ensures zero for the 'passno' field, only in nfs entries" do
@@ -281,22 +319,156 @@
expect(find_mp("/foo").passno).to eq 0
expect(find_mp("/foo/bar/baz").passno).to eq 0
end
+
+ shared_examples "remove_entry" do
+ it "removes the existing NFS share" do
+ nfs_sid = nfs(spec).sid
+
+ subject.WriteOnly
+
+ expect(working_graph.find_device(nfs_sid)).to be_nil
+ end
+ end
+
+ context "when the entry is new" do
+ before do
+ entry = entry(spec)
+
+ if entry
+ entry["new"] = true
+ else
+ entry = create_entry(spec)
+ entry["new"] = true
+ subject.nfs_entries << entry
+ end
+ end
+
+ shared_examples "new_entry" do
+ it "creates a new NFS share for that entry" do
+ subject.WriteOnly
+
+ nfs = nfs(spec)
+
+ expect(nfs).to_not be_nil
+ expect(nfs.exists_in_probed?).to eq(false)
+ end
+
+ it "sets the NFS mount point as active" do
+ subject.WriteOnly
+
+ nfs = nfs(spec)
+
+ expect(nfs.mount_point.active?).to eq(true)
+ end
+
+ it "sets the NFS to be written to the fstab" do
+ subject.WriteOnly
+
+ nfs = nfs(spec)
+
+ expect(nfs.mount_point.in_etc_fstab?).to eq(true)
+ end
+ end
+
+ context "and the NFS share does no exist in the system yet" do
+ let(:spec) { "nfs.example.com:/home/test" }
+
+ include_examples "new_entry"
+ end
+
+ context "and the NFS share already exists in the system" do
+ let(:spec) { "nfs.example.com:/foo" }
+
+ before do
+ # Set mount point properties of the existing NFS share. This
configuration should not be
+ # propagated to the new NFS share.
+ nfs = nfs(spec)
+ nfs.mount_point.active = false
+ nfs.mount_point.in_etc_fstab = false
+ end
+
+ include_examples "remove_entry"
+
+ include_examples "new_entry"
+ end
+ end
+
+ context "when the entry is not new" do
+ before do
+ entry = entry(spec)
+ entry["new"] = false
+ end
+
+ let(:spec) { "nfs.example.com:/foo" }
+
+ include_examples "remove_entry"
+
+ context "and the entry corresponds to a mounted NFS share" do
+ before do
+ probed_nfs(spec).mount_point.active = true
+ end
+
+ it "creates a NFS share with active mount point" do
+ subject.WriteOnly
+
+ expect(nfs(spec).mount_point.active?).to eq(true)
+ end
+ end
+
+ context "and the entry corresponds to an unmounted NFS share" do
+ before do
+ probed_nfs(spec).mount_point.active = false
+ end
+
+ it "creates a NFS share with inactive mount point" do
+ subject.WriteOnly
+
+ expect(nfs(spec).mount_point.active?).to eq(false)
+ end
+ end
+
+ context "and the entry corresponds to a NFS share included in the fstab"
do
+ before do
+ probed_nfs(spec).mount_point.in_etc_fstab = true
+ end
+
+ it "creates a NFS share that would be written to the fstab" do
+ subject.WriteOnly
+
+ expect(nfs(spec).mount_point.in_etc_fstab?).to eq(true)
+ end
+ end
+
+ context "and the entry corresponds to a NFS that is not included in the
fstab" do
+ before do
+ probed_nfs(spec).mount_point.in_etc_fstab = false
+ end
+
+ it "creates a NFS share that would not be written to the fstab" do
+ subject.WriteOnly
+
+ expect(nfs(spec).mount_point.in_etc_fstab?).to eq(false)
+ end
+ end
+ end
end
describe ".Write" do
- let(:written) { false }
- let(:portmapper) { "rpcbind" }
-
before do
- subject.instance_variable_set("@portmapper", portmapper)
allow(subject).to receive(:WriteOnly).and_return(written)
+
allow(Yast::Wizard)
allow(Yast::Progress).to receive(:set)
allow(Yast::Service).to receive(:Start)
allow(Yast::Service).to receive(:Stop)
allow(Yast::Service).to receive(:active?)
+
+ allow_read_side_effects
+ mock_entries
end
+ let(:written) { false }
+
it "writes the nfs configurations" do
expect(subject).to receive(:WriteOnly)
subject.Write()
@@ -305,14 +477,9 @@
context "when the configuration is written correctly" do
let(:written) { true }
- it "stops the nfs service" do
- expect(Yast::Service).to receive(:Stop).with("nfs")
- subject.Write()
- end
-
it "tries to start the portmapper service if it is not running" do
- expect(Yast::Service).to
receive(:active?).with(portmapper).and_return(false)
- expect(Yast::Service).to receive(:Start).with(portmapper)
+ expect(Yast::Service).to
receive(:active?).with("rpcbind").and_return(false)
+ expect(Yast::Service).to receive(:Start).with("rpcbind")
subject.Write()
end
@@ -332,7 +499,6 @@
expect(subject.Write).to eql(false)
end
end
-
end
context "when the configuration is not written correctly" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/test/routines_test.rb
new/yast2-nfs-client-4.2.5/test/routines_test.rb
--- old/yast2-nfs-client-4.2.4/test/routines_test.rb 2020-01-09
16:00:38.000000000 +0100
+++ new/yast2-nfs-client-4.2.5/test/routines_test.rb 2020-01-20
08:17:44.000000000 +0100
@@ -1,4 +1,24 @@
-#! /usr/bin/env rspec
+#!/usr/bin/env rspec
+
+# Copyright (c) [2017-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 "spec_helper"
module Yast
@@ -139,6 +159,12 @@
end
describe "#FstabTableItems" do
+ before do
+ Y2Storage::StorageManager.create_test_instance
+ end
+
+ let(:working_graph) { Y2Storage::StorageManager.instance.staging }
+
context "given a list of nfs fstab entries" do
it "returns a list of ui table items" do
items = subject.FstabTableItems(nfs_entries)
@@ -146,10 +172,88 @@
expect(items.size).to eql(3)
expect(items.first.params[1]).to eql("foo.bar.com ")
expect(items.first.params[2]).to eql("/home ")
- expect(items.first.params[2]).to eql("/home ")
+ expect(items.first.params[3]).to eql("/home* ")
expect(items.first.params[4]).to eql("Any (Please Check) ")
expect(items.first.params[5]).to eql("defaults ")
end
+
+ context "and an entry corresponds to a mounted NFS share" do
+ before do
+ nfs = Y2Storage::Filesystems::Nfs.create(working_graph, "srv",
"/home/test")
+ nfs.mount_path = "/home/test"
+ nfs.mount_point.active = true
+ end
+
+ let(:nfs_entries) do
+ [
+ {
+ "spec" => "srv:/home/test",
+ "file" => "/home/test",
+ "freq" => 0,
+ "mntops" => "defaults",
+ "passno" => 0,
+ "vfstype" => "nfs"
+ }
+ ]
+ end
+
+ it "does not append an asterisk to the mount path of the mounted NFS
share" do
+ # Note that the mount point of "srv:/home/test" is active
+ items = subject.FstabTableItems(nfs_entries)
+
+ expect(items.first.params[1]).to eql("srv ")
+ expect(items.first.params[2]).to eql("/home/test ")
+ expect(items.first.params[3]).to eql("/home/test ")
+ end
+ end
+
+ context "and an entry corresponds to an unmounted NFS share" do
+ before do
+ nfs = Y2Storage::Filesystems::Nfs.create(working_graph, "srv",
"/home/test")
+ nfs.mount_path = "/home/test"
+ nfs.mount_point.active = false
+ end
+
+ let(:nfs_entries) do
+ [
+ {
+ "spec" => "srv:/home/test",
+ "file" => "/home/test",
+ "freq" => 0,
+ "mntops" => "defaults",
+ "passno" => 0,
+ "vfstype" => "nfs",
+ "new" => new_entry
+ }
+ ]
+ end
+
+ context "and the entry is new" do
+ let(:new_entry) { true }
+
+ it "does not append an asterisk to the mount path of the new NFS
share" do
+ # Note that the mount point of "srv:/home/test" is inactive
+ items = subject.FstabTableItems(nfs_entries)
+
+ expect(items.first.params[1]).to eql("srv ")
+ expect(items.first.params[2]).to eql("/home/test ")
+ expect(items.first.params[3]).to eql("/home/test ")
+ end
+ end
+
+ context "and the entry is not new" do
+ let(:new_entry) { false }
+
+ it "appends an asterisk to the mount path of the unmounted NFS
share" do
+ # Note that the mount point of "srv:/home/a" is inactive
+ items = subject.FstabTableItems(nfs_entries)
+
+ expect(items.first.params[1]).to eql("srv ")
+ expect(items.first.params[2]).to eql("/home/test ")
+ expect(items.first.params[3]).to eql("/home/test* ")
+ end
+ end
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-nfs-client-4.2.4/test/ui_test.rb
new/yast2-nfs-client-4.2.5/test/ui_test.rb
--- old/yast2-nfs-client-4.2.4/test/ui_test.rb 2020-01-09 16:00:38.000000000
+0100
+++ new/yast2-nfs-client-4.2.5/test/ui_test.rb 2020-01-20 08:17:44.000000000
+0100
@@ -1,4 +1,24 @@
-#! /usr/bin/env rspec
+#!/usr/bin/env rspec
+
+# Copyright (c) [2018-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 "spec_helper"
module Yast