From: marios <[email protected]>
Signed-off-by: marios <[email protected]> --- server/lib/cimi/model.rb | 2 + server/lib/cimi/model/vsp_template.rb | 34 ++++++++++++++++++++++ server/lib/cimi/model/vsp_template_collection.rb | 34 ++++++++++++++++++++++ server/lib/cimi/server.rb | 31 ++++++++++++++++++++ 4 files changed, 101 insertions(+), 0 deletions(-) create mode 100644 server/lib/cimi/model/vsp_template.rb create mode 100644 server/lib/cimi/model/vsp_template_collection.rb diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb index 1136593..0befe31 100644 --- a/server/lib/cimi/model.rb +++ b/server/lib/cimi/model.rb @@ -59,3 +59,5 @@ require 'cimi/model/vsp' require 'cimi/model/vsp_collection' require 'cimi/model/vsp_configuration' require 'cimi/model/vsp_configuration_collection' +require 'cimi/model/vsp_template' +require 'cimi/model/vsp_template_collection' diff --git a/server/lib/cimi/model/vsp_template.rb b/server/lib/cimi/model/vsp_template.rb new file mode 100644 index 0000000..f1b8078 --- /dev/null +++ b/server/lib/cimi/model/vsp_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::VSPTemplate < CIMI::Model::Base + + href :network + + href :vsp_config + + array :operations do + scalar :rel, :href + end + + def self.find(id, context) + if id==:all + context.driver.vsp_templates(context.credentials, {:env=>context}) + else + context.driver.vsp_templates(context.credentials, {:env=>context, :id=>id}) + end + end + +end diff --git a/server/lib/cimi/model/vsp_template_collection.rb b/server/lib/cimi/model/vsp_template_collection.rb new file mode 100644 index 0000000..4acb74e --- /dev/null +++ b/server/lib/cimi/model/vsp_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::VSPTemplateCollection < CIMI::Model::Base + + CIMI::Model.register_as_root_entity! "VSPTemplates" + + array :vsp_templates do + scalar :href + end + + def self.default(context) + self.new( + :id => context.vsp_templates_url, + :name => 'default', + :created => Time.now, + :description => "#{context.driver.name.capitalize} VSPTemplateCollection", + :vsp_templates => VSPTemplate.all_uri(context) + ) + end + +end diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb index 4dc0606..0f62951 100644 --- a/server/lib/cimi/server.rb +++ b/server/lib/cimi/server.rb @@ -727,3 +727,34 @@ global_collection :vsp_configurations do end end + + +global_collection :vsp_templates do + + description 'The VSP Template is a set of Configuration values for realizing a VSP. A VSP Template may be used to create multiple VSPs' + + operation :index do + description 'List all VSPTemplates in the VSPTemplateCollection' + param :CIMISelect, :string, :optional + control do + vsp_templates = VSPTemplateCollection.default(self).filter_by(params[:CIMISelect]) + respond_to do |format| + format.xml {vsp_templates.to_xml} + format.json {vsp_templates.to_json} + end + end + end + + operation :show do + description 'Show a specific VSPTemplate' + param :id, :string, :required + control do + vsp_template = VSPTemplate.find(params[:id], self) + respond_to do |format| + format.xml {vsp_template.to_xml} + format.json {vsp_template.to_json} + end + end + end + +end -- 1.7.6.5
