Skip to content

Commit 9e7fe6d

Browse files
Merge pull request #202 from endocode/master
Datastore provider supports setting basepath.
2 parents eda17fa + 0121420 commit 9e7fe6d

2 files changed

Lines changed: 58 additions & 4 deletions

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: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,66 @@ class { 'one':
1212
end
1313

1414
describe 'when creating a System datastore' do
15-
it 'should idempotently run' do
15+
16+
after(:each) do
1617
pp = <<-EOS
1718
onedatastore { 'nfs_ds':
18-
tm_mad => 'shared',
19-
type => 'system_ds',
19+
ensure => absent,
2020
}
2121
EOS
2222

2323
apply_manifest(pp, :catch_failures => true)
2424
apply_manifest(pp, :catch_changes => true)
2525
end
26+
27+
context "with default values" do
28+
it 'should idempotently run' do
29+
pp = <<-EOS
30+
onedatastore { 'nfs_ds':
31+
tm_mad => 'shared',
32+
type => 'system_ds',
33+
}
34+
EOS
35+
36+
apply_manifest(pp, :catch_failures => true)
37+
apply_manifest(pp, :catch_changes => true)
38+
end
39+
end
40+
41+
context "with custom values" do
42+
it 'should idempotently run' do
43+
pp = <<-EOS
44+
onedatastore { 'nfs_ds':
45+
ensure => present,
46+
type => 'system_ds',
47+
tm_mad => 'shared',
48+
driver => 'raw',
49+
disk_type => 'file',
50+
}
51+
EOS
52+
53+
apply_manifest(pp, :catch_failures => true)
54+
apply_manifest(pp, :catch_changes => true)
55+
end
56+
end
57+
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
2675
end
2776

2877
describe 'when creating a File datastore' do

0 commit comments

Comments
 (0)