carlasouza / puppet-virt

Puppet Module for Virtualization Management
http://puppetlabs.com
166 stars 72 forks source link

Error messages from vzlist get used as ctids #38

Open drt24 opened 8 years ago

drt24 commented 8 years ago

I got this error message: Error: /Virt[test-1]: Could not evaluate: Execution of '/usr/sbin/vzctl status Unable' returned 21: Bad CT ID Unable

Looking in puppet-virt/lib/puppet/provider/virt/openvz.rb I see:

  # Returns all host's guests
  def self.instances
    guests = []
    execpipe "#{vzlist} --no-header -a -o ctid" do |process|
    process.collect do |line|
      next unless options = parse(line)
        guests << new(options)
      end
    end
    guests
  end

Unfortunately if I run:

    $ sudo vzlist --no-header -a -o ctid

I get

    Unable to open /proc/vz/veinfo: No such file or directory
    Unable to open /proc/user_beancounters: No such file or directory

(as OpenVZ is not properly set up) Unfortunately vzlist does not return an error code in this case. Perhaps some validation of its output would solve this problem and prevent garbage spreading through the code.