Skip to content

Instantly share code, notes, and snippets.

@markmc
Created May 31, 2011 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmc/1000672 to your computer and use it in GitHub Desktop.
Save markmc/1000672 to your computer and use it in GitHub Desktop.
Image Factory Console Hack Hack
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 c196632..788d86f 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
@@ -65,8 +65,8 @@ class ImageFactoryConsole < Qmf2::ConsoleHandler
# TODO: return error if there is a problem calling this method or getting
# a factory instance
begin
- response = factory.image(descriptor, target)
- build_adaptor(response)
+ response = factory.build_image('', '', descriptor, [target])
+ build_adaptors(response)
rescue Exception => e
@logger.debug "Encountered error in build_image: #{e}"
return e
@@ -82,12 +82,12 @@ class ImageFactoryConsole < Qmf2::ConsoleHandler
# XML block to be used for registration, upload, etc
# * Returns => a BuildAdaptor object
#
- def push_image(image_id, provider, credentials)
+ def push_image(image_id, build_id, provider, credentials)
# TODO: return error if there is a problem calling this method or getting
# a factory instance
begin
- response = factory.provider_image(image_id, provider, credentials)
- build_adaptor(response)
+ response = factory.push_image(image_id, build_id, [provider], credentials)
+ build_adaptors(response)
rescue Exception => e
@logger.debug "Encountered error in push_image: #{e}"
return e
@@ -145,7 +145,45 @@ class ImageFactoryConsole < Qmf2::ConsoleHandler
@q.query(query,5).first
end
+ def build_adaptors(response)
+ ret = []
+ response['build_adaptors'].each do |imgfacaddr|
+ puts imgfacaddr
+ query = Qmf2::Query.new(Qmf2::DataAddr.new(imgfacaddr))
+ ret << @q.query(query,5).first
+ end
+ ret
+ end
end
-#i = ImageBuilderConsole.new
-#i.run
+
+
+i = ImageFactoryConsole.new
+i.start
+
+while i.q.nil?
+ puts "waiting"
+ sleep 1
+end
+puts "finished waiting"
+
+tmpl = '<template> <name>tmpl1</name> <description>foo</description> <os> <name>Fedora</name> <arch>x86_64</arch> <version>14</version> <install type="url"> <url>http://download.fedoraproject.org/pub/fedora/linux/releases/14/Fedora/x86_64/os/</url> </install> </os> <repositories> <repository name="custom"> <url>http://repos.fedorapeople.org/repos/aeolus/demo/webapp/</url> <signed>false</signed> </repository> </repositories> </template>'
+adaptors = i.build_image(tmpl, "mock")
+
+ba = adaptors[0]
+puts ba.inspect
+puts "image_id=" + ba.image_id
+puts "status=" + ba.status
+puts "percent_complete=" + ba.percent_complete.to_s
+puts "image=" + ba.image
+puts "build=" + ba.build
+
+adaptors = i.push_image(ba.image, '', 'mock1', '<provider_credentials/>')
+
+ba = adaptors[0]
+puts ba.inspect
+puts "image_id=" + ba.image_id
+puts "status=" + ba.status
+puts "percent_complete=" + ba.percent_complete.to_s
+puts "image=" + ba.image
+puts "build=" + ba.build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment