From: marios <[email protected]>
Signed-off-by: marios <[email protected]> --- .../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(+) create mode 100644 server/lib/cimi/collections/network_port_configurations.rb create mode 100644 server/lib/cimi/models/network_port_configuration.rb create mode 100644 server/lib/cimi/models/network_port_configuration_collection.rb create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig1.json create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/network_port_configuration/portconfig2.json 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 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 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 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" } + ] +} 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" } + ] +} -- 1.7.11.4
