Class: Inspec::Resources::ZfsPool
- Inherits:
-
Object
- Object
- Inspec::Resources::ZfsPool
- Defined in:
- lib/resources/zfs_pool.rb
Instance Method Summary collapse
-
#exists? ⇒ Boolean
method called by ‘it { should exist }’.
- #gather ⇒ Object
-
#initialize(zfs_pool) ⇒ ZfsPool
constructor
A new instance of ZfsPool.
-
#method_missing(name) ⇒ Object
expose all parameters.
- #to_s ⇒ Object
Constructor Details
#initialize(zfs_pool) ⇒ ZfsPool
Returns a new instance of ZfsPool.
17 18 19 20 21 22 |
# File 'lib/resources/zfs_pool.rb', line 17 def initialize(zfs_pool) return skip_resource 'The `zfs_pool` resource is not supported on your OS yet.' if !inspec.os.bsd? @zfs_pool = zfs_pool @params = gather end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
expose all parameters
45 46 47 |
# File 'lib/resources/zfs_pool.rb', line 45 def method_missing(name) @params[name.to_s] end |
Instance Method Details
#exists? ⇒ Boolean
method called by ‘it { should exist }’
25 26 27 |
# File 'lib/resources/zfs_pool.rb', line 25 def exists? inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}").exit_status == 0 end |
#gather ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/resources/zfs_pool.rb', line 33 def gather cmd = inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}") return nil if cmd.exit_status.to_i != 0 # parse data cmd.stdout.chomp.split("\n").each_with_object(Hash.new(0)) do |line, h| t = line.split("\t") h[t[1].to_s] = t[2].to_s end end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/resources/zfs_pool.rb', line 29 def to_s "ZFS Pool #{@zfs_pool}" end |