# File lib/openshift-origin-controller/app/models/component_instance.rb, line 93
  def self.establish_connections(inst1, inst2, app)
    comp1,prof1,cart1 = inst1.get_component_definition(app)
    comp2,prof2,cart2 = inst2.get_component_definition(app)

    new_connections = []
    
    comp1.publishes.each do |pub|
      comp2.subscribes.each do |sub|
        next if not pub.type==sub.type
        ce = ConnectionEndpoint.new(inst1, inst2, pub, sub) 
        app.conn_endpoints_list << ce
        new_connections << ce
      end
    end
    return if inst1==inst2
    comp1.subscribes.each do |sub|
      comp2.publishes.each do |pub|
        next if not pub.type==sub.type
        ce = ConnectionEndpoint.new(inst2, inst1, pub, sub) 
        app.conn_endpoints_list << ce
        new_connections << ce
      end
    end
    new_connections
  end