Fixed auto creation of protection domains
Change-Id: If9bd3ad9a4537c05554361f543910bcc9ec68b74
This commit is contained in:
parent
7cc12e1dbe
commit
a9e89dec39
|
@ -29,7 +29,6 @@ define mdm_tb() {
|
|||
}
|
||||
|
||||
define storage_pool_ensure(
|
||||
$protection_domain,
|
||||
$zero_padding,
|
||||
$scanner_mode,
|
||||
$checksum_mode,
|
||||
|
@ -38,7 +37,9 @@ define storage_pool_ensure(
|
|||
$rmcache_passthrough_pools,
|
||||
$rmcache_cached_pools,
|
||||
) {
|
||||
$sp_name = $title
|
||||
$parsed_pool_name = split($title, ":")
|
||||
$protection_domain = $parsed_pool_name[0]
|
||||
$sp_name = $parsed_pool_name[1]
|
||||
if $::scaleio_storage_pools and $::scaleio_storage_pools != '' {
|
||||
$current_pools = split($::scaleio_storage_pools, ',')
|
||||
} else {
|
||||
|
@ -79,15 +80,42 @@ define storage_pool_ensure(
|
|||
}
|
||||
}
|
||||
|
||||
define protection_domain_ensure(
|
||||
$pools_array,
|
||||
$zero_padding,
|
||||
$scanner_mode,
|
||||
$checksum_mode,
|
||||
$spare_policy,
|
||||
$rfcache_storage_pools_array,
|
||||
$rmcache_passthrough_pools,
|
||||
$rmcache_cached_pools,
|
||||
) {
|
||||
$protection_domain = $title
|
||||
$full_name_pools_array = prefix($pools_array, "${protection_domain}:")
|
||||
scaleio::protection_domain {"Ensure protection domain ${protection_domain}":
|
||||
sio_name => $protection_domain,
|
||||
} ->
|
||||
storage_pool_ensure {$full_name_pools_array:
|
||||
zero_padding => $zero_padding,
|
||||
scanner_mode => $scanner_mode,
|
||||
checksum_mode => $checksum_mode,
|
||||
spare_policy => $spare_policy,
|
||||
rfcache_storage_pools_array => $rfcache_storage_pools_array,
|
||||
rmcache_passthrough_pools => $rmcache_passthrough_pools,
|
||||
rmcache_cached_pools => $rmcache_cached_pools,
|
||||
}
|
||||
}
|
||||
|
||||
define sds_ensure(
|
||||
$sds_nodes,
|
||||
$protection_domain,
|
||||
$sds_to_pd_map, # map of SDSes to Protection domains
|
||||
$storage_pools, # if sds_devices_config==undef then storage_pools and device_paths are used,
|
||||
$device_paths, # this is FUELs w/o plugin's roles support, so all SDSes have the same config
|
||||
$rfcache_devices,
|
||||
$sds_devices_config, # for FUELs with plugin's roles support, config could be different for SDSes
|
||||
) {
|
||||
$sds_name = $title
|
||||
$protection_domain = $sds_to_pd_map[$sds_name]
|
||||
$sds_node_ = filter_nodes($sds_nodes, 'name', $sds_name)
|
||||
$sds_node = $sds_node_[0]
|
||||
#ips for data path traffic
|
||||
|
@ -219,16 +247,6 @@ if $scaleio['metadata']['enabled'] {
|
|||
}
|
||||
}
|
||||
$password = $scaleio['password']
|
||||
if $scaleio['protection_domain_nodes'] {
|
||||
$protection_domain_number = ($sds_nodes_count + $scaleio['protection_domain_nodes'] - 1) / $scaleio['protection_domain_nodes']
|
||||
} else {
|
||||
$protection_domain_number = 1
|
||||
}
|
||||
$protection_domain = $protection_domain_number ? {
|
||||
0 => $scaleio['protection_domain'],
|
||||
1 => $scaleio['protection_domain'],
|
||||
default => "${scaleio['protection_domain']}_${protection_domain_number}"
|
||||
}
|
||||
# parse config from centralized DB if exists
|
||||
if $::scaleio_sds_config and $::scaleio_sds_config != '' {
|
||||
$sds_devices_config = parsejson($::scaleio_sds_config)
|
||||
|
@ -330,6 +348,17 @@ if $scaleio['metadata']['enabled'] {
|
|||
} else {
|
||||
$to_add_sds_names = $sds_nodes_names
|
||||
}
|
||||
if $::scaleio_sds_with_protection_domain_list and $::scaleio_sds_with_protection_domain_list != '' {
|
||||
$scaleio_sds_to_pd_map = hash(split($::scaleio_sds_with_protection_domain_list, ','))
|
||||
} else {
|
||||
$scaleio_sds_to_pd_map = {}
|
||||
}
|
||||
$sds_pd_limit = $scaleio['protection_domain_nodes'] ? {
|
||||
undef => 0, # unlimited
|
||||
default => $scaleio['protection_domain_nodes']
|
||||
}
|
||||
$sds_to_pd_map = update_sds_to_pd_map($scaleio_sds_to_pd_map, $scaleio['protection_domain'], $sds_pd_limit, $to_add_sds_names)
|
||||
$protection_domain_array = unique(values($sds_to_pd_map))
|
||||
if $cluster_mode != 1 {
|
||||
mdm_standby {$standby_ips:
|
||||
require => Scaleio::Login['Normal'],
|
||||
|
@ -343,13 +372,8 @@ if $scaleio['metadata']['enabled'] {
|
|||
require => Scaleio::Login['Normal'],
|
||||
}
|
||||
}
|
||||
$protection_domain_resource_name = "Ensure protection domain ${protection_domain}"
|
||||
scaleio::protection_domain {$protection_domain_resource_name:
|
||||
sio_name => $protection_domain,
|
||||
require => Scaleio::Login['Normal'],
|
||||
} ->
|
||||
storage_pool_ensure {$pools_array:
|
||||
protection_domain => $protection_domain,
|
||||
protection_domain_ensure {$protection_domain_array:
|
||||
pools_array => $pools_array,
|
||||
zero_padding => $zero_padding,
|
||||
scanner_mode => $scanner_mode,
|
||||
checksum_mode => $checksum_mode,
|
||||
|
@ -357,22 +381,23 @@ if $scaleio['metadata']['enabled'] {
|
|||
rfcache_storage_pools_array => $rfcache_storage_pools_array,
|
||||
rmcache_passthrough_pools => $rmcache_passthrough_pools,
|
||||
rmcache_cached_pools => $rmcache_cached_pools,
|
||||
require => Scaleio::Login['Normal'],
|
||||
} ->
|
||||
sds_ensure {$to_add_sds_names:
|
||||
sds_nodes => $sds_nodes,
|
||||
protection_domain => $protection_domain,
|
||||
sds_to_pd_map => $sds_to_pd_map,
|
||||
storage_pools => $pools,
|
||||
device_paths => $paths,
|
||||
rfcache_devices => $rfcache_devices,
|
||||
sds_devices_config => $sds_devices_config,
|
||||
require => Scaleio::Protection_domain[$protection_domain_resource_name],
|
||||
require => Protection_domain_ensure[$protection_domain_array],
|
||||
}
|
||||
if $capacity_high_alert_threshold and $capacity_critical_alert_threshold {
|
||||
scaleio::cluster {'Configure alerts':
|
||||
ensure => 'present',
|
||||
capacity_high_alert_threshold => $capacity_high_alert_threshold,
|
||||
capacity_critical_alert_threshold => $capacity_critical_alert_threshold,
|
||||
require => Scaleio::Protection_domain[$protection_domain_resource_name],
|
||||
require => Protection_domain_ensure[$protection_domain_array],
|
||||
}
|
||||
}
|
||||
# Apply high performance profile to SDC-es
|
||||
|
@ -380,7 +405,7 @@ if $scaleio['metadata']['enabled'] {
|
|||
if ! empty($sdc_nodes_ips) {
|
||||
scaleio::sdc {'Set performance settings for all available SDCs':
|
||||
ip => $sdc_nodes_ips[0],
|
||||
require => Scaleio::Protection_domain[$protection_domain_resource_name],
|
||||
require => Protection_domain_ensure[$protection_domain_array],
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -175,6 +175,27 @@ if $discovery_allowed == 'yes' and $mdm_ips and $mdm_ips != '' and $mdm_password
|
|||
result
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add(:scaleio_sds_with_protection_domain_list) do
|
||||
setcode do
|
||||
mdm_opts = "--mdm_ip %s" % $mdm_ips
|
||||
login_cmd = "scli %s --approve_certificate --login --username admin --password %s 1>/dev/null 2>>%s" % [mdm_opts, $mdm_password, $scaleio_log_file]
|
||||
query_cmd = "scli %s --approve_certificate --query_all_sds 2>>%s" % [mdm_opts, $scaleio_log_file]
|
||||
fiter_cmd = "awk '/Protection Domain/ {domain=$5} /SDS ID:/ {print($5\",\"domain)}'"
|
||||
cmd = "%s && %s | %s" % [login_cmd, query_cmd, fiter_cmd]
|
||||
debug_log(cmd)
|
||||
result = Facter::Util::Resolution.exec(cmd)
|
||||
if result
|
||||
result = result.split(' ')
|
||||
if result.count() > 0
|
||||
result = result.join(',')
|
||||
end
|
||||
end
|
||||
debug_log("%s='%s'" % ['scaleio_sds_with_protection_domain_list', result])
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
# Update the map of SDSes to protection domains according to SDS number limit in one domain
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:update_sds_to_pd_map, :type => :rvalue, :doc => <<-EOS
|
||||
Updates map of SDS to PD with new SDSes according to SDS number limit in one PD
|
||||
EOS
|
||||
) do |args|
|
||||
sds_to_pd_map = {}
|
||||
sds_to_pd_map.update(args[0])
|
||||
pd_name_template = args[1]
|
||||
pd_number = 1
|
||||
sds_limit = args[2].to_i
|
||||
new_sds_array = args[3]
|
||||
#prepare map of PDs to SDSes
|
||||
pd_to_sds_map = {}
|
||||
sds_to_pd_map.each do |sds, pd|
|
||||
if not pd_to_sds_map.has_key?(pd)
|
||||
pd_to_sds_map[pd] = []
|
||||
end
|
||||
pd_to_sds_map[pd] << sds
|
||||
end
|
||||
# map new SDSes to PDs
|
||||
new_sds_array.select{|sds| not sds_to_pd_map.has_key?(sds)}.each do |sds|
|
||||
suitable_pd_array = pd_to_sds_map.select{|pd, sds_es| sds_limit == 0 or sds_es.length < sds_limit}.keys
|
||||
if suitable_pd_array.length == 0
|
||||
pd_name = nil
|
||||
while not pd_name
|
||||
proposed_name = pd_number == 1 ? pd_name_template : "%s_%s" % [pd_name_template, pd_number]
|
||||
pd_number += 1
|
||||
if not pd_to_sds_map.has_key?(proposed_name)
|
||||
pd_name = proposed_name
|
||||
end
|
||||
end
|
||||
pd_to_sds_map[pd_name] = []
|
||||
suitable_pd_array = [pd_name]
|
||||
end
|
||||
suitable_pd = suitable_pd_array[0]
|
||||
pd_to_sds_map[suitable_pd] << sds
|
||||
sds_to_pd_map[sds] = suitable_pd
|
||||
end
|
||||
return sds_to_pd_map
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue