forked from puppetlabs/puppetlabs-lvm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add physical_volume and filesystems, remove logical volume resizing.
Basic functions should be in for all providers, removed logical volume resizing for the moment (it also requires filesystem unmounting, resizing, and remounting); for MVP testing purposes it makes sense to get this out in create/destroy form first (size is only one of many possible options that we may want to support as modifiable properties).
- Loading branch information
Bruce Williams
committed
Jan 27, 2010
1 parent
1df8f51
commit 1918167
Showing
21 changed files
with
189 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Puppet::Type.type(:filesystem).provide :lvm do | ||
desc "Manages LVM volume groups" | ||
|
||
commands :df => 'df' | ||
|
||
def create(new_fstype) | ||
mkfs(new_fstype) | ||
end | ||
|
||
def fstype | ||
info[@resource[:name]]['fstype'] | ||
end | ||
|
||
def mkfs(new_fstype) | ||
execute ["mkfs.#{new_fstype}", @resource[:name]] | ||
end | ||
|
||
def info | ||
fields = %w(fstype size used avail used_percentage mounted) | ||
df('-h', '-T').split(/\n/)[1..-1].inject({}) do |records, line| | ||
parts = line.split(/\s+/) | ||
records[parts.shift] = Hash[*(fields.zip(parts).flatten)] | ||
records | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Puppet::Type.type(:physical_volume).provide(:lvm) do | ||
desc "Manages LVM physical volumes" | ||
|
||
commands :pvcreate => 'pvcreate', :pvdestroy => 'pvdestroy' | ||
|
||
def create | ||
pvcreate(@resource[:name]) | ||
end | ||
|
||
def destroy | ||
pvdestroy(@resource[:name]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Filesystem Type Size Used Avail Use% Mounted on | ||
/dev/sda1 ext3 19G 1.8G 16G 10% / | ||
tmpfs tmpfs 257M 0 257M 0% /lib/init/rw | ||
varrun tmpfs 257M 44K 257M 1% /var/run | ||
varlock tmpfs 257M 0 257M 0% /var/lock | ||
x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bruce@rimal.3464 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Filesystem Type Size Used Avail Use% Mounted on | ||
/dev/sda1 ext3 19G 1.8G 16G 10% / | ||
tmpfs tmpfs 257M 0 257M 0% /lib/init/rw | ||
varrun tmpfs 257M 44K 257M 1% /var/run | ||
varlock tmpfs 257M 0 257M 0% /var/lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } | ||
|
||
provider_class = Puppet::Type.type(:filesystem).provider(:lvm) | ||
|
||
describe provider_class do | ||
before do | ||
@resource = stub("resource") | ||
@provider = provider_class.new(@resource) | ||
end | ||
|
||
describe 'when creating' do | ||
it "should execute the correct filesystem command" do | ||
@resource.expects(:[]).with(:name).returns('/dev/myvg/mylv') | ||
@provider.expects(:execute).with(['mkfs.ext3', '/dev/myvg/mylv']) | ||
@provider.create('ext3') | ||
end | ||
end | ||
|
||
describe "when collecting info" do | ||
it "should parse the output of 'df'" do | ||
@provider.expects(:df).returns(fixture(:df)) | ||
info = @provider.info | ||
info['/dev/sda1'].should == { | ||
'fstype' => 'ext3', | ||
'size' => '19G', | ||
'used' => '1.8G', | ||
'avail' => '16G', | ||
'used_percentage' => '10%', | ||
'mounted' => '/' | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } | ||
|
||
provider_class = Puppet::Type.type(:physical_volume).provider(:lvm) | ||
|
||
describe provider_class do | ||
before do | ||
@resource = stub("resource") | ||
@provider = provider_class.new(@resource) | ||
end | ||
|
||
describe 'when creating' do | ||
it "should execute the 'pvcreate'" do | ||
@resource.expects(:[]).with(:name).returns('/dev/hdx') | ||
@provider.expects(:pvcreate).with('/dev/hdx') | ||
@provider.create | ||
end | ||
end | ||
|
||
describe 'when destroying' do | ||
it "should execute 'pvdestroy'" do | ||
@resource.expects(:[]).with(:name).returns('/dev/hdx') | ||
@provider.expects(:pvdestroy).with('/dev/hdx') | ||
@provider.destroy | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.