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
# File 'lib/osctl/exportfs/operations/exportfs/generate.rb', line 9

def initialize(server)
  @server = server
end

Instance Attribute Details

#serverObject (readonly, protected)

Returns the value of attribute server.



24
25
26
# File 'lib/osctl/exportfs/operations/exportfs/generate.rb', line 24

def server
  @server
end

Instance Method Details

#executeObject



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

def execute
  cfg = server.open_config

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