Class: OsCtl::ExportFS::Operations::Server::Configure

Inherits:
Base
  • Object
show all
Includes:
Lib::Utils::Log, Lib::Utils::System
Defined in:
lib/osctl/exportfs/operations/server/configure.rb

Overview

Change the server configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

run

Constructor Details

#initialize(server, opts) ⇒ Configure

Returns a new instance of Configure.

Parameters:

  • server (Server)
  • opts (Hash)

    options

Options Hash (opts):

  • :address (String)
  • :netif (String)
  • :nfsd (Hash)
  • :mountd_port (Integer)
  • :lockd_port (Integer)
  • :statd_port (Integer)


19
20
21
22
23
# File 'lib/osctl/exportfs/operations/server/configure.rb', line 19

def initialize(server, opts)
  super()
  @server = server
  @opts = opts
end

Instance Attribute Details

#optsObject (readonly, protected)

Returns the value of attribute opts.



45
46
47
# File 'lib/osctl/exportfs/operations/server/configure.rb', line 45

def opts
  @opts
end

#serverObject (readonly, protected)

Returns the value of attribute server.



45
46
47
# File 'lib/osctl/exportfs/operations/server/configure.rb', line 45

def server
  @server
end

Instance Method Details

#executeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/osctl/exportfs/operations/server/configure.rb', line 25

def execute
  server.synchronize do
    cfg = server.open_config

    %i[address netif mountd_port lockd_port statd_port].each do |v|
      cfg.send(:"#{v}=", opts[v]) unless opts[v].nil?
    end

    if opts[:nfsd]
      %i[port nproc tcp udp versions syslog].each do |v|
        cfg.nfsd.send(:"#{v}=", opts[:nfsd][v]) unless opts[:nfsd][v].nil?
      end
    end

    cfg.save
  end
end