Fixup functions for 5.5.7+
Recent changes to Puppet (5.5.7+) has broken some of the legacy function items we were doing in puppet-nova. We'll likely need to update all the functions to the new syntax but for now this change is to address current issues. Change-Id: If1d675cec6fe64e8a812fb638078b0ab1c66b5de Closes-Bug: #1799757
This commit is contained in:
parent
48f22ecf15
commit
3d877926f0
|
@ -1,13 +1,5 @@
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
def array_of_hash?(list)
|
|
||||||
return false unless list.class == Array
|
|
||||||
list.each do |e|
|
|
||||||
return false unless e.class == Hash
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
module Puppet::Parser::Functions
|
module Puppet::Parser::Functions
|
||||||
newfunction(:to_array_of_json_strings, :arity =>1, :type => :rvalue, :doc => "Convert
|
newfunction(:to_array_of_json_strings, :arity =>1, :type => :rvalue, :doc => "Convert
|
||||||
input array of hashes (optionally JSON encoded) to a puppet Array of JSON encoded Strings") do |arg|
|
input array of hashes (optionally JSON encoded) to a puppet Array of JSON encoded Strings") do |arg|
|
||||||
|
@ -26,7 +18,7 @@ module Puppet::Parser::Functions
|
||||||
raise Puppet::ParseError, "Syntax error: #{arg[0]} is not valid"
|
raise Puppet::ParseError, "Syntax error: #{arg[0]} is not valid"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless array_of_hash?(list)
|
unless list.class == Array or (list.each { |e| return false unless e.class == Hash })
|
||||||
raise Puppet::ParseError, "Syntax error: #{arg[0]} is not an Array or JSON encoded String"
|
raise Puppet::ParseError, "Syntax error: #{arg[0]} is not an Array or JSON encoded String"
|
||||||
end
|
end
|
||||||
rv = []
|
rv = []
|
||||||
|
|
|
@ -23,7 +23,7 @@ require 'spec_helper'
|
||||||
describe 'nova::migration::libvirt' do
|
describe 'nova::migration::libvirt' do
|
||||||
|
|
||||||
generate = {}
|
generate = {}
|
||||||
|
# needed for Puppet 4.x
|
||||||
before(:each) {
|
before(:each) {
|
||||||
Puppet::Parser::Functions.newfunction(:generate, :type => :rvalue) {
|
Puppet::Parser::Functions.newfunction(:generate, :type => :rvalue) {
|
||||||
|args| generate.call()
|
|args| generate.call()
|
||||||
|
@ -31,8 +31,10 @@ describe 'nova::migration::libvirt' do
|
||||||
generate.stubs(:call).returns('0000-111-111')
|
generate.stubs(:call).returns('0000-111-111')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# function here is needed for Puppet 5.5.7+
|
||||||
let :pre_condition do
|
let :pre_condition do
|
||||||
'include nova
|
'function generate($a, $b) { return "0000-111-111" }
|
||||||
|
include nova
|
||||||
include nova::compute
|
include nova::compute
|
||||||
include nova::compute::libvirt'
|
include nova::compute::libvirt'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue