puppet-trove/lib/puppet/provider/trove_datastore/trove.rb
Takashi Kajinami ead07878ba trove_datastore: Make version optional
datastore version can't be used until the version is registered but we
can't register the version before we register datastore before applying
catalog. This makes version optional to avoid that dependency look.

Partial-Bug: #2007961
Change-Id: Ieba9c10b49f41980555e2734bb29415fcf0b585f
2023-02-23 17:47:22 +00:00

55 lines
1.3 KiB
Ruby

require File.join(File.dirname(__FILE__), "..","..","..",
"puppet/provider/trove")
Puppet::Type.type(:trove_datastore).provide(
:trove,
:parent => Puppet::Provider::Trove
) do
desc <<-EOT
Trove provider to manage datastore type.
EOT
mk_resource_methods
@credentials = Puppet::Provider::Openstack::CredentialsV3.new
def self.instances
request('datastore', 'list').collect do |attrs|
new(
:ensure => :present,
:name => attrs[:name],
:id => attrs[:id]
)
end
end
def self.prefetch(resources)
instances_ = instances
resources.keys.each do |name|
if provider = instances_.find{ |instance| instance.name == name }
resources[name].provider = provider
end
end
end
def exists?
@property_hash[:ensure] == :present
end
def create
if trove_manage(['trove-manage', 'datastore_update',
"#{@resource[:name]}", "''"]) != 0
fail("Failed to create datastore #{@resource[:name]}")
end
if @resource[:version]
if trove_manage(['trove-manage', 'datastore_update',
"#{@resource[:name]}", "#{@resource[:version]}"]) != 0
fail("Failed to set version for datastore #{@resource[:name]}")
end
end
end
end