def configure_dependencies
reply = ResultIO.new
self.class.notify_observers(:before_application_configure, {:application => self, :reply => reply})
elaborate_descriptor
exceptions = []
Rails.logger.debug "Configure order is #{self.configure_order.inspect}"
self.configure_order.each do |comp_inst_name|
comp_inst = self.comp_instance_map[comp_inst_name]
next if comp_inst.parent_cart_name == self.name
group_inst = self.group_instance_map[comp_inst.group_instance_name]
begin
group_inst.fulfil_requirements(self)
run_on_gears(group_inst.get_unconfigured_gears(comp_inst), reply) do |gear, r|
doExpose = false
if self.scalable and comp_inst.parent_cart_name!=self.proxy_cartridge
doExpose = true if not gear.configured_components.include? comp_inst.name
end
r.append gear.configure(comp_inst, @init_git_url)
begin
r.append gear.expose_port(comp_inst) if doExpose
rescue Exception=>e
end
process_cartridge_commands(r)
end
rescue Exception => e
Rails.logger.debug e.message
Rails.logger.debug e.backtrace.inspect
if e.message.kind_of?(Hash) and e.message[:exception]
successful_gears = []
successful_gears = e.message[:successful].map{|g| g[:gear]} if e.message[:successful]
failed_gears = []
failed_gears = e.message[:failed].map{|g| g[:gear]} if e.message[:failed]
gear_exception = e.message[:exception]
run_on_gears(successful_gears, reply, false) do |gear, r|
r.append gear.deconfigure(comp_inst)
process_cartridge_commands(r)
end
run_on_gears(failed_gears, reply, false) do |gear, r|
r.append gear.deconfigure(comp_inst, true)
process_cartridge_commands(r)
end
else
gear_exception = e
end
run_on_gears(group_inst.gears, reply, false) do |gear, r|
r.append group_inst.remove_gear(gear) if gear.configured_components.length == 0
end
self.save
exceptions << gear_exception
end
end
unless exceptions.empty?
raise exceptions.first
end
self.save
self.class.notify_observers(:after_application_configure, {:application => self, :reply => reply})
reply
end