Class: Inspec::Resources::Zfs

Inherits:
ZfsPool
  • Object
show all
Defined in:
lib/inspec/resources/zfs.rb

Instance Method Summary collapse

Methods inherited from ZfsPool

#exists?, #gather, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Inspec::Resources::ZfsPool

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Inspec::Resources::ZfsPool

Instance Method Details

#has_property?(properties_hash) ⇒ Boolean

The below matcher checks if the given properties are valid properties of the zfs pool.

Returns:

  • (Boolean)

Raises:



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/inspec/resources/zfs.rb', line 34

def has_property?(properties_hash)
  raise Inspec::Exceptions::ResourceSkipped, "Provide a valid key-value pair of the zfs properties." if properties_hash.empty?

  # Transform all the key & values provided by user to string,
  # since hash keys can be symbols or strings & values can be integers or strings.
  # @params is a hash populated in the parent class with the properties(key-value) of the current zfs pool.
  # and the key-value in @params are of string type.
  properties_hash.transform_keys(&:to_s)
  properties_hash.transform_values(&:to_s)

  # check if the given properties is a subset of @params
  properties_hash <= @params
end

#resource_idObject

Unique identity for the resource.



23
24
25
26
# File 'lib/inspec/resources/zfs.rb', line 23

def resource_id
  # @zfs_pool is the zfs pool name assigned during initialization in the parent class i.e. ZfsPool
  @zfs_pool
end

#to_sObject

Resource appearance in test reports.



29
30
31
# File 'lib/inspec/resources/zfs.rb', line 29

def to_s
  "zfs #{resource_id}"
end