Calculate partition power for swift

Calculage partition power according to
https://answers.launchpad.net/swift/+question/211929

power = int(log2(devnumber*100)) + resize_factor

resize_factor can be set in $::fuel_settings['swift'] hash.
default value: 2 (2048 partitions in standard setup)

Change-Id: Icbc518b05f8170b8656b6aad701bf3cece89f74f
Related-bug: #1261659
This commit is contained in:
Vladimir Kuklin 2013-12-20 16:19:29 +04:00
parent a2111938f6
commit 79002d3332
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,16 @@
module Puppet::Parser::Functions
newfunction(:calc_ring_part_power, :type => :rvalue) do |args|
resize_value = args[1]
nodes = args[0].is_a?(Array) ? args[0] : [ args[0] ]
dev_number = nodes.inject(0) do |num,node|
if node['mountpoints']
add = node['mountpoints'].split('\n')[0].split.length
num += add
else
num += 2
end
num
end
ring_power = (Math.log(dev_number * 100)/Math.log(2)).to_int+args[1].to_i
end
end

View File

@ -341,9 +341,18 @@ class osnailyfacter::cluster_ha {
if $primary_proxy {
ring_devices {'all': storages => $controllers }
}
if !$swift_hash['resize_value']
{
$swift_hash['resize_value'] = 2
}
$ring_part_power=calc_ring_part_power($controllers,$swift_hash['resize_value'])
class { 'openstack::swift::proxy':
swift_user_password => $swift_hash[user_password],
swift_proxies => $controller_internal_addresses,
ring_part_power => $ring_part_power,
primary_proxy => $primary_proxy,
controller_node_address => $::fuel_settings['management_vip'],
swift_local_net_ip => $swift_local_net_ip,