Class: Inspec::Resources::Lxc

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container_name) ⇒ Lxc

Resource initialization.



26
27
28
29
30
31
32
# File 'lib/inspec/resources/lxc.rb', line 26

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?

  @container_info = populate_container_info
end

Instance Attribute Details

#container_infoObject (readonly)

Returns the value of attribute container_info.



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

def container_info
  @container_info
end

#container_nameObject (readonly)

Returns the value of attribute container_name.



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

def container_name
  @container_name
end

Instance Method Details

#architectureObject



62
63
64
# File 'lib/inspec/resources/lxc.rb', line 62

def architecture
  @container_info["Architecture"]
end

#created_atObject



70
71
72
# File 'lib/inspec/resources/lxc.rb', line 70

def created_at
  @container_info["Created"]
end

#exists?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/inspec/resources/lxc.rb', line 42

def exists?
  !@container_info.empty?
end

#last_used_atObject



74
75
76
# File 'lib/inspec/resources/lxc.rb', line 74

def last_used_at
  @container_info["Last Used"]
end

#nameObject



50
51
52
# File 'lib/inspec/resources/lxc.rb', line 50

def name
  @container_info["Name"]
end

#pidObject



66
67
68
# File 'lib/inspec/resources/lxc.rb', line 66

def pid
  @container_info["PID"]
end

#resource_idObject



34
35
36
# File 'lib/inspec/resources/lxc.rb', line 34

def resource_id
  @container_name
end

#resourcesObject



78
79
80
# File 'lib/inspec/resources/lxc.rb', line 78

def resources
  @container_info["Resources"]
end

#running?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/inspec/resources/lxc.rb', line 46

def running?
  @container_info.key?("Status") && @container_info["Status"].casecmp("Running") == 0
end

#statusObject



54
55
56
# File 'lib/inspec/resources/lxc.rb', line 54

def status
  @container_info["Status"]
end

#to_sObject



38
39
40
# File 'lib/inspec/resources/lxc.rb', line 38

def to_s
  "lxc #{resource_id}"
end

#typeObject



58
59
60
# File 'lib/inspec/resources/lxc.rb', line 58

def type
  @container_info["Type"]
end