From 64476abbf0a8f9425db70a19e14f8768d4905434 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 28 Mar 2012 19:24:21 +0200 Subject: [PATCH] feature #1141: Add url support to quota.rb --- src/authm_mad/remotes/quota/quota.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/authm_mad/remotes/quota/quota.rb b/src/authm_mad/remotes/quota/quota.rb index fedddd5f3e..e7a94b166e 100644 --- a/src/authm_mad/remotes/quota/quota.rb +++ b/src/authm_mad/remotes/quota/quota.rb @@ -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