dynamically generate SDS device hash from nodes

Change-Id: I175295a59c178b0a0119a5bfe757b725622f7645
This commit is contained in:
Moreno, Adrian 2015-10-22 16:25:10 +02:00
parent d2be3898e4
commit 785763c4cf
2 changed files with 29 additions and 12 deletions

View File

@ -0,0 +1,24 @@
module Puppet::Parser::Functions
newfunction(:get_sds_devices, :type => :rvalue) do |args|
result = {}
nodes = args[0]
device = args[1]
protection_domain = args[2]
pool_size = args[3]
storage_pool = args[4]
nodes.each do |node|
result[node["fqdn"]] = {
"ip" => node["internal_address"],
"protection_domain" => protection_domain,
"devices" => {
device => {
"size" => pool_size,
"storage_pool" => storage_pool
}
}
}
end
return result
end
end

View File

@ -13,6 +13,7 @@ class scaleio_fuel::params
$protection_domain = $scaleio['protection_domain']
$storage_pool = $scaleio['storage_pool']
$pool_size = $scaleio['pool_size']
$device = '/var/sio_device1'
$nodes_hash = $::fuel_settings['nodes']
$controller_nodes = concat(filter_nodes($nodes_hash,'role','primary-controller'), filter_nodes($nodes_hash,'role','controller'))
@ -55,18 +56,10 @@ class scaleio_fuel::params
notice("Node role: ${role}, IP: ${node_ip}, FQDN: ${::fqdn}")
$sio_sds_device = {
"${::fqdn}" => {
'ip' => $node_ip,
'protection_domain' => $protection_domain,
'devices' => {
'/var/sio_device1' => {
'size' => $pool_size,
'storage_pool' => $storage_pool,
}
}
}
}
$sio_sds_device = get_sds_devices($nodes_hash, $device, $protection_domain, $pool_size, $storage_pool)
notice("sio_sds_device: ${sio_sds_device}")
#TODO: Get callhome information from UI