Make allocated_hugepages compatible with Ruby 2.0

To make allocated_hugepages fact compatible with different Ruby versions
(1.9.3, 2.0) it's safer to return a hash as JSON and then parse to avoid
different types conversion

Change-Id: If7adadd2de2cc7154281a0d9cbadf825dffe5d2c
Closes-bug: #1572110
(cherry picked from commit fb899cc93c)
This commit is contained in:
Sergey Kolekonov 2016-04-19 16:52:24 +03:00
parent 114e5586f2
commit da69e6bd4f
3 changed files with 8 additions and 6 deletions

View File

@ -13,6 +13,6 @@ end
Facter.add(:allocated_hugepages) do
setcode do
hugepages
hugepages.to_json
end
end

View File

@ -52,8 +52,9 @@ class openstack_tasks::roles::compute {
$ssl_hash = hiera_hash('use_ssl', {})
$node_hash = hiera_hash('node', {})
$use_huge_pages = pick($node_hash['nova_hugepages_enabled'], false)
$use_2m_huge_pages = $::allocated_hugepages['2M']
$use_1g_huge_pages = $::allocated_hugepages['1G']
$allocated_hugepages = parsejson($::allocated_hugepages)
$use_2m_huge_pages = $allocated_hugepages['2M']
$use_1g_huge_pages = $allocated_hugepages['1G']
$libvirt_type = hiera('libvirt_type', undef)
$kombu_compression = hiera('kombu_compression', '')

View File

@ -26,7 +26,7 @@ describe manifest do
let(:facts) {
Noop.ubuntu_facts.merge({
:libvirt_uuid => '0251bf3e0a3f48da8cdf8daad5473a7f',
:allocated_hugepages => {'2M' => true, '1G' => true},
:allocated_hugepages => '{"1G":true,"2M":true}',
})
}
@ -180,8 +180,9 @@ describe manifest do
let(:node_hash) { Noop.hiera_hash 'node' }
let(:enable_hugepages) { node_hash.fetch('nova_hugepages_enabled', false) }
let(:enable_cpu_pinning) { node_hash.fetch('nova_cpu_pinning_enabled', false) }
let(:use_1g_huge_pages) { facts[:allocated_hugepages]['1G'] }
let(:use_2m_huge_pages) { facts[:allocated_hugepages]['2M'] }
let(:allocated_hugepages) { Noop.puppet_function 'parsejson', facts[:allocated_hugepages] }
let(:use_1g_huge_pages) { allocated_hugepages['1G'] }
let(:use_2m_huge_pages) { allocated_hugepages['2M'] }
it 'should configure vcpu_pin_set for nova' do
if enable_cpu_pinning