You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2012/01/06 17:41:58 UTC
[PATCH 3/3] Adds new CIMI::Network models and routes for Sinatra
From: marios <ma...@redhat.com>
Signed-off-by: marios <ma...@redhat.com>
---
server/lib/cimi/model.rb | 5 +++
server/lib/cimi/server.rb | 80 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
index 4fed4e8..1ecf848 100644
--- a/server/lib/cimi/model.rb
+++ b/server/lib/cimi/model.rb
@@ -45,3 +45,8 @@ require 'cimi/model/volume_image_collection'
require 'cimi/model/volume_template_collection'
require 'cimi/model/entity_metadata'
require 'cimi/model/entity_metadata_collection'
+require 'cimi/model/network'
+require 'cimi/model/network_collection'
+require 'cimi/model/network_configuration'
+require 'cimi/model/network_configuration_collection'
+require 'cimi/model/network_template'
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 0829f1b..2a90c0e 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -492,4 +492,84 @@ global_collection :entity_metadata do
end
+global_collection :networks do
+ description 'A Network represents an abstraction of a layer 2 broadcast domain'
+
+ operation :index do
+ description "List all Networks"
+ param :CIMISelect, :string, :optional
+ control do
+ networks = NetworkCollection.default(self).filter_by(params[:CIMISelect])
+ respond_to do |format|
+ format.xml { networks.to_xml }
+ format.json { networks.to_json }
+ end
+ end
+ end
+
+ operation :show do
+ description "Show a specific Network"
+ param :id, :string, :required
+ control do
+ network = Network.find(params[:id], self)
+ respond_to do |format|
+ format.xml { network.to_xml }
+ format.json { network.to_json }
+ end
+ end
+ end
+
+ operation :create do
+ description "Create a new Network"
+ control do
+ if request.content_type.end_with("+json")
+ network = Network.create_from_json(request.body.read, self)
+ else
+ network = Network.create_from_xml(request.body.read, self)
+ end
+ respond_to do |format|
+ format.xml { network.to_xml}
+ format.json { network.to_json }
+ end
+ end
+ end
+
+ operation :destroy do
+ description "Delete a specified Network"
+ param :id, :string, :required
+ control do
+ Network.delete!(params[:id], self)
+ no_content_with_status(200)
+ end
+ end
+
+end
+
+global_collection :network_configurations do
+ description 'Network Configurations contain the set of configuration values representing the information needed to create a Network with certain characteristics'
+
+ operation :index do
+ description 'List all NetworkConfigurations'
+ param :CIMISelect, :string, :optional
+ control do
+ network_configurations = NetworkConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+ respond_to do |format|
+ format.xml { network_configurations.to_xml }
+ format.json { network_configurations.to_json }
+ end
+ end
+ end
+
+ operation :show do
+ description 'Show a specific NetworkConfiguration'
+ param :id, :string, :required
+ control do
+ network_config = NetworkConfiguration.find(params[:id], self)
+ respond_to do
+ format.xml { network_config.to_xml }
+ format.json { network_config.to_json }
+ end
+ end
+ end
+end
end
--
1.7.6.5