deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [2/3] git commit: Fix Network and Subnet create routes for JSON
Date Fri, 26 Apr 2013 15:56:56 GMT
Fix Network and Subnet create routes for JSON

Creating a network or subnet whilst using "Accept: application/json"
resulted in an exception because of the missing `xml_to_json` method in
the routes for JSON responses.

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/211962b6
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/211962b6
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/211962b6

Branch: refs/heads/master
Commit: 211962b62e13ad9e5e5d6fc084dd1c23ca4041ba
Parents: 5d13f9b
Author: Tomas Sedovic <tomas@sedovic.cz>
Authored: Tue Apr 16 16:51:55 2013 +0200
Committer: marios <marios@redhat.com>
Committed: Fri Apr 26 18:51:29 2013 +0300

----------------------------------------------------------------------
 server/lib/deltacloud/collections/networks.rb |    4 ++--
 server/lib/deltacloud/collections/subnets.rb  |    9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/211962b6/server/lib/deltacloud/collections/networks.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/networks.rb b/server/lib/deltacloud/collections/networks.rb
index 34c7fad..83b51fe 100644
--- a/server/lib/deltacloud/collections/networks.rb
+++ b/server/lib/deltacloud/collections/networks.rb
@@ -36,11 +36,11 @@ module Deltacloud::Collections
         param :address_block, :string, :optional
         param :name,          :string, :optional
         control do
-          @network = driver.create_network(credentials, { :address_block => params[:address_block]})
+          @network = driver.create_network(credentials, params)
           respond_to do |format|
             format.xml  { haml :"networks/show" }
             format.html { haml :"networks/show" }
-            format.json { xml_to_json("networks/show")}
+            format.json { JSON::dump(:network => @network.to_hash(self))}
           end
         end
       end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/211962b6/server/lib/deltacloud/collections/subnets.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/subnets.rb b/server/lib/deltacloud/collections/subnets.rb
index 9d5fd74..ad0d112 100644
--- a/server/lib/deltacloud/collections/subnets.rb
+++ b/server/lib/deltacloud/collections/subnets.rb
@@ -35,14 +35,15 @@ module Deltacloud::Collections
       standard_index_operation
 
       operation :create, :with_capability => :create_subnet do
-        param :network_id, :string, :required
-        param :address_block,  :string,  :required
+        param :network_id,     :string, :required
+        param :address_block,  :string, :required
+        param :name,           :string, :optional
         control do
-          @subnet = driver.create_subnet(credentials, { :network_id => params[:network_id],
:address_block => params[:address_block]})
+          @subnet = driver.create_subnet(credentials, params)
           respond_to do |format|
             format.xml  { haml :"subnets/show"}
             format.html { haml :"subnets/show" }
-            format.json { xml_to_json("subnets/show")}
+            format.json { JSON::dump(:subnet => @subnet.to_hash(self))}
           end
         end
       end


Mime
View raw message