bab9bb6b69
Create new directories: ceph config config-files filesystem kernel kernel/kernel-modules ldap logging strorage-drivers tools utilities virt Retire directories: connectivity core devtools support extended Delete two packages: tgt irqbalance Relocated packages: base/ dhcp initscripts libevent lighttpd linuxptp memcached net-snmp novnc ntp openssh pam procps sanlock shadow sudo systemd util-linux vim watchdog ceph/ python-cephclient config/ facter puppet-4.8.2 puppet-modules filesystem/ e2fsprogs nfs-utils nfscheck kernel/ kernel-std kernel-rt kernel/kernel-modules/ mlnx-ofa_kernel ldap/ nss-pam-ldapd openldap logging/ syslog-ng logrotate networking/ lldpd iproute mellanox python-ryu mlx4-config python/ python-2.7.5 python-django python-gunicorn python-setuptools python-smartpm python-voluptuous security/ shim-signed shim-unsigned tboot strorage-drivers/ python-3parclient python-lefthandclient virt/ cloud-init libvirt libvirt-python qemu tools/ storage-topology vm-topology utilities/ tis-extensions namespace-utils nova-utils update-motd Change-Id: I37ade764d873c701b35eac5881eb40412ba64a86 Story: 2002801 Task: 22687 Signed-off-by: Scott Little <scott.little@windriver.com>
695 lines
32 KiB
Diff
695 lines
32 KiB
Diff
From b80e106ace391d88de683c3da5e03878ce1ffa1d Mon Sep 17 00:00:00 2001
|
|
From: Al Bailey <al.bailey@windriver.com>
|
|
Date: Tue, 7 Jun 2016 10:36:17 -0400
|
|
Subject: [PATCH] puppet-lvm kilo quilt changes
|
|
|
|
---
|
|
.../lvm/lib/puppet/provider/logical_volume/lvm.rb | 194 ++++++++++++++-------
|
|
.../lvm/lib/puppet/provider/physical_volume/lvm.rb | 2 +-
|
|
.../lvm/lib/puppet/provider/volume_group/lvm.rb | 60 ++++++-
|
|
.../modules/lvm/lib/puppet/type/logical_volume.rb | 32 +++-
|
|
.../puppet/modules/lvm/manifests/logical_volume.pp | 6 +
|
|
packstack/puppet/modules/lvm/manifests/volume.pp | 11 +-
|
|
.../puppet/provider/logical_volume/lvm_spec.rb | 55 +++---
|
|
7 files changed, 267 insertions(+), 93 deletions(-)
|
|
|
|
diff --git a/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb b/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb
|
|
index e813193..2f41695 100755
|
|
--- a/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb
|
|
+++ b/packstack/puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb
|
|
@@ -3,24 +3,56 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
|
|
commands :lvcreate => 'lvcreate',
|
|
:lvremove => 'lvremove',
|
|
+ :lvresize => 'lvresize',
|
|
:lvextend => 'lvextend',
|
|
:lvs => 'lvs',
|
|
- :resize2fs => 'resize2fs',
|
|
+ :vgs => 'vgs',
|
|
:umount => 'umount',
|
|
:blkid => 'blkid',
|
|
:dmsetup => 'dmsetup',
|
|
+ :dd => 'dd',
|
|
:lvconvert => 'lvconvert',
|
|
- :lvdisplay => 'lvdisplay'
|
|
-
|
|
- optional_commands :xfs_growfs => 'xfs_growfs',
|
|
- :resize4fs => 'resize4fs'
|
|
+ :lvdisplay => 'lvdisplay',
|
|
+ :fsadm => 'fsadm',
|
|
+ :dd => 'dd'
|
|
+
|
|
+ def round_to_extent(size)
|
|
+ lvm_size_units = {
|
|
+ "K" => 1**0, "M" => 1024**1, "G" => 1024**2, "T" => 1024**3, "P" => 1024**4, "E" => 1025**5,
|
|
+ }
|
|
+
|
|
+ if @resource[:size] =~ /^([0-9]+(\.[0-9]+)?)([KMGTPE])/i
|
|
+ size_value = $1.to_f
|
|
+ size_unit = $3.upcase
|
|
+ size_kibi = (size_value * lvm_size_units[size_unit]).to_i
|
|
+ if vgs('--noheading', '-o', 'vg_extent_size', '--units', 'k', "#{@resource[:volume_group]}") =~ /\s+(\d+)\.\d+k/i
|
|
+ vg_extent_size_kibi = $1.to_i
|
|
+ end
|
|
+ new_size_kibi = ((size_kibi + vg_extent_size_kibi - 1) / vg_extent_size_kibi) * vg_extent_size_kibi
|
|
+ "#{new_size_kibi}k"
|
|
+ else
|
|
+ size
|
|
+ end
|
|
+ end
|
|
|
|
def create
|
|
args = ['-n', @resource[:name]]
|
|
if @resource[:size]
|
|
- args.push('--size', @resource[:size])
|
|
+ size = @resource[:size]
|
|
+ if size == 'max'
|
|
+ size = vgs('--noheading', '-o', 'vg_size', '--units', 'k', "#{@resource[:volume_group]}").strip
|
|
+ elsif @resource[:round_to_extent] then
|
|
+ size = round_to_extent(size)
|
|
+ end
|
|
+ args.push('--size', size)
|
|
elsif @resource[:initial_size]
|
|
- args.push('--size', @resource[:initial_size])
|
|
+ args.push(
|
|
+ '--size',
|
|
+ if @resource[:round_to_extent] then
|
|
+ round_to_extent(@resource[:initial_size])
|
|
+ else
|
|
+ @resource[:initial_size]
|
|
+ end)
|
|
end
|
|
if @resource[:extents]
|
|
args.push('--extents', @resource[:extents])
|
|
@@ -63,6 +95,7 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
|
|
args << @resource[:volume_group]
|
|
lvcreate(*args)
|
|
+ lvzero
|
|
end
|
|
|
|
def destroy
|
|
@@ -75,9 +108,16 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
lvs(@resource[:volume_group]) =~ lvs_pattern
|
|
end
|
|
|
|
+ def exec_cmd(*cmd)
|
|
+ output = Puppet::Util::Execution.execute(cmd, :failonfail => false, :combine => true)
|
|
+ {:out => output, :exit => $CHILD_STATUS.exitstatus}
|
|
+ end
|
|
+
|
|
def size
|
|
if @resource[:size] =~ /^\d+\.?\d{0,2}([KMGTPE])/i
|
|
unit = $1.downcase
|
|
+ else
|
|
+ unit = 'k'
|
|
end
|
|
|
|
raw = lvs('--noheading', '--unit', unit, path)
|
|
@@ -92,64 +132,87 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
end
|
|
|
|
def size=(new_size)
|
|
- lvm_size_units = { "K" => 1, "M" => 1024, "G" => 1048576, "T" => 1073741824, "P" => 1099511627776, "E" => 1125899906842624 }
|
|
- lvm_size_units_match = lvm_size_units.keys().join('|')
|
|
+ lvm_size_units = {
|
|
+ "K" => 1**0, "M" => 1024**1, "G" => 1024**2, "T" => 1024**3, "P" => 1024**4, "E" => 1025**5,
|
|
+ }
|
|
|
|
- resizeable = false
|
|
- current_size = size()
|
|
+ current_size = size()
|
|
|
|
- if current_size =~ /(\d+\.{0,1}\d{0,2})(#{lvm_size_units_match})/i
|
|
- current_size_bytes = $1.to_i
|
|
- current_size_unit = $2.upcase
|
|
- end
|
|
+ if current_size =~ /^([0-9]+(\.[0-9]+)?)([KMGTPE])/i
|
|
+ current_size_value = $1.to_f
|
|
+ current_size_unit = $3.upcase
|
|
+ current_size = (current_size_value * lvm_size_units[current_size_unit]).to_i
|
|
+ end
|
|
|
|
- if new_size =~ /(\d+)(#{lvm_size_units_match})/i
|
|
- new_size_bytes = $1.to_i
|
|
- new_size_unit = $2.upcase
|
|
- end
|
|
+ info( "Current: value=#{current_size_value}, unit=#{current_size_unit}, kibi=#{current_size}" )
|
|
|
|
- ## Get the extend size
|
|
- if lvs('--noheading', '-o', 'vg_extent_size', '--units', 'k', path) =~ /\s+(\d+)\.\d+k/i
|
|
- vg_extent_size = $1.to_i
|
|
- end
|
|
+ if new_size == 'max'
|
|
+ new_size = vgs('--noheading', '-o', 'vg_size', '--units', 'k', "#{@resource[:volume_group]}").strip
|
|
+ end
|
|
|
|
- ## Verify that it's a extension: Reduce is potentially dangerous and should be done manually
|
|
- if lvm_size_units[current_size_unit] < lvm_size_units[new_size_unit]
|
|
- resizeable = true
|
|
- elsif lvm_size_units[current_size_unit] > lvm_size_units[new_size_unit]
|
|
- if (current_size_bytes * lvm_size_units[current_size_unit]) < (new_size_bytes * lvm_size_units[new_size_unit])
|
|
- resizeable = true
|
|
- end
|
|
- elsif lvm_size_units[current_size_unit] == lvm_size_units[new_size_unit]
|
|
- if new_size_bytes > current_size_bytes
|
|
- resizeable = true
|
|
- end
|
|
- end
|
|
+ if new_size =~ /^([0-9]+(\.[0-9]+)?)([KMGTPE])/i
|
|
+ new_size_value = $1.to_f
|
|
+ new_size_unit = $3.upcase
|
|
+ new_size = (new_size_value * lvm_size_units[new_size_unit]).to_i
|
|
+ end
|
|
|
|
- if not resizeable
|
|
- if @resource[:size_is_minsize] == :true or @resource[:size_is_minsize] == true or @resource[:size_is_minsize] == 'true'
|
|
- info( "Logical volume already has minimum size of #{new_size} (currently #{current_size})" )
|
|
- else
|
|
- fail( "Decreasing the size requires manual intervention (#{new_size} < #{current_size})" )
|
|
- end
|
|
- else
|
|
- ## Check if new size fits the extend blocks
|
|
- if new_size_bytes * lvm_size_units[new_size_unit] % vg_extent_size != 0
|
|
- fail( "Cannot extend to size #{new_size} because VG extent size is #{vg_extent_size} KB" )
|
|
- end
|
|
+ info( "New: value=#{new_size_value}, unit=#{new_size_unit}, kibi=#{new_size}" )
|
|
|
|
- lvextend( '-L', new_size, path) || fail( "Cannot extend to size #{new_size} because lvextend failed." )
|
|
+ ## Get the extend size
|
|
+ if lvs('--noheading', '-o', 'vg_extent_size', '--units', 'k', path) =~ /\s+(\d+)\.\d+k/i
|
|
+ vg_extent_size = $1.to_i
|
|
+ end
|
|
|
|
- blkid_type = blkid(path)
|
|
- if command(:resize4fs) and blkid_type =~ /\bTYPE=\"(ext4)\"/
|
|
- resize4fs( path) || fail( "Cannot resize file system to size #{new_size} because resize2fs failed." )
|
|
- elsif blkid_type =~ /\bTYPE=\"(ext[34])\"/
|
|
- resize2fs( path) || fail( "Cannot resize file system to size #{new_size} because resize2fs failed." )
|
|
- elsif blkid_type =~ /\bTYPE=\"(xfs)\"/
|
|
- xfs_growfs( path) || fail( "Cannot resize filesystem to size #{new_size} because xfs_growfs failed." )
|
|
+ if new_size < current_size
|
|
+ if @resource[:size_is_minsize] == :true or @resource[:size_is_minsize] == true or @resource[:size_is_minsize] == 'true'
|
|
+ info( "Logical volume already has minimum size of #{new_size} (currently #{current_size})" )
|
|
+ else
|
|
+ if not @resource[:allow_reduce]
|
|
+ fail( "Decreasing the size requires manual intervention (#{new_size} < #{current_size})" )
|
|
+ end
|
|
+ if new_size % vg_extent_size != 0
|
|
+ if @resource[:round_to_extent]
|
|
+ new_size = ((new_size + vg_extent_size - 1) / vg_extent_size) * vg_extent_size
|
|
+ if new_size >= current_size
|
|
+ info( "Logical volume already has a size of #{current_size}" )
|
|
+ return
|
|
+ end
|
|
+ else
|
|
+ fail( "Cannot reduce to size #{new_size} because VG extent size is #{vg_extent_size} KB" )
|
|
end
|
|
-
|
|
+ end
|
|
+ exec_cmd('umount', path)
|
|
+ exec_cmd('fsadm', '-y', 'check', path )
|
|
+ r = exec_cmd('fsadm', '-y', 'resize', path, "#{new_size}k")
|
|
+ if r[:exit] != 0 and @resource[:nuke_fs_on_resize_failure]
|
|
+ exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
|
|
+ blkid('-g')
|
|
+ end
|
|
+ lvresize( '-f', '-L', "#{new_size}k", path) || fail( "Cannot reduce to size #{new_size} because lvresize failed." )
|
|
+ end
|
|
+ elsif new_size > current_size
|
|
+ if new_size % vg_extent_size != 0
|
|
+ if @resource[:round_to_extent]
|
|
+ new_size = ((new_size + vg_extent_size - 1) / vg_extent_size) * vg_extent_size
|
|
+ if new_size <= current_size
|
|
+ info( "Logical volume already has a size of #{current_size}" )
|
|
+ return
|
|
+ end
|
|
+ else
|
|
+ fail( "Cannot extend to size #{new_size} because VG extent size is #{vg_extent_size} KB" )
|
|
+ end
|
|
+ end
|
|
+ lvextend( '-L', "#{new_size}k", path) || fail( "Cannot extend to size #{new_size} because lvextend failed." )
|
|
+ exec_cmd('umount', path)
|
|
+ exec_cmd('fsadm', '-y', 'check', path )
|
|
+ r = exec_cmd('fsadm', '-y', 'resize', path, "#{new_size}k")
|
|
+ if r[:exit] != 0 and @resource[:nuke_fs_on_resize_failure]
|
|
+ exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
|
|
+ blkid('-g')
|
|
end
|
|
+ else
|
|
+ info( "Logical volume already has a size of #{current_size}" )
|
|
+ end
|
|
end
|
|
|
|
|
|
@@ -161,7 +224,7 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
# Minus one because it says "2" when there is only one spare. And so on.
|
|
n = ($1.to_i)-1
|
|
#puts " current mirrors: #{n}"
|
|
- return n.to_s
|
|
+ return n.to_s
|
|
end
|
|
return 0.to_s
|
|
end
|
|
@@ -176,7 +239,7 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
end
|
|
|
|
# Region size cannot be changed on an existing mirror (not even when changing to zero mirrors).
|
|
-
|
|
+
|
|
if @resource[:alloc]
|
|
args.push( '--alloc', @resource[:alloc] )
|
|
end
|
|
@@ -222,9 +285,6 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
end
|
|
end
|
|
|
|
-
|
|
-
|
|
-
|
|
private
|
|
|
|
def lvs_pattern
|
|
@@ -240,4 +300,18 @@ Puppet::Type.type(:logical_volume).provide :lvm do
|
|
"/dev/#{@resource[:volume_group]}"
|
|
end
|
|
|
|
+ def lvzero
|
|
+ if lvs('--noheading', '-o', 'lv_size', '--units', 'm', path) =~ /\s+(\d+)\.\d+m/i
|
|
+ lv_size = $1.to_i
|
|
+ lv_size = lv_size - 2
|
|
+ begin
|
|
+ dd('if=/dev/zero', 'of=' + path, 'bs=1M', "seek=#{lv_size}")
|
|
+ rescue
|
|
+ end
|
|
+ begin
|
|
+ dd('if=/dev/zero', 'of=' + path, 'bs=1M', 'count=100')
|
|
+ rescue
|
|
+ end
|
|
+ end
|
|
+ end
|
|
end
|
|
diff --git a/packstack/puppet/modules/lvm/lib/puppet/provider/physical_volume/lvm.rb b/packstack/puppet/modules/lvm/lib/puppet/provider/physical_volume/lvm.rb
|
|
index eaefc92..6ac6e0a 100644
|
|
--- a/packstack/puppet/modules/lvm/lib/puppet/provider/physical_volume/lvm.rb
|
|
+++ b/packstack/puppet/modules/lvm/lib/puppet/provider/physical_volume/lvm.rb
|
|
@@ -4,7 +4,7 @@ Puppet::Type.type(:physical_volume).provide(:lvm) do
|
|
commands :pvcreate => 'pvcreate', :pvremove => 'pvremove', :pvs => 'pvs', :vgs => 'vgs'
|
|
|
|
def create
|
|
- pvcreate(@resource[:name])
|
|
+ pvcreate('-y', @resource[:name])
|
|
end
|
|
|
|
def destroy
|
|
diff --git a/packstack/puppet/modules/lvm/lib/puppet/provider/volume_group/lvm.rb b/packstack/puppet/modules/lvm/lib/puppet/provider/volume_group/lvm.rb
|
|
index c8de071..3d54dba 100644
|
|
--- a/packstack/puppet/modules/lvm/lib/puppet/provider/volume_group/lvm.rb
|
|
+++ b/packstack/puppet/modules/lvm/lib/puppet/provider/volume_group/lvm.rb
|
|
@@ -1,12 +1,18 @@
|
|
+require 'csv'
|
|
+
|
|
Puppet::Type.type(:volume_group).provide :lvm do
|
|
desc "Manages LVM volume groups"
|
|
|
|
commands :vgcreate => 'vgcreate',
|
|
:vgremove => 'vgremove',
|
|
+ :pvremove => 'pvremove',
|
|
:vgs => 'vgs',
|
|
:vgextend => 'vgextend',
|
|
:vgreduce => 'vgreduce',
|
|
- :pvs => 'pvs'
|
|
+ :vgscan => 'vgscan',
|
|
+ :pvs => 'pvs',
|
|
+ :lvremove => 'lvremove',
|
|
+ :umount => 'umount'
|
|
|
|
def create
|
|
vgcreate(@resource[:name], *@resource.should(:physical_volumes))
|
|
@@ -22,17 +28,55 @@ Puppet::Type.type(:volume_group).provide :lvm do
|
|
false
|
|
end
|
|
|
|
+ def exec_cmd(*cmd)
|
|
+ output = Puppet::Util::Execution.execute(cmd, :failonfail => false, :combine => true)
|
|
+ {:out => output, :exit => $CHILD_STATUS.exitstatus}
|
|
+ end
|
|
+
|
|
def physical_volumes=(new_volumes = [])
|
|
- # Only take action if createonly is false just to be safe
|
|
- # this is really only here to enforce the createonly setting
|
|
- # if something goes wrong in physical_volumes
|
|
- if @resource[:createonly].to_s == "false"
|
|
- existing_volumes = physical_volumes
|
|
- extraneous = existing_volumes - new_volumes
|
|
- extraneous.each { |volume| reduce_with(volume) }
|
|
+ # Only take action if createonly is false just to be safe
|
|
+ # this is really only here to enforce the createonly setting
|
|
+ # if something goes wrong in physical_volumes
|
|
+ if @resource[:createonly].to_s == "false"
|
|
+ vgreduce('--removemissing', '--force', @resource[:name])
|
|
+ existing_volumes = physical_volumes
|
|
+ extraneous = existing_volumes - new_volumes
|
|
+ pv_to_lv={}
|
|
+ pv_to_dev={}
|
|
+ csv = CSV.new(pvs('-o', 'pv_name,vg_name,lv_name', '--separator', ','),
|
|
+ :headers => true, :header_converters => :symbol)
|
|
+ csv.to_a.map {|row| row.to_hash}.each do |m|
|
|
+ unless m[:lv].nil?
|
|
+ pv_to_lv[m[:_pv].strip] = "#{m[:vg]}/#{m[:lv]}"
|
|
+ pv_to_dev[m[:_pv].strip] = "#{m[:vg].gsub('-','--')}-#{m[:lv].gsub('-','--')}"
|
|
+ end
|
|
+ end
|
|
+
|
|
+ if extraneous == existing_volumes
|
|
+ extraneous.each do |volume|
|
|
+ if pv_to_lv.has_key?(volume)
|
|
+ exec_cmd('/bin/umount', "/dev/mapper/#{pv_to_dev[volume]}")
|
|
+ lvremove('-f', pv_to_lv[volume])
|
|
+ end
|
|
+ end
|
|
+ vgremove(@resource[:name], '--force')
|
|
+ extraneous.each do |volume|
|
|
+ pvremove(volume)
|
|
+ end
|
|
+ vgcreate(@resource[:name], *new_volumes)
|
|
+ else
|
|
+ extraneous.each do |volume|
|
|
+ if pv_to_lv.has_key?(volume)
|
|
+ exec_cmd('/bin/umount', "/dev/mapper/#{pv_to_dev[volume]}")
|
|
+ lvremove('-f', pv_to_lv[volume])
|
|
+ end
|
|
+ reduce_with(volume)
|
|
+ pvremove(volume)
|
|
+ end
|
|
missing = new_volumes - existing_volumes
|
|
missing.each { |volume| extend_with(volume) }
|
|
end
|
|
+ end
|
|
end
|
|
|
|
def physical_volumes
|
|
diff --git a/packstack/puppet/modules/lvm/lib/puppet/type/logical_volume.rb b/packstack/puppet/modules/lvm/lib/puppet/type/logical_volume.rb
|
|
index f907e08..3081650 100644
|
|
--- a/packstack/puppet/modules/lvm/lib/puppet/type/logical_volume.rb
|
|
+++ b/packstack/puppet/modules/lvm/lib/puppet/type/logical_volume.rb
|
|
@@ -31,7 +31,7 @@ Puppet::Type.newtype(:logical_volume) do
|
|
newproperty(:size) do
|
|
desc "The size of the logical volume. Set to undef to use all available space"
|
|
validate do |value|
|
|
- unless value =~ /^[0-9]+(\.[0-9]+)?[KMGTPE]/i
|
|
+ unless value =~ /(^[0-9]+(\.[0-9]+)?[KMGTPE]|max)/i
|
|
raise ArgumentError , "#{value} is not a valid logical volume size"
|
|
end
|
|
end
|
|
@@ -50,6 +50,36 @@ Puppet::Type.newtype(:logical_volume) do
|
|
desc "Configures the logical volume type. AIX only"
|
|
end
|
|
|
|
+ newparam(:allow_reduce) do
|
|
+ desc "Allow reducing logical volume size."
|
|
+ validate do |value|
|
|
+ unless [:true, true, "true", :false, false, "false"].include?(value)
|
|
+ raise ArgumentError , "allow_reduce must either be true or false"
|
|
+ end
|
|
+ end
|
|
+ defaultto :false
|
|
+ end
|
|
+
|
|
+ newparam(:round_to_extent) do
|
|
+ desc "Allow rounding of logical volume size to extent size."
|
|
+ validate do |value|
|
|
+ unless [:true, true, "true", :false, false, "false"].include?(value)
|
|
+ raise ArgumentError , "round_to_extent must either be true or false"
|
|
+ end
|
|
+ end
|
|
+ defaultto :false
|
|
+ end
|
|
+
|
|
+ newparam(:nuke_fs_on_resize_failure) do
|
|
+ desc "Remove filesystem on logical volume resize failure."
|
|
+ defaultto :false
|
|
+ validate do |value|
|
|
+ unless [:true, true, "true", :false, false, "false"].include?(value)
|
|
+ raise ArgumentError , "nuke_fs_on_resize_failure must either be true or false"
|
|
+ end
|
|
+ end
|
|
+ end
|
|
+
|
|
newparam(:range) do
|
|
desc "Sets the inter-physical volume allocation policy. AIX only"
|
|
validate do |value|
|
|
diff --git a/packstack/puppet/modules/lvm/manifests/logical_volume.pp b/packstack/puppet/modules/lvm/manifests/logical_volume.pp
|
|
index e6e5e78..4888b5d 100644
|
|
--- a/packstack/puppet/modules/lvm/manifests/logical_volume.pp
|
|
+++ b/packstack/puppet/modules/lvm/manifests/logical_volume.pp
|
|
@@ -3,7 +3,9 @@
|
|
define lvm::logical_volume (
|
|
$volume_group,
|
|
$size = undef,
|
|
+ $size_is_minsize = false,
|
|
$initial_size = undef,
|
|
+ $round_to_extent = false,
|
|
$ensure = present,
|
|
$options = 'defaults',
|
|
$pass = '2',
|
|
@@ -12,6 +14,7 @@ define lvm::logical_volume (
|
|
$mkfs_options = undef,
|
|
$mountpath = "/${name}",
|
|
$mountpath_require = false,
|
|
+ $remounts = true,
|
|
$createfs = true,
|
|
$extents = undef,
|
|
$stripes = undef,
|
|
@@ -21,6 +24,7 @@ define lvm::logical_volume (
|
|
) {
|
|
|
|
validate_bool($mountpath_require)
|
|
+ validate_bool($size_is_minsize)
|
|
|
|
if ($name == undef) {
|
|
fail("lvm::logical_volume \$name can't be undefined")
|
|
@@ -51,6 +55,7 @@ define lvm::logical_volume (
|
|
ensure => $ensure,
|
|
volume_group => $volume_group,
|
|
size => $size,
|
|
+ size_is_minsize => $size_is_minsize,
|
|
initial_size => $initial_size,
|
|
stripes => $stripes,
|
|
stripesize => $stripesize,
|
|
@@ -81,6 +86,7 @@ define lvm::logical_volume (
|
|
pass => $pass,
|
|
dump => $dump,
|
|
atboot => true,
|
|
+ remounts => $remounts,
|
|
}
|
|
}
|
|
}
|
|
diff --git a/packstack/puppet/modules/lvm/manifests/volume.pp b/packstack/puppet/modules/lvm/manifests/volume.pp
|
|
index a8bc3c8..bdfc937 100644
|
|
--- a/packstack/puppet/modules/lvm/manifests/volume.pp
|
|
+++ b/packstack/puppet/modules/lvm/manifests/volume.pp
|
|
@@ -59,7 +59,10 @@ define lvm::volume (
|
|
$fstype = undef,
|
|
$size = undef,
|
|
$extents = undef,
|
|
- $initial_size = undef
|
|
+ $initial_size = undef,
|
|
+ $allow_reduce = false,
|
|
+ $round_to_extent = false,
|
|
+ $nuke_fs_on_resize_failure = false
|
|
) {
|
|
|
|
if ($name == undef) {
|
|
@@ -88,6 +91,9 @@ define lvm::volume (
|
|
volume_group => $vg,
|
|
size => $size,
|
|
initial_size => $initial_size,
|
|
+ allow_reduce => $allow_reduce,
|
|
+ round_to_extent => $round_to_extent,
|
|
+ nuke_fs_on_resize_failure => $nuke_fs_on_resize_failure,
|
|
before => Volume_group[$vg]
|
|
}
|
|
}
|
|
@@ -124,6 +130,9 @@ define lvm::volume (
|
|
volume_group => $vg,
|
|
size => $size,
|
|
extents => $extents,
|
|
+ allow_reduce => $allow_reduce,
|
|
+ round_to_extent => $round_to_extent,
|
|
+ nuke_fs_on_resize_failure => $nuke_fs_on_resize_failure,
|
|
require => Volume_group[$vg]
|
|
}
|
|
|
|
diff --git a/packstack/puppet/modules/lvm/spec/unit/puppet/provider/logical_volume/lvm_spec.rb b/packstack/puppet/modules/lvm/spec/unit/puppet/provider/logical_volume/lvm_spec.rb
|
|
index 56c32a5..a465a7f 100644
|
|
--- a/packstack/puppet/modules/lvm/spec/unit/puppet/provider/logical_volume/lvm_spec.rb
|
|
+++ b/packstack/puppet/modules/lvm/spec/unit/puppet/provider/logical_volume/lvm_spec.rb
|
|
@@ -12,23 +12,24 @@ describe provider_class do
|
|
describe 'when creating' do
|
|
context 'with size' do
|
|
it "should execute 'lvcreate' with a '--size' option" do
|
|
- @resource.expects(:[]).with(:name).returns('mylv')
|
|
- @resource.expects(:[]).with(:volume_group).returns('myvg')
|
|
+ @resource.expects(:[]).with(:name).returns('mylv').at_least_once
|
|
+ @resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
|
|
@resource.expects(:[]).with(:size).returns('1g').at_least_once
|
|
@resource.expects(:[]).with(:extents).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:stripes).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
end
|
|
end
|
|
context 'with initial_size' do
|
|
it "should execute 'lvcreate' with a '--size' option" do
|
|
- @resource.expects(:[]).with(:name).returns('mylv')
|
|
- @resource.expects(:[]).with(:volume_group).returns('myvg')
|
|
+ @resource.expects(:[]).with(:name).returns('mylv').at_least_once
|
|
+ @resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
|
|
@resource.expects(:[]).with(:initial_size).returns('1g').at_least_once
|
|
@resource.expects(:[]).with(:size).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:extents).returns(nil).at_least_once
|
|
@@ -36,15 +37,16 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
end
|
|
end
|
|
context 'without size and without extents' do
|
|
it "should execute 'lvcreate' without a '--size' option or a '--extents' option" do
|
|
- @resource.expects(:[]).with(:name).returns('mylv')
|
|
- @resource.expects(:[]).with(:volume_group).returns('myvg')
|
|
+ @resource.expects(:[]).with(:name).returns('mylv').at_least_once
|
|
+ @resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
|
|
@resource.expects(:[]).with(:size).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:initial_size).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:extents).returns(nil).at_least_once
|
|
@@ -52,45 +54,47 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--extents', '100%FREE', 'myvg')
|
|
@provider.create
|
|
end
|
|
end
|
|
context 'with extents' do
|
|
it "should execute 'lvcreate' with a '--extents' option" do
|
|
- @resource.expects(:[]).with(:name).returns('mylv')
|
|
- @resource.expects(:[]).with(:volume_group).returns('myvg')
|
|
+ @resource.expects(:[]).with(:name).returns('mylv').at_least_once
|
|
+ @resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
|
|
@resource.expects(:[]).with(:size).returns('1g').at_least_once
|
|
@resource.expects(:[]).with(:extents).returns('80%vg').at_least_once
|
|
@resource.expects(:[]).with(:stripes).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', '--extents', '80%vg', 'myvg')
|
|
@provider.create
|
|
end
|
|
end
|
|
context 'without extents' do
|
|
it "should execute 'lvcreate' without a '--extents' option" do
|
|
- @resource.expects(:[]).with(:name).returns('mylv')
|
|
- @resource.expects(:[]).with(:volume_group).returns('myvg')
|
|
+ @resource.expects(:[]).with(:name).returns('mylv').at_least_once
|
|
+ @resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
|
|
@resource.expects(:[]).with(:size).returns('1g').at_least_once
|
|
@resource.expects(:[]).with(:extents).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:stripes).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
end
|
|
end
|
|
context 'with initial_size and mirroring' do
|
|
it "should execute 'lvcreate' with '--size' and '--mirrors' and '--mirrorlog' options" do
|
|
- @resource.expects(:[]).with(:name).returns('mylv')
|
|
- @resource.expects(:[]).with(:volume_group).returns('myvg')
|
|
+ @resource.expects(:[]).with(:name).returns('mylv').at_least_once
|
|
+ @resource.expects(:[]).with(:volume_group).returns('myvg').at_least_once
|
|
@resource.expects(:[]).with(:initial_size).returns('1g').at_least_once
|
|
@resource.expects(:[]).with(:size).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:extents).returns(nil).at_least_once
|
|
@@ -102,6 +106,7 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:region_size).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:no_sync).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', '--mirrors', '1', '--mirrorlog', 'core', 'myvg')
|
|
@provider.create
|
|
end
|
|
@@ -120,13 +125,15 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
+ @resource.expects(:[]).with(:nuke_fs_on_resize_failure).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
@provider.expects(:lvs).with('--noheading', '--unit', 'g', '/dev/myvg/mylv').returns(' 1.00g').at_least_once
|
|
@provider.expects(:lvs).with('--noheading', '-o', 'vg_extent_size', '--units', 'k', '/dev/myvg/mylv').returns(' 1000.00k')
|
|
@provider.expects(:lvextend).with('-L', '2000000k', '/dev/myvg/mylv').returns(true)
|
|
- @provider.expects(:blkid).with('/dev/myvg/mylv')
|
|
+ #@provider.expects(:blkid).with('/dev/myvg/mylv')
|
|
@provider.size = '2000000k'
|
|
end
|
|
end
|
|
@@ -140,7 +147,8 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:stripesize).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
@provider.expects(:lvs).with('--noheading', '--unit', 'g', '/dev/myvg/mylv').returns(' 1.00g').at_least_once
|
|
@@ -161,7 +169,9 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:size_is_minsize).returns(:false).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
+ @resource.expects(:[]).with(:allow_reduce).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
@provider.expects(:lvs).with('--noheading', '--unit', 'g', '/dev/myvg/mylv').returns(' 1.00g').at_least_once
|
|
@@ -182,7 +192,8 @@ describe provider_class do
|
|
@resource.expects(:[]).with(:readahead).returns(nil).at_least_once
|
|
@resource.expects(:[]).with(:size_is_minsize).returns(:true).at_least_once
|
|
@resource.expects(:[]).with(:mirror).returns(nil).at_least_once
|
|
- @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:alloc).returns(nil).at_least_once
|
|
+ @resource.expects(:[]).with(:round_to_extent).returns(false).at_least_once
|
|
@provider.expects(:lvcreate).with('-n', 'mylv', '--size', '1g', 'myvg')
|
|
@provider.create
|
|
@provider.expects(:lvs).with('--noheading', '--unit', 'g', '/dev/myvg/mylv').returns(' 1.00g').at_least_once
|
|
--
|
|
1.8.3.1
|
|
|