Method: AugeasProviders::Mounttab::Fstab.insoptions

Defined in:
lib/augeasproviders/mounttab/fstab.rb

.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.insoptions(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