deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [1/2] git commit: Fixes file injection for Openstack Instances. Part of resolution for JIRA DTACLOUD_204
Date Tue, 05 Jun 2012 08:34:01 GMT
Updated Branches:
  refs/heads/master 8e5669ad8 -> d46d6a1a3


Fixes file injection for Openstack Instances.
Part of resolution for JIRA DTACLOUD_204

https://issues.apache.org/jira/browse/DTACLOUD-204


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/36ca5bed
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/36ca5bed
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/36ca5bed

Branch: refs/heads/master
Commit: 36ca5bed7edc8cfcc3f5e6e87a1bda71c272bf90
Parents: 8e5669a
Author: marios <marios@redhat.com>
Authored: Mon Jun 4 12:59:33 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Tue Jun 5 11:32:47 2012 +0300

----------------------------------------------------------------------
 .../drivers/openstack/openstack_driver.rb          |   21 ++++++++++-----
 1 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/36ca5bed/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
index da4c9a5..df8e823 100644
--- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
+++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
@@ -133,8 +133,8 @@ module Deltacloud
           os = new_client( credentials )
           result = nil
 #opts[:personality]: path1='server_path1'. content1='contents1', path2='server_path2', content2='contents2'
etc
-          params = extract_personality(opts)
-#          ref_prefix = get_prefix(os)
+          params = {}
+          params[:personality] = extract_personality(opts)
           params[:name] = (opts[:name] && opts[:name].length>0)? opts[:name] :
Time.now.to_s
           params[:imageRef] = image_id
           params[:flavorRef] =  (opts[:hwp_id] && opts[:hwp_id].length>0) ?
@@ -323,10 +323,17 @@ private
         #OUT:{local_path=>server_path, local_path1=>server_path2 etc}
         def extract_personality(opts)
           personality_hash =  opts.inject({}) do |result, (opt_k,opt_v)|
-            if opt_k.to_s =~ /^path([1-5]+)/
-              tempfile = Tempfile.new("os_personality_local_#{$1}")
-              tempfile.write(opts[:"content#{$1}"])
-              result[tempfile.path]=opts[:"path#{$1}"]
+            if (opt_k.to_s =~ /^path([1-5]+)/ and opts[opt_k] != nil and opts[opt_k].length
> 0)
+              unless opts[:"content#{$1}"].nil?
+                case opts[:"content#{$1}"]
+                  when String
+                    tempfile = Tempfile.new("os_personality_local_#{$1}")
+                    tempfile.write(opts[:"content#{$1}"])
+                    result[tempfile.path]=opts[:"path#{$1}"]
+                  when Hash
+                    result[opts[:"content#{$1}"][:tempfile].path]=opts[:"path#{$1}"]
+                end
+              end
             end
             result
           end
@@ -342,7 +349,7 @@ private
 
         exceptions do
 
-          on /Exception::BadRequest/ do
+          on /(Exception::BadRequest|PersonalityFilePathTooLong|PersonalityFileTooLarge|TooManyPersonalityItems)/
do
             status 400
           end
 


Mime
View raw message