On 08/05/2011 11:44 AM, mtaylor(a)redhat.com wrote:
From: Martyn Taylor<mtaylor(a)redhat.com>
This seporates out listing and printing target images, so that listing target images can
be used as a utility method for other commands
---
lib/list_command.rb | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/lib/list_command.rb b/lib/list_command.rb
index ca7308a..69fa7df 100644
--- a/lib/list_command.rb
+++ b/lib/list_command.rb
@@ -46,17 +46,30 @@ module Aeolus
end
def targetimages
- check_bucket_exists("target-images")
+ targetimages = [["Target Image Id"]]
+ list_targetimages(@options[:id]).each do |ti|
+ targetimages<< [ti]
+ end
+ format_print(targetimages)
+ quit(0)
+ end
+
+ def list_targetimages(build)
+ targetimages = []
+ if check_bucket_exists("target_images").nil?
+ return targetimages
+ end
+
doc = Nokogiri::XML iwhd['/target_images'].get
doc.xpath("/objects/object/key").each do |target_image|
begin
- if iwhd['/target_images/' + target_image.text +
"/build"].get == @options[:id]
- puts target_image.text
+ if iwhd['/target_images/' + target_image.text +
"/build"].get == build
+ targetimages<< target_image.text
end
rescue RestClient::ResourceNotFound
end
end
- quit(0)
+ targetimages
end
def providerimages
ACK