Skip to content

Commit 0121420

Browse files
Datastore provider supports setting basepath.
* acceptance test included as example.
1 parent 1936d3f commit 0121420

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/puppet/provider/onedatastore/cli.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ def exists?
6161
def self.get_datastore(xml)
6262
datastore_hash = Hash.new
6363
get_attributes.each do |node|
64-
if node == :type
64+
if node == :base_path
65+
## removes a char, one or more digits from the end
66+
# required to match basepath /tmp vs /tmp/102
67+
text = xml.css("#{node.to_s.upcase}").first.text.sub!(/.\d+\z/, '')
68+
datastore_hash[node] = text
69+
elsif node == :type
6570
case xml.css("#{node.to_s.upcase}").first.text
6671
when '0' then text = 'IMAGE_DS'
6772
when '1' then text = 'SYSTEM_DS'

spec/acceptance/onedatastore_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ class { 'one':
5555
end
5656
end
5757

58+
context "with custom basepath" do
59+
it 'should idempotently run' do
60+
pp = <<-EOS
61+
onedatastore { 'nfs_ds':
62+
ensure => present,
63+
type => 'system_ds',
64+
tm_mad => 'shared',
65+
driver => 'raw',
66+
disk_type => 'file',
67+
base_path => '/tmp',
68+
}
69+
EOS
70+
71+
apply_manifest(pp, :catch_failures => true)
72+
apply_manifest(pp, :catch_changes => true)
73+
end
74+
end
5875
end
5976

6077
describe 'when creating a File datastore' do

0 commit comments

Comments
 (0)