From: Martyn Taylor <mtaylor(a)redhat.com>
---
.../image_factory/aeolus-image/lib/list_command.rb | 26 +++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/services/image_factory/aeolus-image/lib/list_command.rb
b/services/image_factory/aeolus-image/lib/list_command.rb
index eb44cb1..5f97b2f 100644
--- a/services/image_factory/aeolus-image/lib/list_command.rb
+++ b/services/image_factory/aeolus-image/lib/list_command.rb
@@ -23,12 +23,36 @@ module Aeolus
end
def providers
- not_implemented
+ print_values = [["NAME", "TYPE", "URL"]]
+
+ doc = Nokogiri::XML conductor['/providers'].get
+ doc.xpath("/providers/provider").each do |provider|
+ print_values << [provider.xpath("name").text,
provider.xpath("provider_type").text, provider.xpath("url").text]
+ end
+
+ format_print(print_values)
+ quit(0)
end
def accounts
not_implemented
end
+
+ private
+ # Takes a 2D array of strings and neatly prints them to STDOUT
+ def format_print(print_values)
+ widths = Array.new(print_values[0].size, 0)
+ print_values.each do |print_value|
+ widths = widths.zip(print_value).map! {|width, value| value.length > width ?
value.length : width }
+ end
+
+ print_values.each do |print_value|
+ widths.zip(print_value) do |width, value|
+ printf("%-#{width + 5}s", value)
+ end
+ puts ""
+ end
+ end
end
end
end
--
1.7.4
Show replies by thread
From: Martyn Taylor <mtaylor(a)redhat.com>
---
.../image_factory/aeolus-image/lib/list_command.rb | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/services/image_factory/aeolus-image/lib/list_command.rb
b/services/image_factory/aeolus-image/lib/list_command.rb
index 5f97b2f..46bb2b8 100644
--- a/services/image_factory/aeolus-image/lib/list_command.rb
+++ b/services/image_factory/aeolus-image/lib/list_command.rb
@@ -35,7 +35,14 @@ module Aeolus
end
def accounts
- not_implemented
+ print_values = [["NAME", "PROVIDER", "PROVIDER
TYPE"]]
+ doc = Nokogiri::XML conductor['/provider_accounts/'].get
+ doc.xpath("/provider_accounts/provider_account").each do |account|
+ print_values << [account.xpath("name").text,
account.xpath("provider").text, account.xpath("provider_type").text]
+ end
+
+ format_print(print_values)
+ quit(0)
end
private
--
1.7.4