Class: OsCtl::ExportFS::Operations::Exportfs::Generate

Inherits:
Base
  • Object
show all
Includes:
Lib::Utils::File
Defined in:
lib/osctl/exportfs/operations/exportfs/generate.rb

Overview

Generate exports file from the database for use with exportfs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

run

Constructor Details

#initialize(server) ⇒ Generate

Returns a new instance of Generate.

Parameters:



9
10
11
12
# File 'lib/osctl/exportfs/operations/exportfs/generate.rb', line 9

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

Instance Attribute Details

#serverObject (readonly, protected)

Returns the value of attribute server.



26
27
28
# File 'lib/osctl/exportfs/operations/exportfs/generate.rb', line 26

def server
  @server
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
# File 'lib/osctl/exportfs/operations/exportfs/generate.rb', line 14

def execute
  cfg = server.open_config

  regenerate_file(server.exports_file, 0o644) do |new|
    cfg.exports.each do |ex|
      new.puts("#{ex.as} #{ex.host}(#{ex.options})")
    end
  end
end