puppet recipes: Import from stak-common and restructure

puppetlabs-stdlib: remove older recipe
Delete patches that are no longer needed

This is an older version than what's in meta-starlingx

Signed-off-by: Saul Wold <sgw@linux.intel.com>
This commit is contained in:
Saul Wold 2020-05-15 14:53:48 -07:00
parent b4ed31a429
commit 5d6d77cb75
95 changed files with 0 additions and 959 deletions

View File

@ -1,15 +0,0 @@
--- /dev/null 2019-10-23 20:19:32.602763995 -0700
+++ b/puppet-keystone.gemspec 2019-10-28 15:09:10.705761083 -0700
@@ -0,0 +1,12 @@
+Gem::Specification.new do |s|
+ s.name = 'puppet-keystone'
+ s.version = '11.3.0'
+ s.date = '2017-08-21'
+ s.summary = "Puppet module for OpenStack Keystone."
+ s.description = s.summary
+ s.authors = ["Puppet Labs and OpenStack Contributors"]
+ s.email = ''
+ s.files = %w(LICENSE) + Dir.glob('{lib,spec}/**/*')
+ s.homepage = 'https://launchpad.net/puppet-keystone'
+ s.license = 'Apache 2.0'
+ end

View File

@ -1,694 +0,0 @@
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

View File

@ -1,46 +0,0 @@
From ac6a60e4d65e33017f8db0eca499f8dd898acb3c Mon Sep 17 00:00:00 2001
From: Kristine Bujold <kristine.bujold@windriver.com>
Date: Fri, 15 Jul 2016 16:55:16 -0400
Subject: [PATCH] US80802 - PXE Installation changes for UEFI support. Fixing
pvcreate issue.
---
.../lvm/lib/puppet/provider/physical_volume/lvm.rb | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
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 6ac6e0a..18183ae 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
@@ -1,12 +1,27 @@
Puppet::Type.type(:physical_volume).provide(:lvm) do
desc "Manages LVM physical volumes"
- commands :pvcreate => 'pvcreate', :pvremove => 'pvremove', :pvs => 'pvs', :vgs => 'vgs'
+
+ commands :pvcreate => 'pvcreate',
+ :pvremove => 'pvremove',
+ :pvs => 'pvs',
+ :vgs => 'vgs',
+ :dd => 'dd'
def create
+ # Delete the first few bytes at the start and end of the partition. This is required with
+ # GPT partitions, they save partition info at the start and the end of the block.
+ exec_cmd('dd', 'if=/dev/zero', "of=#{@resource[:name]}", "bs=512", "count=34")
+ exec_cmd('dd', 'if=/dev/zero', "of=#{@resource[:name]}", "bs=512", "count=34", "seek=$((`blockdev --getsz #{@resource[:name]}` - 34))")
+
pvcreate('-y', @resource[:name])
end
+ def exec_cmd(*cmd)
+ output = Puppet::Util::Execution.execute(cmd, :failonfail => false, :combine => true)
+ {:out => output, :exit => $CHILD_STATUS.exitstatus}
+ end
+
def destroy
pvremove(@resource[:name])
end
--
1.8.3.1

View File

@ -1,25 +0,0 @@
From b05de190832bba08ce410c267c4b2f8a74916f7a Mon Sep 17 00:00:00 2001
From: Robert Church <robert.church@windriver.com>
Date: Wed, 1 Mar 2017 09:12:34 +0000
Subject: [PATCH] US94222: Persistent Dev Naming
---
packstack/puppet/modules/lvm/lib/puppet/provider/volume_group/lvm.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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 3d54dba..04dea64 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
@@ -81,7 +81,7 @@ Puppet::Type.type(:volume_group).provide :lvm do
def physical_volumes
if @resource[:createonly].to_s == "false" || ! vgs(@resource[:name])
- lines = pvs('-o', 'pv_name,vg_name', '--separator', ',')
+ lines = `pvs -o pv_name,vg_name --separator ',' | awk -F ',' 'NR>1{cmd="find -L /dev/disk/by-path/ -samefile" $1; cmd | getline $1;print $1 "," $2; next};{print}'`
lines.split(/\n/).grep(/,#{@resource[:name]}$/).map { |s|
s.split(/,/)[0].strip
}
--
1.8.3.1

View File

@ -1,34 +0,0 @@
From f2676c5ac0e17a18726815b72ef449c804e07135 Mon Sep 17 00:00:00 2001
From: Stefan Dinescu <stefan.dinescu@windriver.com>
Date: Wed, 6 Dec 2017 12:50:14 +0000
Subject: [PATCH 1/1] extendind nuke_fs_on_resize_failure functionality
---
.../modules/lvm/lib/puppet/provider/logical_volume/lvm.rb | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
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 2f41695..2abfea3 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
@@ -188,7 +188,16 @@ Puppet::Type.type(:logical_volume).provide :lvm do
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." )
+ r = exec_cmd('lvresize', '-r', '-f', '-L', "#{new_size}k", path)
+ if r[:exit] != 0
+ if @resource[:nuke_fs_on_resize_failure]
+ exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
+ blkid('-g')
+ lvresize( '-f', '-L', "#{new_size}k", path) || fail( "Cannot reduce to size #{new_size} because lvresize failed." )
+ else
+ fail( "Cannot reduce to size #{new_size} because lvresize failed." )
+ end
+ end
end
elsif new_size > current_size
if new_size % vg_extent_size != 0
--
1.8.3.1

