From e0acf333e991de15e42d43ab1627021d5738add1 Mon Sep 17 00:00:00 2001 From: Sean Handley Date: Tue, 19 Jul 2016 14:28:45 +0100 Subject: [PATCH] Fixing three mistakes, plus missing durability steps. 1) 'Fog#wait_for' hangs forever. Using #wait_for directly on the instance model is the right way to go. 2) Fixed incorrect variable name. This was causing the IP assignment to fail. 3) Typo in durability direcories. 4) Added steps for durability Steps 10, 11, and 13. Change-Id: Iffac65777e06fc36c5c815a7eef6c4e8523000a1 --- firstapp/samples/fog/block_storage.rb | 2 +- firstapp/samples/fog/durability.rb | 19 +++++++++++-------- firstapp/samples/fog/getting_started.rb | 4 ++-- firstapp/samples/fog/introduction.rb | 8 ++++---- firstapp/samples/fog/scaling_out.rb | 6 +++--- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/firstapp/samples/fog/block_storage.rb b/firstapp/samples/fog/block_storage.rb index bce263931..612d51bd3 100755 --- a/firstapp/samples/fog/block_storage.rb +++ b/firstapp/samples/fog/block_storage.rb @@ -38,7 +38,7 @@ instance = conn.servers.create name: "app-database", key_name: key_pair.name, security_groups: db_group -Fog.wait_for { instance.ready? } +instance.wait_for { ready? } # step-5 volume = conn.volumes.get "755ab026-b5f2-4f53-b34a-6d082fb36689" diff --git a/firstapp/samples/fog/durability.rb b/firstapp/samples/fog/durability.rb index f21be2048..8edaa8960 100755 --- a/firstapp/samples/fog/durability.rb +++ b/firstapp/samples/fog/durability.rb @@ -28,7 +28,7 @@ p swift.directories.all # step-4 file_path = "goat.jpg" object_name = "an amazing goat" -container = swift.direcories.get container_name +container = swift.directories.get container_name object = container.files.create body: File.read(File.expand_path(file_path)), key: object_name @@ -48,6 +48,8 @@ object.destroy p container.files.all # step-10 +container_name = 'fractals' +container = swift.directories.get container_name # step-11 endpoint = "http://IP_API_1" @@ -56,8 +58,8 @@ uri.query = URI.encode_www_form results_per_page: -1 data = JSON.parse(Net::HTTP.get_response(uri).body) data["objects"].each do |fractal| - uri = URI("#{endpoint}/fractal/#{fractal["uuid"]}") - #TBC + body = open("#{endpoint}/fractal/#{fractal["uuid"]}") {|f| f.read} + object = container.files.create body: body, key: fractal["uuid"] end p container.files.all @@ -70,13 +72,14 @@ container.destroy # step-13 object_name = "backup_goat.jpg" +file_path = "backup_goat.jpg" extra = { - meta_data: { - description: "a funny goat", - created: "2015-06-02" - } + description: "a funny goat", + created: "2015-06-02" } -#TBC +object = container.files.create body: File.read(File.expand_path(file_path)), + key: object_name, + metadata: extra # step-14 #TBC diff --git a/firstapp/samples/fog/getting_started.rb b/firstapp/samples/fog/getting_started.rb index d4b9b7fd7..5833bd167 100755 --- a/firstapp/samples/fog/getting_started.rb +++ b/firstapp/samples/fog/getting_started.rb @@ -33,7 +33,7 @@ testing_instance = conn.servers.create name: instance_name, image_ref: image.id, flavor_ref: flavor.id -Fog.wait_for {testing_instance.ready?} +testing_instance.wait_for { ready? } p testing_instance @@ -107,7 +107,7 @@ else user_data: user_data, security_groups: all_in_one_security_group - Fog.wait_for {testing_instance.ready?} + testing_instance.wait_for { ready? } end p conn.servers.summary diff --git a/firstapp/samples/fog/introduction.rb b/firstapp/samples/fog/introduction.rb index e365edd52..ad39e67c2 100644 --- a/firstapp/samples/fog/introduction.rb +++ b/firstapp/samples/fog/introduction.rb @@ -13,7 +13,7 @@ testing_instance = conn.servers.create name: instance_name, user_data: user_data, security_groups: all_in_one_security_group -Fog.wait_for {testing_instance.ready?} +testing_instance.wait_for { ready? } # step-2 user_data = <