Image upload to Sunstone running under Apache
|Assignee:||Daniel Molina||% Done:|
|Target version:||Release 4.4|
|Affected Versions:||OpenNebula 4.2|
I'm running OpenNebula and Sunstone 4.2.0-1 on a Debian 7.1 machine. Sunstone is running under Apache 2.2.22-13 (with SSL) via mod_passenger.
When I try to upload an image (Virtual Resources -> Images -> Create -> 'Image Location' set to 'upload') the operation hangs.
The temporary file is not uploaded to the folder specified in /etc/one/sunstone-server.conf as :tmpdir:, even if it is owned by the same user running Apache.
The progress bar is filled, but in the Sunstone logfile (/var/log/one/sunstone.log) I see the following error:
Thu Oct 24 11:12:59 2013 [E]: Unexpected rackinput class PhusionPassenger::Utils::RewindableInput
and then this message
Thu Oct 24 11:12:59 2013 [I]: 18.104.22.168 - - [24/Oct/2013 11:12:59] "POST /upload?img=%7B%22image%22%3A%7B%22NAME%22%3A%22voyageupl%22%2C%22TYPE%22%3A%22OS%22%2C%22PERSISTENT%22%3A%22NO%22%7D%2C%22ds_id%22%3A%221%22%7D&file=voyage.img&qqfile=voyage.img " 500 - 0.0022
The file doesn't show up in the datastore.
Is it possible that this is a bug?
Thanks for the help.
#2 Updated by Daniel Molina over 7 years ago
Indeed it is a bug, could you try changing the following in your code:
diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 167bcdd..2876aa2 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -408,7 +408,7 @@ post '/upload'do if (rackinput.class == Tempfile) tmpfile = rackinput - elsif (rackinput.class == StringIO) + elsif (rackinput.class == StringIO || rackinput.class == PhusionPassenger::Utils::RewindableInput) tmpfile = Tempfile.open('sunstone-upload') tmpfile.write rackinput.read tmpfile.flush
This code is necessary since we need a path to create the image