1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Improve Selfservice/OCCI upload.

Wait until images have been successfully copied into the repository by opennebula  to return from request.
(cherry picked from commit 2630d1c6a7a630b26646107f88c33e2ae1500671)
This commit is contained in:
Hector Sanjuan 2012-02-14 18:59:00 +01:00 committed by Ruben S. Montero
parent d0c6453c9b
commit a5d72b936c
3 changed files with 12 additions and 7 deletions

View File

@ -45,6 +45,9 @@ COLLECTIONS = ["compute", "instance_type", "network", "storage"]
# FLAG that will filter the elements retrieved from the Pools
POOL_FILTER = Pool::INFO_ALL
# Secs to sleep between checks to see if image upload&copy to repo is finished
IMAGE_POLL_SLEEP_TIME = 1
class OCCIServer < CloudServer
# Server initializer
# config_file:: _String_ path of the config file
@ -410,8 +413,14 @@ class OCCIServer < CloudServer
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
end
# --- Prepare XML Response ---
image.info
#wait until image is ready to return
while (image.state_str == 'LOCKED') && (image['RUNNING_VMS'] == '0') do
sleep IMAGE_POLL_SLEEP_TIME
image.info
end
# --- Prepare XML Response ---
return to_occi_xml(image, :status=>201)
end

View File

@ -366,13 +366,9 @@ get '/ui' do
end
post '/ui/upload' do
file = Tempfile.new('uploaded_image')
FileUtils.cp(request.env['rack.input'].path, file.path)
#so we can re-use occi post_storage()
request.params['file'] = {:tempfile => file}
request.params['file'] = {:tempfile => request.env['rack.input']}
result,rc = @occi_server.post_storage(request)
treat_response(result,rc)
end

View File

@ -478,7 +478,7 @@ function popUpCreateImageDialog(){
multiple: false,
params: {},
showMessage: function(message){
notifyMessage(message);
//notifyMessage(message);
},
onSubmit: function(id, fileName){
var xml = json2xml(img_obj,"STORAGE");