
This change updates the require statements in the providers to resolve the issues with the autoloader in puppet. This issue technically always existed but was masked prior to the split with puppet server and puppet agent because both used to share the same loadpath. Documentation on this issue can be read at https://tickets.puppetlabs.com/browse/PUP-4450. Change-Id: I5eae546d65832a39dd75ab9c0f97868c7edc9e91
105 lines
2.9 KiB
Ruby
105 lines
2.9 KiB
Ruby
require File.join(File.dirname(__FILE__), '..','..','..', 'puppet/provider/keystone')
|
|
|
|
Puppet::Type.type(:keystone_service).provide(
|
|
:openstack,
|
|
:parent => Puppet::Provider::Keystone
|
|
) do
|
|
|
|
desc "Provider to manage keystone services."
|
|
|
|
@credentials = Puppet::Provider::Openstack::CredentialsV3.new
|
|
|
|
include PuppetX::Keystone::CompositeNamevar::Helpers
|
|
|
|
def initialize(value = {})
|
|
super(value)
|
|
@property_flush = {}
|
|
end
|
|
|
|
def self.do_not_manage
|
|
@do_not_manage
|
|
end
|
|
|
|
def self.do_not_manage=(value)
|
|
@do_not_manage = value
|
|
end
|
|
|
|
def create
|
|
if self.class.do_not_manage
|
|
fail("Not managing Keystone_service[#{@resource[:name]}] due to earlier Keystone API failures.")
|
|
end
|
|
properties = [resource[:type]]
|
|
properties << '--name' << resource[:name]
|
|
if resource[:description]
|
|
properties << '--description' << resource[:description]
|
|
end
|
|
created = self.class.request('service', 'create', properties)
|
|
@property_hash[:ensure] = :present
|
|
@property_hash[:type] = resource[:type]
|
|
@property_hash[:id] = created[:id]
|
|
@property_hash[:description] = resource[:description]
|
|
end
|
|
|
|
def destroy
|
|
if self.class.do_not_manage
|
|
fail("Not managing Keystone_service[#{@resource[:name]}] due to earlier Keystone API failures.")
|
|
end
|
|
self.class.request('service', 'delete', @property_hash[:id])
|
|
@property_hash.clear
|
|
end
|
|
|
|
def exists?
|
|
@property_hash[:ensure] == :present
|
|
end
|
|
|
|
mk_resource_methods
|
|
|
|
def description=(value)
|
|
if self.class.do_not_manage
|
|
fail("Not managing Keystone_service[#{@resource[:name]}] due to earlier Keystone API failures.")
|
|
end
|
|
@property_flush[:description] = value
|
|
end
|
|
|
|
def type=(value)
|
|
if self.class.do_not_manage
|
|
fail("Not managing Keystone_service[#{@resource[:name]}] due to earlier Keystone API failures.")
|
|
end
|
|
@property_flush[:type] = value
|
|
end
|
|
|
|
def self.instances
|
|
self.do_not_manage = true
|
|
list = request('service', 'list', '--long')
|
|
reallist = list.collect do |service|
|
|
new(
|
|
:name => resource_to_name(service[:type], service[:name], false),
|
|
:ensure => :present,
|
|
:type => service[:type],
|
|
:description => service[:description],
|
|
:id => service[:id]
|
|
)
|
|
end
|
|
self.do_not_manage = false
|
|
reallist
|
|
end
|
|
|
|
def self.prefetch(resources)
|
|
prefetch_composite(resources) do |sorted_namevars|
|
|
name = sorted_namevars[0]
|
|
type = sorted_namevars[1]
|
|
resource_to_name(type, name, false)
|
|
end
|
|
end
|
|
|
|
def flush
|
|
options = []
|
|
if @property_flush && !@property_flush.empty?
|
|
options << "--description=#{resource[:description]}" if @property_flush[:description]
|
|
options << "--type=#{resource[:type]}" if @property_flush[:type]
|
|
self.class.request('service', 'set', [@property_hash[:id]] + options) unless options.empty?
|
|
@property_flush.clear
|
|
end
|
|
end
|
|
end
|