Sha256: 31a9a6b5230483fa388a6a8cc30b42e487f60080cfb0cbcb9886ea62bca09048

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 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
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openvz-1.2 lib/openvz/inventory.rb
openvz-1.1 lib/openvz/inventory.rb