From: Martyn Taylor <mtaylor(a)redhat.com>
---
lib/config_parser.rb | 4 ++++
lib/delete_command.rb | 29 +++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/lib/config_parser.rb b/lib/config_parser.rb
index fdbebf3..0a8f647 100644
--- a/lib/config_parser.rb
+++ b/lib/config_parser.rb
@@ -115,6 +115,10 @@ module Aeolus
opts.separator ""
opts.separator "Delete options:"
+ opts.on('-B', '--build ID', 'delete build and associated
objects') do |id|
+ @options[:subcommand] = :build
+ @options[:build] = id
+ end
opts.on('-m', '--targetimage ID', 'delete target image and
its provider images') do |id|
@options[:subcommand] = :target_image
@options[:targetimage] = id
diff --git a/lib/delete_command.rb b/lib/delete_command.rb
index 2c0f7a9..28d1ad7 100644
--- a/lib/delete_command.rb
+++ b/lib/delete_command.rb
@@ -37,6 +37,22 @@ module Aeolus
end
end
+ def build
+ check_id(@options[:build], "Build")
+ begin
+ delete_build(@options[:build])
+ puts "Build: '" + @options[:build] + "' was succesfully
deleted"
+ exit(0)
+ rescue RestClient::ResourceNotFound
+ puts "Error: Could not find Build with ID: '" + @options[:build]
+ "'"
+ exit(1)
+ rescue => e
+ puts "Error: Could not delete Build with ID: '" +
@options[:build] + "'"
+ puts e.inspect
+ exit(1)
+ end
+ end
+
private
def delete_provider_image(provider_image)
iwhd['/provider_images/' + provider_image].delete
@@ -55,6 +71,19 @@ module Aeolus
iwhd['/target_images/' + target_image].delete
end
+ def delete_build(build)
+ # Delete Target Images
+ list_command = ListCommand.new
+ list_command.list_targetimages(build).each do |target_image|
+ begin
+ delete_target_image(target_image)
+ rescue
+ end
+ end
+ # Delete Build
+ iwhd['/builds/' + build].delete
+ end
+
def check_id(uuid, type)
if !(is_uuid?(uuid))
puts "Error: '" + uuid + "' is not a valid " + type
+ " ID"
--
1.7.4