def set_user_min(cart_group_map, min_scale)
return if not min_scale
cart_current_min, cart_current_max, sup_min, sup_max = get_user_min_max(cart_group_map)
cart_current_max = 1000000 if cart_current_max==-1
if (Integer(min_scale) < sup_min or Integer(min_scale) > cart_current_max)
raise OpenShift::UserException.new("Invalid scales_from factor #{min_scale} provided. Value out of allowed range ( #{sup_min} : #{cart_current_max==1000000 ? -1 : cart_current_max} ).", 168)
end
target_min = Integer(min_scale) - cart_current_min
iter = cart_group_map.keys.each
while target_min != 0 do
begin
group_name = iter.next
break if group_name.nil?
rescue Exception=>e
break
end
ginst = self.group_instance_map[group_name]
ginst_max = ginst.max
ginst_max = 1000000 if ginst.max==-1
if target_min > 0
if (ginst_max-ginst.min)>target_min
ginst.min += target_min
target_min = 0
else
target_min -= (ginst_max-ginst.min)
ginst.min = ginst_max
end
else
if (ginst.supported_min-ginst.min) < target_min
ginst.min += target_min
target_min = 0
else
target_min += (ginst.min-ginst.supported_min)
ginst.min = ginst.supported_min
end
end
end
self.save
if target_min != 0
raise OpenShift::UserException.new("Could not completely distribute scales_from to all groups. Value constrained to #{Integer(min_scale)-target_min}", 169)
end
end