[PATCH aeolus-cli] BZ#753917 Added targets to output of build

mtaylor at redhat.com mtaylor at redhat.com
Tue Dec 13 16:17:59 UTC 2011


From: Martyn Taylor <mtaylor at redhat.com>

---
 lib/aeolus_cli/command/build_command.rb            |   19 ++++++--
 spec/command/build_command_spec.rb                 |   34 ++++++++++++---
 spec/vcr/cassettes/command/build_command/build.yml |   43 ++++++++++---------
 .../command/build_command/multiple_build.yml       |   21 ++++++----
 4 files changed, 77 insertions(+), 40 deletions(-)

diff --git a/lib/aeolus_cli/command/build_command.rb b/lib/aeolus_cli/command/build_command.rb
index 0d9a819..e183891 100644
--- a/lib/aeolus_cli/command/build_command.rb
+++ b/lib/aeolus_cli/command/build_command.rb
@@ -34,14 +34,23 @@ module Aeolus
           begin
             template = read_template
             validate_xml_schema(template)
-
             image = Aeolus::CLI::Image.new({:targets => @options[:target] * ",", :tdl => template})
             image.save!
-            puts "Image: " + image.id
-            puts "Build: " + image.build.id
-            Array(image.build.target_images.target_image).each do |target_image|
-              puts "Target Image: " + target_image.id.to_s + "\t :Status " + target_image.status
+
+            headers = ActiveSupport::OrderedHash.new
+            headers[:id] = "Target Image"
+            headers[:target] = "Target"
+            headers[:status] = "Status"
+            headers[:image] = "Image"
+            headers[:build] = "Build"
+
+            ti_array = Array(image.build.target_images.target_image)
+            ti_array.each do |target_image|
+              target_image.image = image.id
+              target_image.build = image.build.id
             end
+
+            print_collection(ti_array, headers)
             quit(0)
           rescue => e
             handle_exception(e)
diff --git a/spec/command/build_command_spec.rb b/spec/command/build_command_spec.rb
index 2a99553..645f0ff 100644
--- a/spec/command/build_command_spec.rb
+++ b/spec/command/build_command_spec.rb
@@ -31,9 +31,18 @@ module Aeolus
             rescue SystemExit => e
               e.status.should == 0
             end
-            $stdout.string.should include("Image:")
-            $stdout.string.should include("Target Image:")
-            $stdout.string.should include("Build:")
+            $stdout.string.should include("Image")
+            $stdout.string.should include("Target Image")
+            $stdout.string.should include("Build")
+            $stdout.string.should include("Target")
+            $stdout.string.should include("Status")
+
+            $stdout.string.should include("6affc8f5-a560-4b7e-88da-2e993cf9ebce")
+            $stdout.string.should include("e0412885-28a6-4c3f-898a-886680ffadd0")
+            $stdout.string.should include("0079b860-e601-4705-8729-d7624f160786")
+            $stdout.string.should include("COMPLETED")
+            $stdout.string.should include("ec2")
+
           end
         end
 
@@ -46,10 +55,21 @@ module Aeolus
             rescue SystemExit => e
               e.status.should == 0
             end
-            $stdout.string.should include("Image: 38d8b8e4-21f8-439b-9fc8-e6f8816682cb")
-            $stdout.string.should include("Build: af8016a8-2ee6-409c-8752-7c74c60a174e")
-            $stdout.string.should include("Target Image: 30a11f4a-e568-4c2d-a9b6-7c2c80a7ed3f")
-            $stdout.string.should include("Target Image: c27db6d9-6f7c-413e-9103-70e8af0daf32")
+            $stdout.string.should include("Image")
+            $stdout.string.should include("Build")
+            $stdout.string.should include("Target Image")
+            $stdout.string.should include("Target")
+            $stdout.string.should include("Status")
+
+            $stdout.string.should include("48b91462-9715-4a06-be21-4090972a7f5f")
+            $stdout.string.should include("59643fd4-12d2-4e67-8394-2183341d9ec1")
+            $stdout.string.should include("e33e3358-663a-4e81-9259-cff0ce6aa3b1")
+            $stdout.string.should include("ec2")
+            $stdout.string.should include("New")
+
+            $stdout.string.should include("c74124e7-8777-4ec1-beea-d896bec80b22")
+            $stdout.string.should include("mock")
+            $stdout.string.should include("COMPLETED")
           end
         end
 
