def run_cartridge_command(framework, app, gear, command, arg=nil, allow_move=true)
arguments = "'#{gear.name}' '#{app.domain.namespace}' '#{gear.uuid}'"
arguments += " '#{arg}'" if arg
result = execute_direct(framework, command, arguments)
begin
resultIO = parse_result(result, app, command)
rescue OpenShift::InvalidNodeException => e
if command != 'configure' && allow_move
@id = e.server_identity
Rails.logger.debug "DEBUG: Changing server identity of '#{gear.name}' from '#{gear.server_identity}' to '#{@id}'"
dns_service = OpenShift::DnsService.instance
dns_service.modify_application(gear.name, app.domain.namespace, get_public_hostname)
dns_service.publish
gear.server_identity = @id
app.save
result = execute_direct(framework, command, arguments)
resultIO = parse_result(result, app, command)
else
raise
end
end
Rails.logger.debug "DEBUG: Cartridge command #{framework}::#{command} exitcode = #{resultIO.exitcode}"
if resultIO.exitcode != 0
resultIO.debugIO << "Cartridge return code: " + resultIO.exitcode.to_s
begin
raise OpenShift::NodeException.new("Node execution failure (invalid exit code from node). If the problem persists please contact Red Hat support.", 143, resultIO)
rescue OpenShift::NodeException => e
if command == 'deconfigure'
if framework.start_with?('embedded/')
if has_embedded_app?(app.uuid, framework[9..-1])
raise
else
Rails.logger.debug "DEBUG: Component '#{framework}' in application '#{app.name}' not found on node '#{@id}'. Continuing with deconfigure."
end
else
if has_app?(app.uuid, app.name)
raise
else
Rails.logger.debug "DEBUG: Application '#{app.name}' not found on node '#{@id}'. Continuing with deconfigure."
end
end
else
raise
end
end
end
resultIO
end