Class: OpenVZ::Inventory
- Inherits:
-
ConfigHash
- Object
- ConfigHash
- OpenVZ::Inventory
- Defined in:
- lib/openvz/inventory.rb
Instance Method Summary collapse
-
#ids ⇒ Object
Returns cotainers’ id as a array of strings.
-
#initialize ⇒ Inventory
constructor
A new instance of Inventory.
- #load ⇒ Object
- #to_hash ⇒ Object
Methods inherited from ConfigHash
#[], #[]=, #method_missing, #update!
Constructor Details
#initialize ⇒ Inventory
Returns a new instance of Inventory.
3 4 5 |
# File 'lib/openvz/inventory.rb', line 3 def initialize() @vzlist = "/usr/sbin/vzlist" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OpenVZ::ConfigHash
Instance Method Details
#ids ⇒ Object
Returns cotainers’ id as a array of strings
17 18 19 |
# File 'lib/openvz/inventory.rb', line 17 def ids Util.execute("#{@vzlist} -a1").split end |
#load ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/openvz/inventory.rb', line 7 def load Util.execute("#{@vzlist} -a").each_line { |l| # inventarize a container object for each avaiable container. if l =~ /^\s+(\d+)\s+(.*)\s+(running|stopped)\s+(.*)\s\s(.*)$/ self[$1] = Container.new($1) end } end |
#to_hash ⇒ Object
21 22 23 |
# File 'lib/openvz/inventory.rb', line 21 def to_hash @data end |