Class: AugeasProviders::Mounttab::Fstab
- Inherits:
-
Object
- Object
- AugeasProviders::Mounttab::Fstab
- Defined in:
- lib/augeasproviders/mounttab/fstab.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Class Method Summary collapse
- .atboot(aug, resource) ⇒ Object
- .create(aug, resource) ⇒ Object
- .default_file ⇒ Object
- .dump(aug, resource) ⇒ Object
- .empty_options ⇒ Object
- .get_resource(aug, mpath, target) ⇒ Object
- .insoptions(aug, entry, resource) ⇒ Object
- .lens ⇒ Object
- .pass(aug, resource) ⇒ Object
- .set_atboot(aug, resource, value) ⇒ Object
- .set_dump(aug, resource, value) ⇒ Object
- .set_pass(aug, resource, value) ⇒ Object
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
15 16 17 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 15 def resource @resource end |
Class Method Details
.atboot(aug, resource) ⇒ Object
113 114 115 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 113 def self.atboot(aug, resource) resource.should(:atboot) end |
.create(aug, resource) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 48 def self.create(aug, resource) aug.set("$resource/spec", resource[:device]) aug.set("$resource/file", resource[:name]) aug.set("$resource/vfstype", resource[:fstype]) (aug, "$resource", resource) aug.set("$resource/dump", resource[:dump].to_s) aug.set("$resource/passno", resource[:pass].to_s) end |
.default_file ⇒ Object
17 18 19 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 17 def self.default_file '/etc/fstab' end |
.dump(aug, resource) ⇒ Object
80 81 82 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 80 def self.dump(aug, resource) aug.get("$target/*[file = '#{resource[:name]}']/dump") end |
.empty_options ⇒ Object
121 122 123 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 121 def self. ['', 'defaults'] end |
.get_resource(aug, mpath, target) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 25 def self.get_resource(aug, mpath, target) entry = { :ensure => :present, :target => target } return nil unless entry[:name] = aug.get("#{mpath}/file") entry[:device] = aug.get("#{mpath}/spec") entry[:fstype] = aug.get("#{mpath}/vfstype") = [] aug.match("#{mpath}/opt").each do |opath| opt = aug.get(opath) optv = aug.get("#{opath}/value") opt = "#{opt}=#{optv}" if optv << opt end entry[:options] = entry[:pass] = aug.get("#{mpath}/passno") if aug.match("#{mpath}/passno") entry[:dump] = aug.get("#{mpath}/dump") if aug.match("#{mpath}/dump") entry end |
.insoptions(aug, entry, resource) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 57 def self.(aug, entry, resource) # Options are defined as a list property, so they get joined with commas. # Since Augeas understands elements, access the original array or string. values = resource.original_parameters[:options] aug.rm("#{entry}/opt") insafter = "vfstype" if values and not values.empty? [values].flatten.each do |opt| optk, optv = opt.split("=", 2) aug.insert("#{entry}/#{insafter}", "opt", false) aug.set("#{entry}/opt[last()]", optk) aug.set("#{entry}/opt[last()]/value", optv) if optv insafter = "opt[last()]" end else # Strictly this is optional, but only Augeas > 0.10.0 has a lens that # knows this is the case, so always fill it in. aug.insert("#{entry}/#{insafter}", "opt", false) aug.set("#{entry}/opt", "defaults") end end |
.lens ⇒ Object
21 22 23 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 21 def self.lens 'Fstab.lns' end |
.pass(aug, resource) ⇒ Object
94 95 96 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 94 def self.pass(aug, resource) aug.get("$target/*[file = '#{resource[:name]}']/passno") end |
.set_atboot(aug, resource, value) ⇒ Object
117 118 119 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 117 def self.set_atboot(aug, resource, value) return end |
.set_dump(aug, resource, value) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 84 def self.set_dump(aug, resource, value) # Ensure "defaults" option is always set if dump is being set, as the # opts field is optional if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults") end aug.set("$target/*[file = '#{resource[:name]}']/dump", value.to_s) end |
.set_pass(aug, resource, value) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/augeasproviders/mounttab/fstab.rb', line 98 def self.set_pass(aug, resource, value) # Ensure "defaults" option is always set if passno is being set, as the # opts field is optional if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults") end # Ensure dump is always set too if aug.match("$target/*[file = '#{resource[:name]}']/dump").empty? aug.set("$target/*[file = '#{resource[:name]}']/dump", "0") end aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s) end |