deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [1/7] git commit: CIMI: Adds NetworkPortTemplate (used to be VSPTemplate)
Date Tue, 18 Sep 2012 13:37:28 GMT
Updated Branches:
  refs/heads/master eaca25055 -> 80b7ac4b0


CIMI: Adds NetworkPortTemplate (used to be VSPTemplate)


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

Branch: refs/heads/master
Commit: 2054a472ee658522fc02843df7508a84c3784acc
Parents: be4c327
Author: marios <marios@redhat.com>
Authored: Fri Sep 14 18:35:36 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Tue Sep 18 16:34:36 2012 +0300

----------------------------------------------------------------------
 .../lib/cimi/collections/network_port_templates.rb |   51 +++++++++++++++
 server/lib/cimi/models/network_port_template.rb    |   34 ++++++++++
 .../models/network_port_template_collection.rb     |   37 +++++++++++
 .../data/cimi/network_port_template/template1.json |   10 +++
 .../data/cimi/network_port_template/template2.json |   10 +++
 5 files changed, 142 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2054a472/server/lib/cimi/collections/network_port_templates.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_port_templates.rb b/server/lib/cimi/collections/network_port_templates.rb
new file mode 100644
index 0000000..1995e56
--- /dev/null
+++ b/server/lib/cimi/collections/network_port_templates.rb
@@ -0,0 +1,51 @@
+# 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.
+
+module CIMI::Collections
+  class NetworkPortTemplates < Base
+
+    set :capability, lambda { |m| driver.respond_to? m }
+
+    collection :network_port_templates do
+
+      description 'The NetworkPort Template is a set of Configuration values for realizing
a NetworkPort. A NetworkPort Template may be used to create multiple NetworkPorts'
+
+      operation :index, :with_capability => :network_port_templates do
+        description 'List all NetworkPortTemplates in the NetworkPortTemplateCollection'
+        param :CIMISelect, :string, :optional
+        control do
+          network_port_templates = NetworkPortTemplateCollection.default(self).filter_by(params[:CIMISelect])
+          respond_to do |format|
+            format.xml {network_port_templates.to_xml}
+            format.json {network_port_templates.to_json}
+          end
+        end
+      end
+
+      operation :show, :with_capability => :network_port_templates do
+        description 'Show a specific NetworkPortTemplate'
+        control do
+          network_port_template = NetworkPortTemplate.find(params[:id], self)
+          respond_to do |format|
+            format.xml {network_port_template.to_xml}
+            format.json {network_port_template.to_json}
+          end
+        end
+      end
+
+    end
+
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2054a472/server/lib/cimi/models/network_port_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port_template.rb b/server/lib/cimi/models/network_port_template.rb
new file mode 100644
index 0000000..8fb7ef1
--- /dev/null
+++ b/server/lib/cimi/models/network_port_template.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::NetworkPortTemplate < CIMI::Model::Base
+
+  href :network
+
+  href :network_port_config
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+  def self.find(id, context)
+    if id==:all
+      context.driver.network_port_templates(context.credentials, {:env=>context})
+    else
+      context.driver.network_port_templates(context.credentials, {:env=>context, :id=>id})
+    end
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2054a472/server/lib/cimi/models/network_port_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port_template_collection.rb b/server/lib/cimi/models/network_port_template_collection.rb
new file mode 100644
index 0000000..782af0d
--- /dev/null
+++ b/server/lib/cimi/models/network_port_template_collection.rb
@@ -0,0 +1,37 @@
+# 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::NetworkPortTemplateCollection < CIMI::Model::Base
+
+  CIMI::Model.register_as_root_entity! "NetworkPortTemplates"
+
+  text :count
+
+  #add array of network_port_templates:
+  self << CIMI::Model::NetworkPortTemplate
+
+  def self.default(context)
+    network_port_templates = CIMI::Model::NetworkPortTemplate.all(context)
+    self.new(
+      :id => context.network_port_templates_url,
+      :name => 'default',
+      :created => Time.now,
+      :description => "#{context.driver.name.capitalize} NetworkPortTemplateCollection",
+      :count => network_port_templates.size,
+      :network_port_templates => network_port_templates
+    )
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2054a472/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template1.json
b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template1.json
new file mode 100644
index 0000000..3c81787
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template1.json
@@ -0,0 +1,10 @@
+{ "id": "http://cimi.example.org/network_port_templates/template1",
+  "name": "template1",
+  "description": "A mock NetworkPortTemplate",
+  "created": "Fri Mar 16 19:26:41 EET 2012",
+  "network": { "href": "http://cimi.example.org/networks/network1"},
+  "networkPortConfig": { "href": "http://cimi.example.org/network_port_configurations/portconfig1"},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/network_port_templates/template1" },
+    { "rel": "delete", "href": "http://cimi.example.org/network_port_templates/template1"
}]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/2054a472/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template2.json
b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template2.json
new file mode 100644
index 0000000..99386a7
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_template/template2.json
@@ -0,0 +1,10 @@
+{ "id": "http://cimi.example.org/network_port_templates/template2",
+  "name": "template2",
+  "description": "A mock NetworkPortTemplate",
+  "created": "Fri Mar 16 19:26:41 EET 2012",
+  "network": { "href": "http://cimi.example.org/networks/network2"},
+  "networkPortConfig": { "href": "http://cimi.example.org/network_port_configurations/portconfig2"},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/network_port_templates/template2" },
+    { "rel": "delete", "href": "http://cimi.example.org/network_port_templates/template2"
}]
+}


Mime
View raw message