def set_user_max(cart_group_map, max_scale)
return if not max_scale
cart_current_min, cart_current_max, sup_min, sup_max = get_user_min_max(cart_group_map)
sup_max = 1000000 if sup_max==-1
max_scale_int = Integer(max_scale)
max_scale_int = 1000000 if max_scale_int==-1
if (max_scale_int and ( max_scale_int > sup_max or max_scale_int < cart_current_min) )
raise OpenShift::UserException.new("Invalid scales_to factor #{max_scale} provided. Value out of allowed range ( #{cart_current_min} : #{sup_max==1000000 ? -1 : sup_max} ).", 168)
end
target_max = Integer(max_scale)
cart_group_map.keys.each { |group_name, component_instances|
gi = self.group_instance_map[group_name]
if target_max==-1
next if gi.supported_max!=-1
gi.max = target_max
break
end
if gi.supported_max==-1 or( (gi.supported_max-gi.min) > target_max )
rest_total = 0
cart_group_map.keys.each { |other_group_name|
next if other_group_name==group_name
other_gi = self.group_instance_map[other_group_name]
if other_gi.max == -1
other_gi.max==other_gi.min
end
rest_total += other_gi.max
}
gi.max = (target_max-rest_total)
break
end
}
self.save
end