Class: Inspec::Resources::Lxc
- Inherits:
-
Object
- Object
- Inspec::Resources::Lxc
- Defined in:
- lib/inspec/resources/lxc.rb
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(container_name) ⇒ Lxc
constructor
Resource initialization.
- #resource_id ⇒ Object
- #running? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(container_name) ⇒ Lxc
Resource initialization.
16 17 18 19 20 |
# File 'lib/inspec/resources/lxc.rb', line 16 def initialize(container_name) @container_name = container_name raise Inspec::Exceptions::ResourceSkipped, "The `lxc` resource is not supported on your OS yet." unless inspec.os.linux? end |
Instance Method Details
#exists? ⇒ Boolean
30 31 32 |
# File 'lib/inspec/resources/lxc.rb', line 30 def exists? lxc_info_cmd.exit_status.to_i == 0 end |
#resource_id ⇒ Object
22 23 24 |
# File 'lib/inspec/resources/lxc.rb', line 22 def resource_id @container_name end |
#running? ⇒ Boolean
34 35 36 37 |
# File 'lib/inspec/resources/lxc.rb', line 34 def running? container_info = lxc_info_cmd.stdout.split(":").map(&:strip) container_info[0] == "Status" && container_info[1] == "Running" end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/inspec/resources/lxc.rb', line 26 def to_s "lxc #{resource_id}" end |