ManageIQ/manageiq-gems-pending

View on GitHub
lib/gems/pending/util/mount/miq_nfs_session.rb

Summary

Maintainability
A
2 hrs
Test Coverage
F
36%
class MiqNfsSession < MiqGenericMountSession
PORTS = [2049, 111]
 
def self.uri_scheme
"nfs".freeze
end
 
def initialize(log_settings)
super(log_settings.merge(:ports => PORTS))
end
 
def connect
Useless assignment to variable - `registry`. Use `_` or `_registry` as a variable name to indicate that it won't be used.
Useless assignment to variable - `fragment`. Use `_` or `_fragment` as a variable name to indicate that it won't be used.
Useless assignment to variable - `port`. Use `_` or `_port` as a variable name to indicate that it won't be used.
Useless assignment to variable - `opaque`. Use `_` or `_opaque` as a variable name to indicate that it won't be used.
Useless assignment to variable - `userinfo`. Use `_` or `_userinfo` as a variable name to indicate that it won't be used.
Useless assignment to variable - `query`. Use `_` or `_query` as a variable name to indicate that it won't be used.
Useless assignment to variable - `scheme`. Use `_` or `_scheme` as a variable name to indicate that it won't be used.
scheme, userinfo, @host, port, registry, @mount_path, opaque, query, fragment = URI.split(URI::DEFAULT_PARSER.escape(@settings[:uri]))
super
end
 
Similar blocks of code found in 2 locations. Consider refactoring.
def mount_share
super
 
log_header = "MIQ(#{self.class.name}-mount_share)"
logger.info("#{log_header} Connecting to host: [#{@host}], share: [#{@mount_path}] using mount point: [#{@mnt_point}]...")
# URI: nfs://192.168.252.139/exported/miq
# mount 192.168.252.139:/exported/miq /mnt/miq
 
mount_args = {:t => "nfs"}
mount_args[:r] = nil if settings_read_only?
mount_args[nil] = %W[#{@host}:#{@mount_path} #{@mnt_point}]
 
# Quote the host:exported directory since the directory can have spaces in it
case Sys::Platform::IMPL
when :macosx
mount_args[:o] = "resvport"
sudo_mount(mount_args)
when :linux
mount(mount_args)
else
raise "platform not supported"
end
logger.info("#{log_header} Connecting to host: [#{@host}], share: [#{@mount_path}]...Complete")
end
end