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.
This commit is contained in:
parent
07adba6f54
commit
2630d1c6a7
@ -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© 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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user