Unable to use API to call bpy.ops.render.opengl()
The operator works correctly and will render your image. However with the default arguments it won't switch to the UV/Image Editor. If you intend to replicate the behavior of Render > OpenGL Render Image then you will have to change the execution context. In general buttons in the user interface use 'INVOKE_DEFAULT' as execution context.

bpy.ops.render.opengl('INVOKE_DEFAULT')


Additionally you can use the write_still=True argument to save the file. It will write the file to the path specified in bpy.context.scene.render.filepath. The last line in your script could then be removed.