deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [3/3] git commit: JSON support for network_interface model
Date Fri, 26 Apr 2013 15:56:57 GMT
JSON support for network_interface model

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/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 <tomas@sedovic.cz>
Authored: Wed Apr 17 17:07:36 2013 +0200
Committer: marios <marios@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


Mime
View raw message