Merge "Use :commands interface for trove-manage"

This commit is contained in:
Zuul 2023-11-17 18:16:07 +00:00 committed by Gerrit Code Review
commit d4233a6360
5 changed files with 16 additions and 23 deletions

View File

@ -11,6 +11,9 @@ class Puppet::Provider::Trove < Puppet::Provider::Openstack
extend Puppet::Provider::Openstack::Auth extend Puppet::Provider::Openstack::Auth
initvars # so commands will work
commands :trove_manage => 'trove-manage'
def self.request(service, action, properties=nil) def self.request(service, action, properties=nil)
begin begin
super super
@ -106,8 +109,6 @@ class Puppet::Provider::Trove < Puppet::Provider::Openstack
end end
def trove_manage(*args) def trove_manage(*args)
cmd = args.join(" ") execute([command(:trove_manage)] + args)
output = `#{cmd}`
$?.exitstatus
end end
end end

View File

@ -37,18 +37,11 @@ Puppet::Type.type(:trove_datastore).provide(
end end
def create def create
if trove_manage(['trove-manage', 'datastore_update', trove_manage(['datastore_update', "#{@resource[:name]}", "''"])
"#{@resource[:name]}", "''"]) != 0
fail("Failed to create datastore #{@resource[:name]}")
end
if @resource[:version] if @resource[:version]
if trove_manage(['trove-manage', 'datastore_update', trove_manage(['datastore_update', "#{@resource[:name]}", "#{@resource[:version]}"])
"#{@resource[:name]}", "#{@resource[:version]}"]) != 0
fail("Failed to set version for datastore #{@resource[:name]}")
end
end end
end end
end end

View File

@ -34,13 +34,12 @@ Puppet::Type.type(:trove_datastore_version).provide(
end end
def create def create
cmd = ['trove-manage', 'datastore_version_update', trove_manage([
"#{@resource[:datastore]}", "#{@resource[:name]}", 'datastore_version_update',
"#{@resource[:manager]}", "#{@resource[:image_id]}", "#{@resource[:datastore]}", "#{@resource[:name]}",
"#{@resource[:packages]}", "#{@resource[:active]}"] "#{@resource[:manager]}", "#{@resource[:image_id]}",
if trove_manage(cmd) != 0 "#{@resource[:packages]}", "#{@resource[:active]}"
fail("Failed to create datastore version #{@resource[:name]}") ])
end
end end
def destroy def destroy

View File

@ -57,7 +57,7 @@ describe provider_class do
context 'without version' do context 'without version' do
it 'creates datastore' do it 'creates datastore' do
expect(provider).to receive(:trove_manage) expect(provider).to receive(:trove_manage)
.with(['trove-manage', 'datastore_update', datastore_name, "''"]) .with(['datastore_update', datastore_name, "''"])
.and_return(0) .and_return(0)
provider.create provider.create
end end
@ -72,11 +72,11 @@ describe provider_class do
it 'creates datastore' do it 'creates datastore' do
expect(provider).to receive(:trove_manage) expect(provider).to receive(:trove_manage)
.with(['trove-manage', 'datastore_update', datastore_name, "''"]) .with(['datastore_update', datastore_name, "''"])
.and_return(0) .and_return(0)
expect(provider).to receive(:trove_manage) expect(provider).to receive(:trove_manage)
.with(['trove-manage', 'datastore_update', datastore_name, "0.1"]) .with(['datastore_update', datastore_name, "0.1"])
.and_return(0) .and_return(0)
provider.create provider.create
end end

View File

@ -50,7 +50,7 @@ describe provider_class do
describe '#create' do describe '#create' do
it 'should call trove-manage' do it 'should call trove-manage' do
expect(provider). to receive(:trove_manage).with( expect(provider). to receive(:trove_manage).with(
['trove-manage', 'datastore_version_update', datastore_name, ['datastore_version_update', datastore_name,
datastore_version, 'mysql', '1234', 'mysql', '1'] datastore_version, 'mysql', '1234', 'mysql', '1']
).and_return(0) ).and_return(0)