diff --git a/lib/puppet/provider/trove.rb b/lib/puppet/provider/trove.rb index 8ec14c11..a59f070f 100644 --- a/lib/puppet/provider/trove.rb +++ b/lib/puppet/provider/trove.rb @@ -11,6 +11,9 @@ class Puppet::Provider::Trove < Puppet::Provider::Openstack extend Puppet::Provider::Openstack::Auth + initvars # so commands will work + commands :trove_manage => 'trove-manage' + def self.request(service, action, properties=nil) begin super @@ -106,8 +109,6 @@ class Puppet::Provider::Trove < Puppet::Provider::Openstack end def trove_manage(*args) - cmd = args.join(" ") - output = `#{cmd}` - $?.exitstatus + execute([command(:trove_manage)] + args) end end diff --git a/lib/puppet/provider/trove_datastore/trove.rb b/lib/puppet/provider/trove_datastore/trove.rb index 009ec4f7..75dd775e 100644 --- a/lib/puppet/provider/trove_datastore/trove.rb +++ b/lib/puppet/provider/trove_datastore/trove.rb @@ -37,18 +37,11 @@ Puppet::Type.type(:trove_datastore).provide( end def create - if trove_manage(['trove-manage', 'datastore_update', - "#{@resource[:name]}", "''"]) != 0 - fail("Failed to create datastore #{@resource[:name]}") - end + trove_manage(['datastore_update', "#{@resource[:name]}", "''"]) 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 + trove_manage(['datastore_update', "#{@resource[:name]}", "#{@resource[:version]}"]) end end - end diff --git a/lib/puppet/provider/trove_datastore_version/trove.rb b/lib/puppet/provider/trove_datastore_version/trove.rb index f0f90cb7..d0ccd14a 100644 --- a/lib/puppet/provider/trove_datastore_version/trove.rb +++ b/lib/puppet/provider/trove_datastore_version/trove.rb @@ -34,13 +34,12 @@ Puppet::Type.type(:trove_datastore_version).provide( end def create - cmd = ['trove-manage', 'datastore_version_update', - "#{@resource[:datastore]}", "#{@resource[:name]}", - "#{@resource[:manager]}", "#{@resource[:image_id]}", - "#{@resource[:packages]}", "#{@resource[:active]}"] - if trove_manage(cmd) != 0 - fail("Failed to create datastore version #{@resource[:name]}") - end + trove_manage([ + 'datastore_version_update', + "#{@resource[:datastore]}", "#{@resource[:name]}", + "#{@resource[:manager]}", "#{@resource[:image_id]}", + "#{@resource[:packages]}", "#{@resource[:active]}" + ]) end def destroy diff --git a/spec/unit/provider/trove_datastore/trove_spec.rb b/spec/unit/provider/trove_datastore/trove_spec.rb index 359b7ac7..1ad82d68 100644 --- a/spec/unit/provider/trove_datastore/trove_spec.rb +++ b/spec/unit/provider/trove_datastore/trove_spec.rb @@ -57,7 +57,7 @@ describe provider_class do context 'without version' do it 'creates datastore' do expect(provider).to receive(:trove_manage) - .with(['trove-manage', 'datastore_update', datastore_name, "''"]) + .with(['datastore_update', datastore_name, "''"]) .and_return(0) provider.create end @@ -72,11 +72,11 @@ describe provider_class do it 'creates datastore' do expect(provider).to receive(:trove_manage) - .with(['trove-manage', 'datastore_update', datastore_name, "''"]) + .with(['datastore_update', datastore_name, "''"]) .and_return(0) 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) provider.create end diff --git a/spec/unit/provider/trove_datastore_version/trove_spec.rb b/spec/unit/provider/trove_datastore_version/trove_spec.rb index ece57753..1ae57803 100644 --- a/spec/unit/provider/trove_datastore_version/trove_spec.rb +++ b/spec/unit/provider/trove_datastore_version/trove_spec.rb @@ -50,7 +50,7 @@ describe provider_class do describe '#create' do it 'should call trove-manage' do 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'] ).and_return(0)