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(data = {}) ⇒ Inventory
constructor
A new instance of Inventory.
- #load ⇒ Object
- #to_hash ⇒ Object
Methods inherited from ConfigHash
#[], #[]=, #method_missing, #update!
Constructor Details
#initialize(data = {}) ⇒ Inventory
Returns a new instance of Inventory.
3 4 5 6 7 |
# File 'lib/openvz/inventory.rb', line 3 def initialize(data={}) @data = {} update!(data) @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
19 20 21 |
# File 'lib/openvz/inventory.rb', line 19 def ids Util.execute("#{@vzlist} -a1").split end |
#load ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/openvz/inventory.rb', line 9 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
23 24 25 |
# File 'lib/openvz/inventory.rb', line 23 def to_hash @data end |