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 2012/09/18 15:37:28 UTC
[5/7] git commit: CIMI: Adds NetworkPortConfiguration (used to be
VSPConfiguration)
CIMI: Adds NetworkPortConfiguration (used to be VSPConfiguration)
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/4374c9ec
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/4374c9ec
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/4374c9ec
Branch: refs/heads/master
Commit: 4374c9ec64b59b3de46950d608d4b98ba0991fde
Parents: 85cef26
Author: marios <ma...@redhat.com>
Authored: Fri Sep 14 18:34:14 2012 +0300
Committer: marios <ma...@redhat.com>
Committed: Tue Sep 18 16:34:36 2012 +0300
----------------------------------------------------------------------
.../collections/network_port_configurations.rb | 49 +++++++++++++++
.../lib/cimi/models/network_port_configuration.rb | 34 ++++++++++
.../network_port_configuration_collection.rb | 35 ++++++++++
.../network_port_configuration/portconfig1.json | 11 +++
.../network_port_configuration/portconfig2.json | 11 +++
5 files changed, 140 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4374c9ec/server/lib/cimi/collections/network_port_configurations.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/network_port_configurations.rb b/server/lib/cimi/collections/network_port_configurations.rb
new file mode 100644
index 0000000..8a1c17d
--- /dev/null
+++ b/server/lib/cimi/collections/network_port_configurations.rb
@@ -0,0 +1,49 @@
+# 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 NetworkPortConfigurations < Base
+
+ set :capability, lambda { |m| driver.respond_to? m }
+
+ collection :network_port_configurations do
+
+ operation :index, :with_capability => :network_port_configurations do
+ description 'List all NetworkPortConfigurations in the NetworkPortConfigurationCollection'
+ param :CIMISelect, :string, :optional
+ control do
+ net_port_configs = NetworkPortConfigurationCollection.default(self).filter_by(params[:CIMISelect])
+ respond_to do |format|
+ format.xml {net_port_configs.to_xml}
+ format.json {net_port_configs.to_json}
+ end
+ end
+ end
+
+ operation :show, :with_capability => :network_port_configurations do
+ description 'Show a specific NetworkPortConfiguration'
+ control do
+ net_port_config = NetworkPortConfiguration.find(params[:id], self)
+ respond_to do |format|
+ format.xml {net_port_config.to_xml}
+ format.json {net_port_config.to_json}
+ end
+ end
+ end
+
+ end
+
+ end
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4374c9ec/server/lib/cimi/models/network_port_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port_configuration.rb b/server/lib/cimi/models/network_port_configuration.rb
new file mode 100644
index 0000000..88f431a
--- /dev/null
+++ b/server/lib/cimi/models/network_port_configuration.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::NetworkPortConfiguration < CIMI::Model::Base
+
+ text :class_of_service
+
+ text :port_type
+
+ array :operations do
+ scalar :rel, :href
+ end
+
+ def self.find(id, context)
+ if id==:all
+ context.driver.network_port_configurations(context.credentials, {:env=>context})
+ else
+ context.driver.network_port_configurations(context.credentials, {:env=>context, :id=>id})
+ end
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4374c9ec/server/lib/cimi/models/network_port_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/network_port_configuration_collection.rb b/server/lib/cimi/models/network_port_configuration_collection.rb
new file mode 100644
index 0000000..eb34902
--- /dev/null
+++ b/server/lib/cimi/models/network_port_configuration_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::NetworkPortConfigurationCollection < CIMI::Model::Base
+
+ act_as_root_entity :network_port_configuration
+
+ text :count
+
+ self << CIMI::Model::NetworkPortConfiguration
+
+ def self.default(context)
+ network_port_configurations = CIMI::Model::NetworkPortConfiguration.all(context)
+ self.new(
+ :id => context.network_port_configurations_url,
+ :name => 'default',
+ :created => Time.now,
+ :description => "#{context.driver.name.capitalize} NetworkPortConfigurationCollection",
+ :count => network_port_configurations.size,
+ :network_port_configurations => network_port_configurations
+ )
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4374c9ec/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig1.json b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig1.json
new file mode 100644
index 0000000..b555b4d
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig1.json
@@ -0,0 +1,11 @@
+{ "id": "http://cimi.example.org/network_port_configurations/portconfig1",
+ "name": "portconfig1",
+ "description": "a mock network_port configuration",
+ "created": "Fri Mar 16 18:39:41 EET 2012",
+ "portType": "ACCESS",
+ "classOfService": "GOLD",
+ "operations": [
+ { "rel": "edit", "href": "http://cimi.example.org/network_port_configurations/portconfig1" },
+ { "rel": "delete", "href": "http://cimi.example.org/network_port_configurations/portconfig1" }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4374c9ec/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig2.json b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig2.json
new file mode 100644
index 0000000..e28cd8f
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig2.json
@@ -0,0 +1,11 @@
+{ "id": "http://cimi.example.org/network_port_configurations/portconfig2",
+ "name": "portconfig2",
+ "description": "a mock network_port configuration",
+ "created": "Fri Mar 16 18:41:41 EET 2012",
+ "portType": "ACCESS",
+ "classOfService": "SILVER",
+ "operations": [
+ { "rel": "edit", "href": "http://cimi.example.org/network_port_configurations/portconfig2" },
+ { "rel": "delete", "href": "http://cimi.example.org/network_port_configurations/portconfig2" }
+ ]
+}