From: Jan Provaznik jprovazn@redhat.com
https://www.aeolusproject.org/redmine/issues/2863
Before a template or image is saved into warehouse, check if the bucket for the template/image exists, if not, create it. --- .../model/warehouse/warehouse_model.rb | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/lib/aeolus_image/model/warehouse/warehouse_model.rb b/lib/aeolus_image/model/warehouse/warehouse_model.rb index 6ec02fa..ab2498e 100644 --- a/lib/aeolus_image/model/warehouse/warehouse_model.rb +++ b/lib/aeolus_image/model/warehouse/warehouse_model.rb @@ -154,6 +154,17 @@ module Aeolus
def create!(key, body, attributes) self.set_warehouse_and_bucket if self.bucket.nil? + unless self.warehouse.buckets.include?(self.bucket.name) + begin + self.bucket = self.warehouse.create_bucket(self.bucket.name) + rescue + # there was an iwhd bug ago - it wasn't possible to find out + # if a bucket exists or not, then code 500 was returned. + # I'm not sure if it's already fixed or not so I'm wrapping it + # with rescue block. If exception is raised we can assume + # that bucket already exists. + end + end obj = self.bucket.create_object(key, body, attributes) self.new(obj) end
On 11/30/2011 09:20 PM, jprovazn@redhat.com wrote:
From: Jan Provaznikjprovazn@redhat.com
https://www.aeolusproject.org/redmine/issues/2863
Before a template or image is saved into warehouse, check if the bucket for the template/image exists, if not, create it.
.../model/warehouse/warehouse_model.rb | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/lib/aeolus_image/model/warehouse/warehouse_model.rb b/lib/aeolus_image/model/warehouse/warehouse_model.rb index 6ec02fa..ab2498e 100644 --- a/lib/aeolus_image/model/warehouse/warehouse_model.rb +++ b/lib/aeolus_image/model/warehouse/warehouse_model.rb @@ -154,6 +154,17 @@ module Aeolus
def create!(key, body, attributes) self.set_warehouse_and_bucket if self.bucket.nil?
unless self.warehouse.buckets.include?(self.bucket.name)
begin
self.bucket = self.warehouse.create_bucket(self.bucket.name)
rescue
# there was an iwhd bug ago - it wasn't possible to find out
# if a bucket exists or not, then code 500 was returned.
# I'm not sure if it's already fixed or not so I'm wrapping it
# with rescue block. If exception is raised we can assume
# that bucket already exists.
end
end obj = self.bucket.create_object(key, body, attributes) self.new(obj) end
ACK
aeolus-devel@lists.fedorahosted.org