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

feature #1141: Add url support to quota.rb

This commit is contained in:
Daniel Molina 2012-03-28 19:24:21 +02:00
parent d843e111d3
commit 64476abbf0

View File

@ -17,6 +17,8 @@
require 'sequel'
require 'base64'
require 'yaml'
require 'uri'
require 'net/http'
class Quota
###########################################################################
@ -82,7 +84,15 @@ class Quota
if template['TYPE'] == 'DATABLOCK'
template['SIZE'].to_i
elsif template['PATH']
(File.size(template['PATH']).to_f / 2**20).round
uri = URI.parse(template['PATH'])
size = if uri.scheme.nil?
File.size(template['PATH'])
else
Net::HTTP.start(uri.host,uri.port) { |http|
http.head(uri.path)
}.content_length
end
(size.to_f / 2**20).round
elsif template['SAVED_VM_ID']
vm_id = template['SAVED_VM_ID'].to_i
disk_id = template['SAVED_DISK_ID'].to_i