
Puppet providers can express what features they can provide using the has_features variable. The declaration of features isn't inherited, so we need to declare the features that we inherited from the core pip provider. Change-Id: I2f4c6254bb7f45649658d6a6b296ea1270ce6364
32 lines
797 B
Ruby
32 lines
797 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('-')[1].match('Latest: (.*) ')[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
|