Class: Inspec::Resources::Lxc

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

Instance Method Summary collapse

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/inspec/resources/lxc.rb', line 30

def exists?
  lxc_info_cmd.exit_status.to_i == 0
end

#resource_idObject



22
23
24
# File 'lib/inspec/resources/lxc.rb', line 22

def resource_id
  @container_name
end

#running?Boolean

Returns:

  • (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_sObject



26
27
28
# File 'lib/inspec/resources/lxc.rb', line 26

def to_s
  "lxc #{resource_id}"
end