View File

@ -1,45 +0,0 @@
From 21d2c4e714611ad08e5aa999e555e1e7591f2717 Mon Sep 17 00:00:00 2001
From: Kristine Bujold <kristine.bujold@windriver.com>
Date: Thu, 19 Jul 2018 09:02:27 -0400
Subject: [PATCH 1/1] Patch4:
Fix-the-logical-statement-for-nuke_fs_on_resize_2.patch
---
.../puppet/modules/lvm/lib/puppet/provider/logical_volume/lvm.rb | 9 ++++++---
1 file changed, 6 insertions(+), 3 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 2abfea3..f9b1c66 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
@@ -184,13 +184,15 @@ Puppet::Type.type(:logical_volume).provide :lvm do
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]
+ if r[:exit] != 0 and [:true, "true", true ].include? @resource[:nuke_fs_on_resize_failure]
+ info( "Failed 'fsadm resize' erase the disk #{r}" )
exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
blkid('-g')
end
r = exec_cmd('lvresize', '-r', '-f', '-L', "#{new_size}k", path)
if r[:exit] != 0
- if @resource[:nuke_fs_on_resize_failure]
+ if [:true, "true", true ].include? @resource[:nuke_fs_on_resize_failure]
+ info( "Failed 'fsadm resize' erase the disk #{r}" )
exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
blkid('-g')
lvresize( '-f', '-L', "#{new_size}k", path) || fail( "Cannot reduce to size #{new_size} because lvresize failed." )
@@ -215,7 +217,8 @@ Puppet::Type.type(:logical_volume).provide :lvm do
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]
+ if r[:exit] != 0 and [:true, "true", true ].include? @resource[:nuke_fs_on_resize_failure]
+ info( "Failed 'fsadm resize' erase the disk #{r}" )
exec_cmd('dd', 'if=/dev/zero', "of=#{path}", "bs=512", "count=16", "conv=notrunc")
blkid('-g')
end
--
1.8.3.1

View File

@ -1,33 +0,0 @@
From c92a9d11002184a67f8bedf542d84f527eea3107 Mon Sep 17 00:00:00 2001
From: babak sarashki <babak.sarashki@windriver.com>
Date: Tue, 29 Oct 2019 15:12:18 -0700
Subject: [PATCH] Fix ruby path
---
tasks/export.rb | 2 +-
tasks/sql.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tasks/export.rb b/tasks/export.rb
index efd9d81..18106ec 100755
--- a/tasks/export.rb
+++ b/tasks/export.rb
@@ -1,4 +1,4 @@
-#!/opt/puppetlabs/puppet/bin/ruby
+#!/usr/bin/ruby
require 'json'
require 'open3'
require 'puppet'
diff --git a/tasks/sql.rb b/tasks/sql.rb
index 29b2c6b..7256f2d 100755
--- a/tasks/sql.rb
+++ b/tasks/sql.rb
@@ -1,4 +1,4 @@
-#!/opt/puppetlabs/puppet/bin/ruby
+#!/usr/bin/ruby
require 'json'
require 'open3'
require 'puppet'
--
2.17.1

View File

@ -1,15 +0,0 @@
--- /dev/null 2019-10-28 19:50:04.372284581 -0700
+++ b/puppetlabs-stdlib.gemspec 2019-10-29 15:09:32.804637910 -0700
@@ -0,0 +1,12 @@
+Gem::Specification.new do |s|
+ s.name = 'puppetlabs-stdlib'
+ s.version = '4.13.1'
+ s.date = '2016-10-12'
+ s.summary = "Puppet Labs Standard Library module"
+ s.description = s.summary
+ s.authors = ["Puppet Labs"]
+ s.email = ''
+ s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob('{lib,spec}/**/*')
+ s.homepage = 'https://github.com/puppetlabs/puppetlabs-stdlib'
+ s.license = 'Apache 2.0'
+end

View File

@ -1,52 +0,0 @@
#
# Copyright (C) 2019 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
SRCREV = "f2492ee916c1c8e0345514045432c4a049674029"
PROTOCOL = "https"
BRANCH = "master"
S = "${WORKDIR}/git"
PV = "4.13.1"
SRC_URI = " \
git://github.com/puppetlabs/puppetlabs-stdlib.git;protocol=${PROTOCOL};rev=${SRCREV};branch=${BRANCH} \
file://puppetlabs-stdlib/Add-gemspec.patch \
"
#inherit ruby
#
#DEPENDS += " \
# ruby \
# facter \
# "
#
#RDEPENDS_${PN} += " \
# ruby \
# facter \
# puppet \
# "
#
RUBY_INSTALL_GEMS = "puppetlabs-stdlib-${PV}.gem"
do_install_append () {
install -d -m 0755 ${D}/${datadir}/puppet/modules/stdlib
tar -C ${S} -cf - --exclude "patches" --exclude "*.gem*" . | tar --no-same-owner -xf - -C ${D}/${datadir}/puppet/modules/stdlib
}
FILES_${PN} += " ${datadir}"