Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DRIVER property to onedatastore provider #186

Merged
merged 1 commit into from
Sep 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ onedatastore { '<name>':
type => 'IMAGE_DS' | 'SYSTEM_DS' | 'FILE_DS',
dm => 'fs' | 'vmware' | 'iscsi' | 'lvm' | 'vmfs' | 'ceph',
tm => 'shared' | 'ssh' | 'qcow2' | 'iscsi' | 'lvm' | 'vmfs' | 'ceph' | 'dummy',
driver => 'raw | qcow2',
cephhost => 'cephhost', # (optional: ceph only)
cephuser => 'cephuser', # (optional: ceph only)
cephsecret => 'ceph-secret-here', # (optional: ceph only)
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/provider/onedatastore/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def create
end if resource[:safe_dirs]
xml.DS_MAD resource[:dm]
xml.DISK_TYPE resource[:disktype]
xml.DRIVER resource[:driver]
xml.BRIDGE_LIST resource[:bridgelist]
xml.CEPH_HOST resource[:cephhost]
xml.CEPH_USER resource[:cephuser]
Expand Down Expand Up @@ -80,6 +81,7 @@ def self.instances
:cephsecret => (datastore.xpath('./TEMPLATE/CEPH_SECRET').text unless datastore.xpath('./TEMPLATE/CEPH_SECRET').nil?),
:poolname => (datastore.xpath('./TEMPLATE/POOL_NAME').text unless datastore.xpath('./TEMPLATE/POOL_NAME').nil?),
:stagingdir => (datastore.xpath('./TEMPLATE/STAGING_DIR').text unless datastore.xpath('./TEMPLATE/STAGING_DIR').nil?),
:driver => (datastore.xpath('./TEMPLATE/DRIVER').text unless datastore.xpath('./TEMPLATE/DRIVER').nil?),
:disktype => {'0' => 'file', '1' => 'block', '3' => 'rbd'}[datastore.xpath('./DISK_TYPE').text]
)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/type/onedatastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
desc "Choose a disk type: file, block, rdb"
end

newproperty(:driver) do
desc "Choose a driver: raw, qcow2"
end

newproperty(:basepath) do
desc "Choose a base path"
end
Expand Down
1 change: 1 addition & 0 deletions spec/acceptance/onedatastore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class { 'one':
onedatastore { 'ceph_ds':
dm => 'ceph',
tm => 'ceph',
driver => 'raw',
cephhost => 'cephhost',
cephuser => 'cephuser',
cephsecret => 'cephsecret',
Expand Down
9 changes: 7 additions & 2 deletions spec/type/onedatastore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
res_type.key_attributes.should == [:name]
end

properties = [:type, :dm, :tm, :disktype, :cephhost, :cephuser, :cephsecret,
:poolname, :bridgelist]
properties = [:type, :dm, :tm, :disktype, :driver, :cephhost, :cephuser,
:cephsecret, :poolname, :bridgelist]
properties.each do |property|
it "should have a #{property} property" do
described_class.attrclass(property).ancestors.should be_include(Puppet::Property)
Expand Down Expand Up @@ -58,6 +58,11 @@
@datastore[:disktype].should == 'file'
end

it 'should have property :driver' do
@datastore[:driver] = 'qcow2'
@datastore[:driver].should == 'qcow2'
end

it 'should have property :cephhost' do
@datastore[:cephhost] = 'cephhost'
@datastore[:cephhost].should == 'cephhost'
Expand Down