-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
399 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# encoding: utf-8 | ||
# | ||
# Copyright (c) [2018] 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" | ||
|
||
module Y2NfsClient | ||
# Version of the NFS protocol configured for an NFS mount | ||
# | ||
# The main goal of the class if to map how the version is configured in the | ||
# /etc/fstab entry with how that is presented to the user. | ||
# | ||
# Each instance can represent the configuration to enforce a concrete version | ||
# or a more generic configuration (i.e. "use any available version"). | ||
class NfsVersion | ||
include Yast::I18n | ||
extend Yast::I18n | ||
textdomain "nfs" | ||
|
||
ALL_ATTRIBUTES = [ | ||
[nil, N_("Any"), :vers_any, N_("Any (Highest Available)")], | ||
["3", N_("NFSv3"), :vers_3, N_("Force NFSv3")], | ||
["4", N_("NFSv4"), :vers_4, N_("Force NFSv4")], | ||
["4.1", N_("NFSv4.1"), :vers_4_1, N_("Force pNFS (v4.1)")] | ||
].freeze | ||
private_constant :ALL_ATTRIBUTES | ||
|
||
# Constructor | ||
def initialize(mntops_value, label, widget_id, widget_text) | ||
textdomain "nfs" | ||
|
||
@mntops_value = mntops_value | ||
@label = label | ||
@widget_id = widget_id | ||
@widget_text = widget_text | ||
end | ||
|
||
# Sorted list of all possible settings | ||
def self.all | ||
ALL_ATTRIBUTES.map { |attrs| new(*attrs) } | ||
end | ||
|
||
# An instance corresponding to a given value in the mount options | ||
# | ||
# @see #mntops_value | ||
# | ||
# @param value [String] | ||
# @return [NfsVersion] | ||
def self.for_mntops_value(value) | ||
all.find { |version| version.mntops_value == value } | ||
end | ||
|
||
# Value used in the corresponding mount option (nfsvers or vers) | ||
# | ||
# @return [String] | ||
attr_reader :mntops_value | ||
|
||
# Id for a widget representing the instance | ||
# | ||
# @return [Symbol] | ||
attr_reader :widget_id | ||
|
||
# Short localized label to represent the instance in listings | ||
# | ||
# @return [String] | ||
def label | ||
_(@label) | ||
end | ||
|
||
# Localized text to use in a widget representing the instance | ||
# | ||
# @return [String] | ||
def widget_text | ||
_(@widget_text) | ||
end | ||
|
||
def ==(other) | ||
other.class == self.class && other.mntops_value == mntops_value | ||
end | ||
|
||
alias_method :eql?, :== | ||
|
||
# Whether the system infrastructure associated to NFSv4 (e.g. enabled | ||
# NFS4_SUPPORT in sysconfig/nfs) is needed in order to use this version of | ||
# the protocol. | ||
# | ||
# @return [Boolean] | ||
def requires_v4? | ||
return false if mntops_value.nil? | ||
mntops_value.start_with?("4") | ||
end | ||
|
||
# Whether is necessary to use the browsing mechanisms associated to NFSv4 in | ||
# order to find shares of this type in the network or in a given server. | ||
# | ||
# Scanning a network or server to find NFS shares is completely different | ||
# depending on the version of the protocol (version 3 vs version 4+). | ||
# | ||
# @return [Boolean] | ||
def browse_with_v4? | ||
requires_v4? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.