Class: OsCtl::ExportFS::Config::TopLevel
- Inherits:
-
Object
- Object
- OsCtl::ExportFS::Config::TopLevel
- Includes:
- Lib::Utils::File
- Defined in:
- lib/osctl/exportfs/config/top_level.rb
Instance Attribute Summary collapse
- #address ⇒ String?
- #exports ⇒ Config::Exports readonly
- #lockd_port ⇒ Integer?
- #mountd_port ⇒ Integer?
- #netif ⇒ String
- #nfsd ⇒ Config::Nfsd readonly
- #path ⇒ String readonly
- #server ⇒ Server readonly
- #statd_port ⇒ Integer?
Instance Method Summary collapse
- #default_netif ⇒ Object protected
- #dump ⇒ Object protected
-
#initialize(server) ⇒ TopLevel
constructor
A new instance of TopLevel.
- #read_config ⇒ Object protected
- #save ⇒ Object
Constructor Details
#initialize(server) ⇒ TopLevel
Returns a new instance of TopLevel.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 35 def initialize(server) @server = server @path = server.config_file if File.exist?(path) read_config else @nfsd = Config::Nfsd.new({}) @exports = Config::Exports.new([]) end end |
Instance Attribute Details
#address ⇒ String?
17 18 19 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 17 def address @address end |
#exports ⇒ Config::Exports (readonly)
32 33 34 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 32 def exports @exports end |
#lockd_port ⇒ Integer?
26 27 28 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 26 def lockd_port @lockd_port end |
#mountd_port ⇒ Integer?
23 24 25 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 23 def mountd_port @mountd_port end |
#netif ⇒ String
48 49 50 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 48 def netif @netif || default_netif end |
#nfsd ⇒ Config::Nfsd (readonly)
20 21 22 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 20 def nfsd @nfsd end |
#path ⇒ String (readonly)
11 12 13 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 11 def path @path end |
#server ⇒ Server (readonly)
8 9 10 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 8 def server @server end |
#statd_port ⇒ Integer?
29 30 31 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 29 def statd_port @statd_port end |
Instance Method Details
#default_netif ⇒ Object (protected)
73 74 75 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 73 def default_netif "nfs-#{server.name}" end |
#dump ⇒ Object (protected)
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 77 def dump { 'address' => address, 'netif' => @netif == default_netif ? nil : @netif, 'nfsd' => nfsd.dump, 'mountd_port' => mountd_port, 'lockd_port' => lockd_port, 'statd_port' => statd_port, 'exports' => exports.dump } end |
#read_config ⇒ Object (protected)
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 62 def read_config data = server.synchronize { OsCtl::Lib::ConfigFile.load_yaml_file(path) } @netif = data['netif'] @address = data['address'] @nfsd = Config::Nfsd.new(data['nfsd'] || {}) @mountd_port = data['mountd_port'] @lockd_port = data['lockd_port'] @statd_port = data['statd_port'] @exports = Config::Exports.new(data['exports'] || []) end |
#save ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/osctl/exportfs/config/top_level.rb', line 52 def save server.synchronize do regenerate_file(path, 0o644) do |new| new.write(OsCtl::Lib::ConfigFile.dump_yaml(dump)) end end end |