On 18/12/12 21:58, Ronelle Landy wrote: >> From: [email protected] >> To: [email protected] >> Sent: Tuesday, December 18, 2012 12:26:21 PM >> Subject: [PATCH 1/3] CIMI: tidy up - add features for Machine and missing >> VolumeTemplates >> >> From: marios <[email protected]> >> >> >> Signed-off-by: marios <[email protected]> >> --- >> server/lib/cimi/collections/machines.rb | 3 ++ >> server/lib/cimi/collections/volume_templates.rb | 47 >> +++++++++++++++++++++++++ >> server/lib/cimi/models/volume_template.rb | 3 ++ >> 3 files changed, 53 insertions(+) >> create mode 100644 server/lib/cimi/collections/volume_templates.rb >> >> diff --git a/server/lib/cimi/collections/machines.rb >> b/server/lib/cimi/collections/machines.rb >> index b18fb1c..e5e1836 100644 >> --- a/server/lib/cimi/collections/machines.rb >> +++ b/server/lib/cimi/collections/machines.rb >> @@ -16,7 +16,10 @@ >> module CIMI::Collections >> class Machines < Base >> >> + include CIMI::Features >> + >> set :capability, lambda { |m| driver.respond_to? m } >> + check_features :for => lambda { |c, f| >> driver.class.has_feature?(c, f) } >> >> collection :machines do >> description 'List all machine' >> diff --git a/server/lib/cimi/collections/volume_templates.rb >> b/server/lib/cimi/collections/volume_templates.rb >> new file mode 100644 >> index 0000000..c73934e >> --- /dev/null >> +++ b/server/lib/cimi/collections/volume_templates.rb >> @@ -0,0 +1,47 @@ >> +# 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 VolumeTemplates < Base >> + >> +# set :capability, lambda { |m| driver.respond_to? m } >> + >> + collection :volume_templates do >> + >> + operation :index do >> + description "Get list all VolumeTemplates" >> + control do >> + volume_template = >> VolumeTemplates.list(self).filter_by(params['$select']) >> + respond_to do |format| >> + format.xml { volume_template.to_xml } >> + format.json { volume_template.to_json } >> + end >> + end >> + end >> + >> + operation :show do >> + description "Get a specific VolumeTemplate" >> + control do >> + volume_template = VolumeTemplate.find(params[:id], self) >> + respond_to do |format| >> + format.xml { volume_template.to_xml } >> + format.json { volume_template.json } >> + end >> + end >> + end >> + end >> + >> + end >> +end >> diff --git a/server/lib/cimi/models/volume_template.rb >> b/server/lib/cimi/models/volume_template.rb >> index b2ac323..bb632c6 100644 >> --- a/server/lib/cimi/models/volume_template.rb >> +++ b/server/lib/cimi/models/volume_template.rb >> @@ -22,4 +22,7 @@ class CIMI::Model::VolumeTemplate < >> CIMI::Model::Base >> array :operations do >> scalar :rel, :href >> end >> + >> + def self.find(id, context) >> + end >> end >> -- >> 1.7.11.7 >> > Hi Marios, > > I get the following error from GET /cimi/volume_templates - mock provider > (after "rake mock:fixtures:reset"): >
OK - I've 'fixed' this for now to just return an empty body - adding the volume_templates functionality is a different issue (needs the db like machine templates). The reason I had to add it at all here is explained in my other e-mail (response to David) - to do with the volume_templates_url helper. > curl -X GET --user "un:pw" > "http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/volume_templates" > {"code":500,"message":"undefined method `list' for > CIMI::Collections::VolumeTemplates:Class","error":"NoMethodError"} > > Similar error + place from running cep_test.rb: > right - well for now and until volume_templates are 'properly' supported I suggest we remove it from the list of 'ROOTS' to be tested in cep_test.rb - as we already do for some other entities. I'll add this in the rev2 patch set marios > ********** > ERROR -- 500: [NoMethodError] undefined method `list' for > CIMI::Collections::VolumeTemplates:Class > > /home/dcloud/workspace/deltacloud/server/lib/cimi/collections/volume_templates.rb:26:in > `block (3 levels) in <class:VolumeTemplates>' > /usr/local/share/gems/gems/sinatra-rabbit-1.1.3/lib/sinatra/rabbit/base.rb:396:in > `instance_eval' > /usr/local/share/gems/gems/sinatra-rabbit-1.1.3/lib/sinatra/rabbit/base.rb:396:in > `block in control' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `block > in compile!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `[]' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (3 > levels) in route!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in > `route_eval' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (2 > levels) in route!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `block in > process_route' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `catch' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in > `process_route' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `block in > route!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `each' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in > `dispatch!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `block in > call!' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `block in > invoke' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `catch' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke' > /usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!' > > ********** > > Applied all three patches in http://tracker.deltacloud.org/set/212. >