diff --git a/spec/vcr/cassettes/command/build_command/build.yml b/spec/vcr/cassettes/command/build_command/build.yml
index bccd152..e495d96 100644
--- a/spec/vcr/cassettes/command/build_command/build.yml
+++ b/spec/vcr/cassettes/command/build_command/build.yml
@@ -2,7 +2,7 @@
 - !ruby/struct:VCR::HTTPInteraction
   request: !ruby/struct:VCR::Request
     method: :post
-    uri: https://admin:password@localhost/conductor/api/images.xml
+    uri: https://admin:password@localhost:443/conductor/api/images.xml
     body: |
       <?xml version="1.0" encoding="UTF-8"?>
       <image>
@@ -29,6 +29,8 @@
       </image>
 
     headers:
+      accept-language:
+      - en
       content-type:
       - application/xml
   response: !ruby/struct:VCR::Response
@@ -37,34 +39,35 @@
       message: OK
     headers:
       x-ua-compatible:
-      - IE=Edge
+      - IE=Edge,chrome=1
       etag:
-      - "\"c65786cb658ae9dcb74afacdfa17d01a\""
+      - "\"1cc9b56f5dd748a8cfa4632c4f5b54b3\""
       content-type:
       - application/xml; charset=utf-8
       server:
-      - WEBrick/1.3.1 (Ruby/1.8.7/2011-06-30)
+      - thin 1.2.11 codename Bat-Shit Crazy
       date:
-      - Thu, 20 Oct 2011 16:30:30 GMT
+      - Tue, 13 Dec 2011 15:25:24 GMT
       x-runtime:
-      - "0.805774"
-      content-length:
-      - "574"
+      - "2.639965"
       set-cookie:
-      - _session_id=BAh7CCIPc2Vzc2lvbl9pZCIlMTA3ZjgzMWQ0ZmQ0NjRkNWEwZWJhM2MyN2ZlN2RkNGYiGXdhcmRlbi51c2VyLnVzZXIua2V5aQYiEGJyZWFkY3J1bWJzWwA%3D--034e267cd5514827f2aaa2cd4cc99777ee5e02e9; path=/; HttpOnly
+      - _session_id=BAh7CCIPc2Vzc2lvbl9pZCIlMWJjMzE4Zjc3MThiN2I4ZDc1OTg4MDE4ZmU3YmZmYzkiGXdhcmRlbi51c2VyLnVzZXIua2V5aQYiEGJyZWFkY3J1bWJzWwA%3D--29e37a191161ffc7c3d145e46e63c9c72179b1e8; path=/; HttpOnly
       cache-control:
       - max-age=0, private, must-revalidate
-    body: |
-      <image href='http://localhost:3000/api/images/66941cc3-7bc7-4d67-abfb-f4473fdc1243' id='66941cc3-7bc7-4d67-abfb-f4473fdc1243'>
-        <build href='http://localhost:3000/api/builds/247fc85c-7eb9-4756-bb7a-c06d19f2da47' id='247fc85c-7eb9-4756-bb7a-c06d19f2da47'>
-          <target_images>
-            <target_image href='http://localhost:3000/api/target_images/7673bd21-3517-48c4-a282-9ea78f52573d' id='7673bd21-3517-48c4-a282-9ea78f52573d'>
-              <status>COMPLETED</status>
-              <provider_images>
-              </provider_images>
-            </target_image>
-          </target_images>
-        </build>
+      transfer-encoding:
+      - chunked
+    body: |+
+      <image href='https://localhost/conductor/api/images/6affc8f5-a560-4b7e-88da-2e993cf9ebce' id='6affc8f5-a560-4b7e-88da-2e993cf9ebce'>
+      <build href='https://localhost/conductor/api/builds/e0412885-28a6-4c3f-898a-886680ffadd0' id='e0412885-28a6-4c3f-898a-886680ffadd0'>
+      <target_images>
+      <target_image href='https://localhost/conductor/api/target_images/0079b860-e601-4705-8729-d7624f160786' id='0079b860-e601-4705-8729-d7624f160786'>
+      <status>COMPLETED</status>
+      <target>ec2</target>
+      <provider_images>
+      </provider_images>
+      </target_image>
+      </target_images>
+      </build>
       </image>
 
     http_version: "1.1"
