puppet-pip/lib/puppet/provider/package/openstack_pip.rb
Alexander Evseev adf639e859 Fix openstack_pip provider to support old pip
Do not split string by hyphen and change regex to match both
formats - new (with hyphen), and old one like
  'pep8 (Current: 1.5.7 Latest: 1.7.0)'

Change-Id: I1eeda1b35ff35dfe8b8b0c6e948616a55f33df25
2016-06-28 17:30:30 +00:00

34 lines
867 B
Ruby

require 'puppet/provider/package'
require 'net/http'
require 'xmlrpc/client'
require 'puppet/util/http_proxy'
Puppet::Type.type(:package).provide(:openstack_pip, :parent => :pip) do
desc "Python packages via `pip` with mirrors."
has_feature :installable, :uninstallable, :upgradeable, :versionable
commands :pip => 'pip'
def self.outdated
@outdated ||= pip(['list', '--outdated'])
end
def latest
outdated = self.class.outdated
if outdated =~ /#{@resource[:name]}/
latest = outdated.split("\n").select { |line|
line =~ /#{@resource[:name]}/
}.first.match('Latest: ([^\s)]*)')[1]
else
package_info = lazy_pip(['show', @resource[:name]])
current = package_info.split("\n").select { |line|
line =~ /^Version/
}.first.split(': ')[1]
latest = current
end
return latest
end
end