def move_gear_post(app, gear, destination_container, state_map)
reply = ResultIO.new
source_container = gear.container
gi = app.group_instance_map[gear.group_instance_name]
app.start_order.each do |ci_name|
next if not gi.component_instances.include? ci_name
cinst = app.comp_instance_map[ci_name]
cart = cinst.parent_cart_name
next if cart==app.name
idle, leave_stopped = state_map[ci_name]
unless leave_stopped
log_debug "DEBUG: Starting cartridge '#{cart}' in '#{app.name}' after move on #{destination_container.id}"
reply.append destination_container.send(:run_cartridge_command, cart, app, gear, "start", nil, false)
end
end
log_debug "DEBUG: Fixing DNS and mongo for gear '#{gear.name}' after move"
log_debug "DEBUG: Changing server identity of '#{gear.name}' from '#{source_container.id}' to '#{destination_container.id}'"
gear.server_identity = destination_container.id
gear.container = destination_container
if app.scalable and not gi.component_instances.include? app.proxy_cartridge
dns = OpenShift::DnsService.instance
begin
public_hostname = destination_container.get_public_hostname
dns.modify_application(gear.name, app.domain.namespace, public_hostname)
dns.publish
ensure
dns.close
end
end
if (not app.scalable) or (app.scalable and gi.component_instances.include? app.proxy_cartridge)
unless app.aliases.nil?
app.aliases.each do |server_alias|
reply.append destination_container.send(:run_cartridge_command, app.framework, app, app.gear, "add-alias", server_alias, false)
end
end
app.recreate_dns
end
reply
end