\ No newline at end of file
diff --git a/spec/vcr/cassettes/command/build_command/multiple_build.yml b/spec/vcr/cassettes/command/build_command/multiple_build.yml
index 101174c..bda97e0 100644
--- a/spec/vcr/cassettes/command/build_command/multiple_build.yml
+++ b/spec/vcr/cassettes/command/build_command/multiple_build.yml
@@ -29,6 +29,8 @@
       </image>
 
     headers:
+      accept-language:
+      - en
       content-type:
       - application/xml
   response: !ruby/struct:VCR::Response
@@ -39,36 +41,39 @@
       x-ua-compatible:
       - IE=Edge,chrome=1
       etag:
-      - "\"7c99627727857e6618d365853351a8d5\""
+      - "\"6f874fe42c203c470c4f7ac3038f5f09\""
       content-type:
       - application/xml; charset=utf-8
       server:
       - thin 1.2.11 codename Bat-Shit Crazy
       date:
-      - Wed, 02 Nov 2011 14:56:05 GMT
+      - Tue, 13 Dec 2011 15:25:27 GMT
       x-runtime:
-      - "0.335635"
+      - "0.340243"
       set-cookie:
-      - _session_id=BAh7CCIPc2Vzc2lvbl9pZCIlZDljNTgyMzFkNzIwMDVmMTA3MmM0ZDYwZDBjYTg0ZTAiGXdhcmRlbi51c2VyLnVzZXIua2V5aQYiEGJyZWFkY3J1bWJzWwA%3D--01b1228fe550752e0c9ec1a3ec0534083af93561; path=/; HttpOnly
+      - _session_id=BAh7CCIPc2Vzc2lvbl9pZCIlNTdkMjFmZmIzMGE5MWJmMGQ4YzhlMzhkNmUxYzA3NjEiGXdhcmRlbi51c2VyLnVzZXIua2V5aQYiEGJyZWFkY3J1bWJzWwA%3D--8d0f7e959e2acfe54e46c752ed3d75743aca3c82; path=/; HttpOnly
       cache-control:
       - max-age=0, private, must-revalidate
       transfer-encoding:
       - chunked
     body: |+
-      <image href='https://localhost/conductor/api/images/38d8b8e4-21f8-439b-9fc8-e6f8816682cb' id='38d8b8e4-21f8-439b-9fc8-e6f8816682cb'>
-      <build href='https://localhost/conductor/api/builds/af8016a8-2ee6-409c-8752-7c74c60a174e' id='af8016a8-2ee6-409c-8752-7c74c60a174e'>
+      <image href='https://localhost/conductor/api/images/48b91462-9715-4a06-be21-4090972a7f5f' id='48b91462-9715-4a06-be21-4090972a7f5f'>
+      <build href='https://localhost/conductor/api/builds/59643fd4-12d2-4e67-8394-2183341d9ec1' id='59643fd4-12d2-4e67-8394-2183341d9ec1'>
       <target_images>
-      <target_image href='https://localhost/conductor/api/target_images/c27db6d9-6f7c-413e-9103-70e8af0daf32' id='c27db6d9-6f7c-413e-9103-70e8af0daf32'>
+      <target_image href='https://localhost/conductor/api/target_images/e33e3358-663a-4e81-9259-cff0ce6aa3b1' id='e33e3358-663a-4e81-9259-cff0ce6aa3b1'>
       <status>New</status>
+      <target>ec2</target>
       <provider_images>
       </provider_images>
       </target_image>
-      <target_image href='https://localhost/conductor/api/target_images/30a11f4a-e568-4c2d-a9b6-7c2c80a7ed3f' id='30a11f4a-e568-4c2d-a9b6-7c2c80a7ed3f'>
+      <target_image href='https://localhost/conductor/api/target_images/c74124e7-8777-4ec1-beea-d896bec80b22' id='c74124e7-8777-4ec1-beea-d896bec80b22'>
       <status>COMPLETED</status>
+      <target>mock</target>
       <provider_images>
       </provider_images>
       </target_image>
       </target_images>
       </build>
       </image>
+
     http_version: "1.1"
\ No newline at end of file
-- 
1.7.6.4




More information about the aeolus-devel mailing list