
The output of `pip list --outdated` is different for pip 18. This patch adjusts the openstack_pip provider to handle old and new versions of pip. Depends-On: https://review.openstack.org/646023 Change-Id: I185116a2701688860fa5ca9f8ef34d6dbecd0174
40 lines
991 B
Ruby
40 lines
991 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
|
|
_latest = latest.match('Latest: ([^\s)]*)')
|
|
if _latest
|
|
latest = _latest[1]
|
|
else
|
|
latest = latest.split(' ')[2]
|
|
end
|
|
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
|