Sha256: e20841fecb6e6b4d8e7e0dc0dee99b0e8e94bed9e74e3e7c2acab88b603ce42d

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

module OpenVZ
    class Inventory < ConfigHash
        def load
            s = Shell.new("/usr/sbin/vzlist -a", :cwd => "/tmp")
            s.runcommand

            ret_code = s.status
            if ret_code != 0
                raise StandardError, "Execution of shell command failed. Command: #{s.command} RC: #{ret_code} Error: #{s.stderr}\n\n"
            end

            s.stdout.each { |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

        def to_hash
            @data
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openvz-1.5 lib/openvz/inventory.rb
openvz-1.4 lib/openvz/inventory.rb