1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

UploadImage and changed RegisterImage

git-svn-id: http://svn.opennebula.org/one/trunk@725 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Javier Fontán Muiños 2009-07-22 13:55:08 +00:00
parent 440d6f4da8
commit 07e566eb43

View File

@ -134,7 +134,8 @@ def authenticate(params)
halt 401, "User does not exist" if !user
signature_params=params.reject {|key,value| key=='Signature' }
signature_params=params.reject {|key,value|
key=='Signature' or key=='file' }
canonical=EC2.canonical_string(signature_params, CONFIG[:server])
signature=EC2.encode(user[:password], canonical, false)
@ -146,10 +147,29 @@ before do
end
def upload_image(params)
user=get_user(params['AWSAccessKeyId'])
file=params["file"]
# tmpfile where the file is stored
f_tmp=file[:tempfile]
img=$repoman.add(user[:id], f_tmp.path)
f_tmp.unlink
@img_id=img.uuid
erb :register_image
end
def register_image(params)
user=get_user(params['AWSAccessKeyId'])
uuid=params['ImageLocation']
img=$repoman.get(uuid)
halt 404, 'Image not found' if !img
halt 401, 'Not permited to use image' if user[:id]!=img[:owner]
img=$repoman.add(user[:id], params["ImageLocation"])
@img_id=img.uuid
erb :register_image
@ -220,6 +240,8 @@ post '/' do
pp params
case params['Action']
when 'UploadImage'
upload_image(params)
when 'RegisterImage'
register_image(params)
when 'DescribeImages'