From: marios <[email protected]>
Signed-off-by: marios <[email protected]> --- server/lib/cimi/model.rb | 4 + server/lib/cimi/model/address.rb | 56 ++++++++++++++++++ server/lib/cimi/model/address_collection.rb | 34 +++++++++++ server/lib/cimi/model/address_template.rb | 54 +++++++++++++++++ .../lib/cimi/model/address_template_collection.rb | 34 +++++++++++ server/lib/cimi/server.rb | 61 ++++++++++++++++++++ 6 files changed, 243 insertions(+), 0 deletions(-) create mode 100644 server/lib/cimi/model/address.rb create mode 100644 server/lib/cimi/model/address_collection.rb create mode 100644 server/lib/cimi/model/address_template.rb create mode 100644 server/lib/cimi/model/address_template_collection.rb diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb index 0befe31..fa3c771 100644 --- a/server/lib/cimi/model.rb +++ b/server/lib/cimi/model.rb @@ -61,3 +61,7 @@ require 'cimi/model/vsp_configuration' require 'cimi/model/vsp_configuration_collection' require 'cimi/model/vsp_template' require 'cimi/model/vsp_template_collection' +require 'cimi/model/address' +require 'cimi/model/address_collection' +require 'cimi/model/address_template' +require 'cimi/model/address_template_collection' diff --git a/server/lib/cimi/model/address.rb b/server/lib/cimi/model/address.rb new file mode 100644 index 0000000..c16b0c6 --- /dev/null +++ b/server/lib/cimi/model/address.rb @@ -0,0 +1,56 @@ +# 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::Address < CIMI::Model::Base + + text :ip + + text :hostname + + text :allocation + + text :default_gateway + + text :dns + + text :mac_address + + text :protocol + + text :mask + + href :network + + href :resource + + array :operations do + scalar :rel, :href + end + + def self.find(id, context) + if id==:all + context.driver.addresses(context.credentials, {:env=>context}) + else + context.driver.addresses(context.credentials, {:id=>id, :env=>context}) + end + end + + def self.create(request_body, context, type) + end + + def self.delete!(id, context) + end + +end diff --git a/server/lib/cimi/model/address_collection.rb b/server/lib/cimi/model/address_collection.rb new file mode 100644 index 0000000..eef6c51 --- /dev/null +++ b/server/lib/cimi/model/address_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::AddressCollection < CIMI::Model::Base + + act_as_root_entity :address + + array :addresses do + scalar :href + end + + def self.default(context) + self.new( + :id => context.addresses_url, + :name => 'default', + :created => Time.now, + :description => "#{context.driver.name.capitalize} AddressCollection", + :addresses => CIMI::Model::Address.all(context).map { |addr| { :href => addr.id } } + ) + end + +end diff --git a/server/lib/cimi/model/address_template.rb b/server/lib/cimi/model/address_template.rb new file mode 100644 index 0000000..9d2c409 --- /dev/null +++ b/server/lib/cimi/model/address_template.rb @@ -0,0 +1,54 @@ +# 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::AddressTemplate < CIMI::Model::Base + + text :ip + + text :hostname + + text :allocation + + text :default_gateway + + text :dns + + text :mac_address + + text :protocol + + text :mask + + href :network + + array :operations do + scalar :rel, :href + end + + def self.find(id, context) + if id==:all + context.driver.address_templates(context.credentials, {:env=>context}) + else + context.driver.address_templates(context.credentials, {:id=>id, :env=>context}) + end + end + + def self.create(request_body, context, type) + end + + def self.delete!(id, context) + end + +end diff --git a/server/lib/cimi/model/address_template_collection.rb b/server/lib/cimi/model/address_template_collection.rb new file mode 100644 index 0000000..e973252 --- /dev/null +++ b/server/lib/cimi/model/address_template_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::AddressTemplateCollection < CIMI::Model::Base + + act_as_root_entity :address_template + + array :address_templates do + scalar :href + end + + def self.default(context) + self.new( + :id => context.address_templates_url, + :name => 'default', + :created => Time.now, + :description => "#{context.driver.name.capitalize} AddressTemplateCollection", + :address_templates => AddressTemplate.all(context).map { |addr| { :href => addr.id } } + ) + end + +end diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb index 7ba18d1..305acd7 100644 --- a/server/lib/cimi/server.rb +++ b/server/lib/cimi/server.rb @@ -812,3 +812,64 @@ global_collection :vsp_templates do end end + +global_collection :addresses do + + description 'An Address represents an IP address, and its associated metdata, for a particular Network.' + + operation :index do + description 'List all Addresses in the AddressCollection' + param :CIMISelect, :string, :optional + control do + addresses = AddressCollection.default(self).filter_by(params[:CIMISelect]) + respond_to do |format| + format.xml {addresses.to_xml} + format.json {addresses.to_json} + end + end + end + + operation :show do + description 'Show a specific Address' + param :id, :string, :required + control do + address = CIMI::Model::Address.find(params[:id], self) + respond_to do |format| + format.xml {address.to_xml} + format.json {address.to_json} + end + end + end + +end + + +global_collection :address_templates do + + description 'An AddressTemplate captures the configuration values for realizing an Address. An Address Template may be used to create multiple Addresses.' + + operation :index do + description 'List all AddressTemplates in the AddressTemplateCollection' + param :CIMISelect, :string, :optional + control do + address_templates = AddressTemplateCollection.default(self).filter_by(params[:CIMISelect]) + respond_to do |format| + format.xml {address_templates.to_xml} + format.json {address_templates.to_json} + end + end + end + + operation :show do + description 'Show a specific AddressTemplate' + param :id, :string, :required + control do + address_template = CIMI::Model::AddressTemplate.find(params[:id], self) + respond_to do |format| + format.xml {address_template.to_xml} + format.json {address_template.to_json} + end + end + end + +end -- 1.7.6.5
