On 07/18/2011 05:14 PM, mtaylor(a)redhat.com wrote:
From: Martyn Taylor<mtaylor(a)redhat.com>
---
.../aeolus-image/lib/config_parser.rb | 4 ++--
.../image_factory/aeolus-image/lib/push_command.rb | 19 ++++++++++++++++++-
.../aeolus-image/man/aeolus-image-push.1 | 6 +++++-
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/services/image_factory/aeolus-image/lib/config_parser.rb
b/services/image_factory/aeolus-image/lib/config_parser.rb
index 60b40cd..8e98971 100644
--- a/services/image_factory/aeolus-image/lib/config_parser.rb
+++ b/services/image_factory/aeolus-image/lib/config_parser.rb
@@ -141,8 +141,8 @@ module Aeolus
opts.separator ""
opts.separator "Push examples:"
- opts.separator "aeolus-image push --provider ec2-us-east-1 --id $image_id
# push the image to the specified provider"
- opts.separator "aeolus-image push --build $build_id
# (NOT IMPLEMENTED) push all target images for a build, to same providers as
previously"
+ opts.separator "aeolus-image push --provider ec2-us-east-1 --id $image_id
# initial push of an image build via image id to the specified provider"
+ opts.separator "aeolus-image push --build $build_id
# push an image build via build id to the specified provider"
opts.separator "aeolus-image push --account $provider_account --build
$build_id # (NOT IMPLEMENTED) ditto, using a specific provider account"
opts.separator "aeolus-image push --image $image_id
# (NOT IMPLEMENTED) push all the target images for the latest build"
diff --git a/services/image_factory/aeolus-image/lib/push_command.rb
b/services/image_factory/aeolus-image/lib/push_command.rb
index 69a0776..b2c863e 100644
--- a/services/image_factory/aeolus-image/lib/push_command.rb
+++ b/services/image_factory/aeolus-image/lib/push_command.rb
@@ -18,6 +18,14 @@ module Aeolus
def run
begin
if combo_implemented?
+ if !@options[:id].empty?
+ if pushed?(@options[:id])
How about joining the two expressions with '&&' into a single if?
+ puts "ERROR: This image has already been
pushed, to push to another provider please push via build-id rather than image-id"
+ puts "e.g. aeolus-image push --provider<provider>
--build<build-id>"
+ quit(1)
+ end
+ end
+
sleep(5)
@console.push(@options[:provider], get_creds, @options[:id],
@options[:build]).each do |adaptor|
puts ""
@@ -40,7 +48,7 @@ module Aeolus
end
def combo_implemented?
- if @options[:provider].empty? || @options[:id].empty?
+ if @options[:provider].empty? || (@options[:build].empty?&&
@options[:id].empty?)
puts "This combination of parameters is not currently supported"
quit(1)
end
@@ -52,6 +60,15 @@ module Aeolus
@console.shutdown
exit(code)
end
+
+ def pushed?(image)
+ begin
+ uuid = Regexp.new('[\w]{8}[-][\w]{4}[-][\w]{4}[-][\w]{4}[-][\w]{12}')
+ uuid.match(iwhd["/images/" + image +
"/latest_unpushed"].get).nil? ? true : false
You can drop the `? true : false` part at the end. uuid.match(...).nil?
already returns the desired value.
+ rescue
+ true
+ end
+ end
end
end
end
diff --git a/services/image_factory/aeolus-image/man/aeolus-image-push.1
b/services/image_factory/aeolus-image/man/aeolus-image-push.1
index 76fab4e..c2e0215 100644
--- a/services/image_factory/aeolus-image/man/aeolus-image-push.1
+++ b/services/image_factory/aeolus-image/man/aeolus-image-push.1
@@ -26,10 +26,14 @@ Get usage information for this command and associated commmands
\-h, --help
.SH EXAMPLES
.TP
-Push an image with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
+Initial push of an image with id 12345678-bbbb-1234--1234567890ab to provider
ec2-us-east-1
.B aeolus-image push
\--id 12345678-bbbb-1234--1234567890ab
\--provider ec2-us-east-1
+Push a build with id 12345678-bbbb-1234--1234567890ab to provider ec2-us-east-1
+.B aeolus-image push
+\--build 12345678-bbbb-1234--1234567890ab
+\--provider ec2-us-east-1
.SH AUTHOR
Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
.SH SEE ALSO
ACK with a couple of nits inline.
Thomas
--
No trees were killed to send this message, but a large number of
electrons were terribly inconvenienced.