Class: AugeasProviders::Mounttab::Vfstab
- Inherits:
-
Object
- Object
- AugeasProviders::Mounttab::Vfstab
- Defined in:
- lib/augeasproviders/mounttab/vfstab.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 Method Summary collapse
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
15 16 17 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 15 def resource @resource end |
Class Method Details
.atboot(aug, resource) ⇒ Object
107 108 109 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 107 def self.atboot(aug, resource) aug.get("$target/*[file = '#{resource[:name]}']/atboot") end |
.create(aug, resource) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 53 def self.create(aug, resource) aug.set("$resource/spec", resource[:device]) if resource[:blockdevice] and resource[:blockdevice] != "" aug.set("$resource/fsck", resource[:blockdevice]) end aug.set("$resource/file", resource[:name]) aug.set("$resource/vfstype", resource[:fstype]) aug.set("$resource/passno", resource[:pass].to_s) unless resource[:pass] == "-" aug.set("$resource/atboot", resource[:atboot].to_s) (aug, "$resource", resource) end |
.default_file ⇒ Object
17 18 19 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 17 def self.default_file '/etc/vfstab' end |
.dump(aug, resource) ⇒ Object
84 85 86 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 84 def self.dump(aug, resource) resource.should(:dump) end |
.empty_options ⇒ Object
115 116 117 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 115 def self. ['', '-'] 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 47 48 49 50 51 |
# File 'lib/augeasproviders/mounttab/vfstab.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") entry[:blockdevice] = (aug.get("#{mpath}/fsck") or "-") entry[:pass] = (aug.get("#{mpath}/passno") or "-") entry[:atboot] = aug.get("#{mpath}/atboot") = [] 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] = if .empty? "-" else end entry end |
.insoptions(aug, entry, resource) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 69 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") if values and not values.empty? [values].flatten.each do |opt| optk, optv = opt.split("=", 2) aug.set("#{entry}/opt[last()+1]", optk) aug.set("#{entry}/opt[last()]/value", optv) if optv end end end |
.lens ⇒ Object
21 22 23 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 21 def self.lens 'Vfstab.lns' end |
.pass(aug, resource) ⇒ Object
92 93 94 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 92 def self.pass(aug, resource) aug.get("$target/*[file = '#{resource[:name]}']/passno") or "-" end |
.set_atboot(aug, resource, value) ⇒ Object
111 112 113 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 111 def self.set_atboot(aug, resource, value) aug.set("$target/*[file = '#{resource[:name]}']/atboot", value.to_s) end |
.set_dump(aug, resource, value) ⇒ Object
88 89 90 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 88 def self.set_dump(aug, resource, value) return end |
.set_pass(aug, resource, value) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 96 def self.set_pass(aug, resource, value) if value == "-" aug.rm("$target/*[file = '#{resource[:name]}']/passno") else if aug.match("$target/*[file = '#{resource[:name]}']/passno").empty? aug.insert("$target/*[file = '#{resource[:name]}']/vfstype", "passno", false) end aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s) end end |
Instance Method Details
#target ⇒ Object
65 66 67 |
# File 'lib/augeasproviders/mounttab/vfstab.rb', line 65 def target file(resource) end |