From: Martyn Taylor mtaylor@redhat.com
--- .../lib/image_factory/image_factory_console.rb | 27 ++++++++++++++++++++ .../console/spec/image_factory/console_spec.rb | 14 ++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/services/image_factory/console/lib/image_factory/image_factory_console.rb b/services/image_factory/console/lib/image_factory/image_factory_console.rb index 01d64bd..ed22a9b 100644 --- a/services/image_factory/console/lib/image_factory/image_factory_console.rb +++ b/services/image_factory/console/lib/image_factory/image_factory_console.rb @@ -103,6 +103,33 @@ class ImageFactoryConsole < Qmf2::ConsoleHandler end end
+# Call this method to import an image +# array of BuildAdaptor objects. +# * image => string +# The uuid of an existing image +# * build => string +# the uuid of an existing build, or the empty string +# * target_identifier => string +# the target specific image ID +# * image_desc => string +# an xml string description of the image +# * target => string +# name of the cloud to target +# * provider => string +# the name of the cloud provider, often a region +# Returns => a map including UUIDs as strings for 'target_image', 'build', 'image', 'provider_image' + + def import_image(image, build, target_identifier, image_description, target, provider) + # TODO: return error if there is a problem calling this method or getting + # a factory instance + begin + factory.import_image(image, build, target_identifier, image_description, target, provider) + rescue Exception => e + @logger.debug "Encountered error in import_image: #{e}" + return e + end + end + # <b>DEPRECATED:</b> Please use <tt>build</tt> instead. # Call this method to initiate a build, and get back an # BuildAdaptor object. diff --git a/services/image_factory/console/spec/image_factory/console_spec.rb b/services/image_factory/console/spec/image_factory/console_spec.rb index 41a6ed1..a575135 100644 --- a/services/image_factory/console/spec/image_factory/console_spec.rb +++ b/services/image_factory/console/spec/image_factory/console_spec.rb @@ -43,6 +43,16 @@ module ImageFactory end end
+ describe "#import_image" do + it "should return a build-adaptor with uuid" do + @import = @i.import_image("", "", "ami-test", "<image><name>Test Image</name></image>", "ec2", "ec2-us-east-1") + is_uuid?(@import['image']).should == true + is_uuid?(@import['target_image']).should == true + is_uuid?(@import['build']).should == true + is_uuid?(@import['provider_image']).should == true + end + end + describe "#build" do it "should return an array of build-adaptors with uuids" do @i.build("<template></template>", ["mock"]).each do |adaptor| @@ -199,5 +209,9 @@ module ImageFactory end end
+ def is_uuid?(test_string) + regexp = Regexp.new('^[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}') + regexp.match(test_string) ? true : false + end end end
On Wed, 2011-06-15 at 17:06 +0100, mtaylor@redhat.com wrote:
From: Martyn Taylor mtaylor@redhat.com
.../lib/image_factory/image_factory_console.rb | 27 ++++++++++++++++++++ .../console/spec/image_factory/console_spec.rb | 14 ++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-)
ACK, looks good, tests all pass with Mark's latest stuff.
-j
aeolus-devel@lists.fedorahosted.org