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: CIMI: Adds NetworkTemplates and RoutingGroup (+collections) to CIMI frontend server
Date Fri, 16 Mar 2012 13:42:53 GMT
CIMI: Adds NetworkTemplates and RoutingGroup (+collections) to CIMI frontend server


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

Branch: refs/heads/master
Commit: f81c65b4ee91d3337cb32ab6462cf0583f88ccc1
Parents: 86cb939
Author: marios <marios@redhat.com>
Authored: Fri Mar 16 15:37:46 2012 +0200
Committer: marios <marios@redhat.com>
Committed: Fri Mar 16 15:37:46 2012 +0200

----------------------------------------------------------------------
 server/lib/cimi/model.rb                           |    3 +
 server/lib/cimi/model/network_template.rb          |   10 +++
 .../lib/cimi/model/network_template_collection.rb  |   35 ++++++++
 server/lib/cimi/model/routing_group.rb             |   34 ++++++++
 server/lib/cimi/model/routing_group_collection.rb  |   34 ++++++++
 server/lib/cimi/server.rb                          |   61 +++++++++++++++
 6 files changed, 177 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f81c65b4/server/lib/cimi/model.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
index 1ecf848..60f2d99 100644
--- a/server/lib/cimi/model.rb
+++ b/server/lib/cimi/model.rb
@@ -50,3 +50,6 @@ require 'cimi/model/network_collection'
 require 'cimi/model/network_configuration'
 require 'cimi/model/network_configuration_collection'
 require 'cimi/model/network_template'
+require 'cimi/model/network_template_collection'
+require 'cimi/model/routing_group'
+require 'cimi/model/routing_group_collection'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f81c65b4/server/lib/cimi/model/network_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_template.rb b/server/lib/cimi/model/network_template.rb
index 7b6b125..ce3b990 100644
--- a/server/lib/cimi/model/network_template.rb
+++ b/server/lib/cimi/model/network_template.rb
@@ -23,4 +23,14 @@ class CIMI::Model::NetworkTemplate < CIMI::Model::Base
     scalar :rel, :href
   end
 
+  def self.find(id, context)
+    network_templates = []
+    if id==:all
+      network_templates = context.driver.network_templates(context.credentials, {:env=>context})
+    else
+      network_templates = context.driver.network_templates(context.credentials, {:env=>context,
:id=>id})
+    end
+    network_templates
+  end
+
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f81c65b4/server/lib/cimi/model/network_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_template_collection.rb b/server/lib/cimi/model/network_template_collection.rb
new file mode 100644
index 0000000..6b97b6e
--- /dev/null
+++ b/server/lib/cimi/model/network_template_collection.rb
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+class CIMI::Model::NetworkTemplateCollection < CIMI::Model::Base
+
+  act_as_root_entity :network_template
+
+  array :network_templates do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.network_templates_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} NetworkTemplateCollection",
+      :network_templates => NetworkTemplate.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f81c65b4/server/lib/cimi/model/routing_group.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/routing_group.rb b/server/lib/cimi/model/routing_group.rb
new file mode 100644
index 0000000..d26f4d7
--- /dev/null
+++ b/server/lib/cimi/model/routing_group.rb
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+class CIMI::Model::RoutingGroup < CIMI::Model::Base
+
+  array :networks do
+    scalar :href
+  end
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    if id==:all
+      context.driver.routing_groups(context.credentials, {:env=>context})
+    else
+      context.driver.routing_groups(context.credentials, {:env=>context, :id=>id})
+    end
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f81c65b4/server/lib/cimi/model/routing_group_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/routing_group_collection.rb b/server/lib/cimi/model/routing_group_collection.rb
new file mode 100644
index 0000000..1546c80
--- /dev/null
+++ b/server/lib/cimi/model/routing_group_collection.rb
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+class CIMI::Model::RoutingGroupCollection < CIMI::Model::Base
+
+  act_as_root_entity :routing_group
+
+  array :routing_groups do
+    scalar :href
+  end
+
+  def self.default(context)
+    self.new(
+      :id => context.routing_groups_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} RoutingGroupCollection",
+      :routing_groups => RoutingGroup.all_uri(context)
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f81c65b4/server/lib/cimi/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 6cd845e..06ad758 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -574,3 +574,64 @@ global_collection :network_configurations do
   end
 end
 end
+
+global_collection :network_templates do
+
+  description 'Network Template is a set of configuration values for realizing a Network.
An instance of Network Template may be used to create multiple Networks'
+
+  operation :index do
+    description 'List all Network Templates in the NetworkTemplateCollection'
+    param :CIMISelect, :string, :optional
+    control do
+      network_templates = NetworkTemplateCollection.default(self).filter_by(params[:CIMISelect])
+      respond_to do |format|
+        format.xml {network_templates.to_xml}
+        format.json {network_templates.to_json}
+      end
+    end
+  end
+
+  operation :show do
+    description 'Show a specific Network Template'
+    param :id, :string, :required
+    control do
+      network_template = NetworkTemplate.find(params[:id], self)
+      respond_to do |format|
+        format.xml {network_template.to_xml}
+        format.json {network_template.to_json}
+      end
+    end
+  end
+
+end
+
+
+global_collection :routing_groups do
+
+  description 'Routing Groups represent a collection of Networks that route to each other.
Providers shall not allow two Networks to be routable to each other unless they are explicitly
connected by being part of a common RoutingGroup.'
+
+  operation :index do
+    description 'List all RoutingGroups in the RoutingGroupsCollection'
+    param :CIMISelect, :string, :optional
+    control do
+      routing_groups = RoutingGroupCollection.default(self).filter_by(params[:CIMISelect])
+      respond_to do |format|
+        format.xml {routing_groups.to_xml}
+        format.json {routing_groups.to_json}
+      end
+    end
+  end
+
+  operation :show do
+    description 'Show a specific RoutingGroup'
+    param :id, :string, :required
+    control do
+      routing_group = RoutingGroup.find(params[:id], self)
+      respond_to do |format|
+        format.xml {routing_group.to_xml}
+        format.json {routing_group.to_json}
+      end
+    end
+  end
+
+end


Mime
View raw message