Class: Serverspec::Type::NfsExport
- Inherits:
-
Base
- Object
- Base
- Serverspec::Type::NfsExport
- Defined in:
- lib/serverspec_extra_types/types/nfs_export.rb
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#get_inspection ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #has_host?(host_id, option = nil) ⇒ Boolean
- #host(host_id) ⇒ Object
- #hosts ⇒ Object
-
#initialize(name = nil, options = {}) ⇒ NfsExport
constructor
A new instance of NfsExport.
- #inspection ⇒ Object
Constructor Details
#initialize(name = nil, options = {}) ⇒ NfsExport
Returns a new instance of NfsExport.
9 10 11 12 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 9 def initialize(name = nil, = {}) super(name, ) @export = name end |
Instance Method Details
#exists? ⇒ Boolean
14 15 16 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 14 def exists? get_inspection.success? end |
#get_inspection ⇒ Object
rubocop:disable Naming/AccessorMethodName
46 47 48 49 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 46 def get_inspection command = "grep #{@export} /etc/exports" @get_inspection ||= @runner.run_command(command) end |
#has_host?(host_id, option = nil) ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 18 def has_host?(host_id, option = nil) if option (host_id, option) else hosts.key?(host_id) end end |
#host(host_id) ⇒ Object
37 38 39 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 37 def host(host_id) hosts[host_id] end |
#hosts ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 26 def hosts unless @hosts @hosts = {} inspection.split(' ')[1..-1].each do |item| (host, ) = item.split('(') @hosts[host] = .split(')')[0].split(',') end end @hosts end |
#inspection ⇒ Object
41 42 43 |
# File 'lib/serverspec_extra_types/types/nfs_export.rb', line 41 def inspection @inspection ||= get_inspection.stdout end |