You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2013/04/26 17:56:55 UTC
[1/3] git commit: Add JSON responses to Network and Subnet models
Updated Branches:
refs/heads/master 9c094964b -> f69f3ddff
Add JSON responses to Network and Subnet models
Signed-off-by: Tomas Sedovic <to...@sedovic.cz>
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/5d13f9b6
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/5d13f9b6
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/5d13f9b6
Branch: refs/heads/master
Commit: 5d13f9b68211fc1972d9e81fa928e193923bbd2e
Parents: 9c09496
Author: Tomas Sedovic <to...@sedovic.cz>
Authored: Mon Apr 15 11:33:08 2013 +0200
Committer: marios <ma...@redhat.com>
Committed: Fri Apr 26 18:51:11 2013 +0300
----------------------------------------------------------------------
server/lib/deltacloud/models/network.rb | 16 ++++++++++++++++
server/lib/deltacloud/models/subnet.rb | 14 ++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/5d13f9b6/server/lib/deltacloud/models/network.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/network.rb b/server/lib/deltacloud/models/network.rb
index d46ac27..121ac24 100644
--- a/server/lib/deltacloud/models/network.rb
+++ b/server/lib/deltacloud/models/network.rb
@@ -26,5 +26,21 @@ class Network < BaseModel
self.subnets = [] unless self.subnets
end
+ def to_hash(context)
+ {
+ :id => id,
+ :name => name,
+ :href => context.network_url(id),
+ :state => state,
+ :address_blocks => address_blocks,
+ :subnets => subnets.map do |s|
+ {
+ :id => s,
+ :href => context.subnet_url(s),
+ }
+ end,
+ }
+ end
+
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/5d13f9b6/server/lib/deltacloud/models/subnet.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/subnet.rb b/server/lib/deltacloud/models/subnet.rb
index d91a7a9..0a05804 100644
--- a/server/lib/deltacloud/models/subnet.rb
+++ b/server/lib/deltacloud/models/subnet.rb
@@ -23,5 +23,19 @@ class Subnet < BaseModel
attr_accessor :state
attr_accessor :type
+ def to_hash(context)
+ {
+ :id => id,
+ :name => name,
+ :href => context.subnet_url(id),
+ :state => state,
+ :address_block => address_block,
+ :network => {
+ :id => network,
+ :href => context.network_url(network),
+ },
+ }
+ end
+
end
end
[3/3] git commit: JSON support for network_interface model
Posted by ma...@apache.org.
JSON support for network_interface model
Signed-off-by: Tomas Sedovic <to...@sedovic.cz>
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/f69f3ddf
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/f69f3ddf
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/f69f3ddf
Branch: refs/heads/master
Commit: f69f3ddffdc471036b75b0223ec8ed268663753f
Parents: 211962b
Author: Tomas Sedovic <to...@sedovic.cz>
Authored: Wed Apr 17 17:07:36 2013 +0200
Committer: marios <ma...@redhat.com>
Committed: Fri Apr 26 18:51:42 2013 +0300
----------------------------------------------------------------------
.../deltacloud/collections/network_interfaces.rb | 2 +-
server/lib/deltacloud/models/network_interface.rb | 17 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f69f3ddf/server/lib/deltacloud/collections/network_interfaces.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/network_interfaces.rb b/server/lib/deltacloud/collections/network_interfaces.rb
index 5a9c2a2..17bc939 100644
--- a/server/lib/deltacloud/collections/network_interfaces.rb
+++ b/server/lib/deltacloud/collections/network_interfaces.rb
@@ -41,7 +41,7 @@ module Deltacloud::Collections
respond_to do |format|
format.xml { haml :"network_interfaces/show", :locals => {:network_interface=>@network_interface, :subnets=>driver.respond_to?(:subnets)}}
format.html { haml :"network_interfaces/show", :locals => {:network_interface=>@network_interface, :subnets=>driver.respond_to?(:subnets)}}
- format.json { xml_to_json("network_interfaces/show")}
+ format.json { JSON::dump(:network_interface => @network_interface.to_hash(self))}
end
end
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f69f3ddf/server/lib/deltacloud/models/network_interface.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/network_interface.rb b/server/lib/deltacloud/models/network_interface.rb
index 41d9816..68fee6a 100644
--- a/server/lib/deltacloud/models/network_interface.rb
+++ b/server/lib/deltacloud/models/network_interface.rb
@@ -20,5 +20,22 @@ class NetworkInterface < BaseModel
attr_accessor :network
attr_accessor :ip_address
+ def to_hash(context)
+ {
+ :id => id,
+ :name => name,
+ :href => context.network_interface_url(id),
+ :network => {
+ :id => network,
+ :href => context.network_url(network),
+ },
+ :instance => {
+ :id => instance,
+ :href => context.instance_url(instance),
+ },
+ :ip_address => ip_address,
+ }
+ end
+
end
end
[2/3] git commit: Fix Network and Subnet create routes for JSON
Posted by ma...@apache.org.
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 <to...@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 <to...@sedovic.cz>
Authored: Tue Apr 16 16:51:55 2013 +0200
Committer: marios <ma...@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