You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2012/12/18 18:26:20 UTC

Rev1 CIMI ResourceMetadata capabilities

Initial implementation/rework of CIMI ResourceMetadata:

curl --user "mockuser:mockpassword" -H "Accept: application/xml" http://localhost:3001/cimi/resource_metadata


*** Usage:

CIMI features go in deltacloud/server/lib/deltacloud/drivers/cimi_features.rb - defined in same way as deltacloud features.

Example usage in mock driver:

 87     #cimi features$
 88     feature :machines, :default_initial_state do$
 89       { :values => ["STARTED"] }$     
 90     end$
 91     feature :machines, :initial_states do$
 92       { :values => ["STARTED", "STOPPED"]}$
 93     end$

NOTE: these may note make sense for mock (e.g. initial_states) but are here just for testing/example

*** Issues

imo CIMI spec not entirely clear/I don't understand how 'values' are to be defined for capability (I tried following what is says for 'constraints' of attributes - i need to bring this up in next meeting)... and I can't work out how to serialize them correctly using our dsl - so the XML for example looks like (note how 'value' is specified...):

<ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1" resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata">
  <id>http://localhost:3001/cimi/resource_metadata/machine</id>
  <name>Machine</name>
  <typeUri>http://localhost:3001/cimi/machines</typeUri>
  <capability name="DefaultInitialState" uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState" description="Indicates what the default initial state of a new Machine">
    <value>
      <value>STARTED</value>
    </value>
  </capability>
  <capability name="DefaultInitialState" uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState" description="Indicates the list of allowable initial states">
    <value>
      <value>STARTED</value>
    </value>
    <value>
      <value>STOPPED</value>
    </value>
  </capability>
</ResourceMetadata>


marios

Re: [PATCH 2/3] CIMI: Add CIMI Features (Sinatra rabbit features DSL)

Posted by David Lutterkort <lu...@redhat.com>.
On Tue, 2012-12-18 at 19:26 +0200, marios@redhat.com wrote:

> diff --git a/server/lib/deltacloud/drivers/cimi_features.rb b/server/lib/deltacloud/drivers/cimi_features.rb
> new file mode 100644
> index 0000000..adcdcbf
> --- /dev/null
> +++ b/server/lib/deltacloud/drivers/cimi_features.rb
> @@ -0,0 +1,48 @@
> +# 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
> +  module Features
> +
> +    def self.included(k)
> +      current_features = features
> +      k.instance_eval do
> +        features(&current_features)
> +      end
> +    end
> +
> +    def self.features(&block)
> +      block_given? ? @features = block : @features || Proc.new{}
> +    end

This isn't so much a comment on your patch, but on our code in general:
the whole feature handling is making me dizzy. We should have another
look and make sure we separate the feature declaration DSL better from
the code that actually declares features.

That would hopefully let us avoid duplicating code between
CIMI::Features and Deltacloud::Features.

David



[PATCH 2/3] CIMI: Add CIMI Features (Sinatra rabbit features DSL)

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/cimi/helpers.rb                     |  3 +-
 server/lib/deltacloud/drivers/base_driver.rb   |  2 +-
 server/lib/deltacloud/drivers/cimi_features.rb | 48 ++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 server/lib/deltacloud/drivers/cimi_features.rb

diff --git a/server/lib/cimi/helpers.rb b/server/lib/cimi/helpers.rb
index ea71cbf..75f9770 100644
--- a/server/lib/cimi/helpers.rb
+++ b/server/lib/cimi/helpers.rb
@@ -14,12 +14,13 @@
 # under the License.
 
 require_relative '../deltacloud/drivers/features'
-
+require_relative '../deltacloud/drivers/cimi_features'
 module CIMI
   module Model; end
   class FakeCollection
     extend Sinatra::Rabbit::Features
     include Deltacloud::Features
+    include CIMI::Features
   end
 end
 
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index c63f94f..f488f91 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -19,6 +19,7 @@ module Deltacloud
   require_relative '../core_ext.rb'
   require_relative './exceptions.rb'
   require_relative './features.rb'
+  require_relative './cimi_features.rb'
   require_relative '../models/state_machine.rb'
 
   class BaseDriver
@@ -38,7 +39,6 @@ module Deltacloud
       @features ||= {}
     end
 
-
     def self.feature(collection, feature_name)
       return if has_feature?(collection, feature_name)
       constraints[collection] ||= {}
diff --git a/server/lib/deltacloud/drivers/cimi_features.rb b/server/lib/deltacloud/drivers/cimi_features.rb
new file mode 100644
index 0000000..adcdcbf
--- /dev/null
+++ b/server/lib/deltacloud/drivers/cimi_features.rb
@@ -0,0 +1,48 @@
+# 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
+  module Features
+
+    def self.included(k)
+      current_features = features
+      k.instance_eval do
+        features(&current_features)
+      end
+    end
+
+    def self.features(&block)
+      block_given? ? @features = block : @features || Proc.new{}
+    end
+
+
+    features do
+      feature :default_initial_state, :for => :machines do
+        description "Indicates what the default initial state of a new Machine "
+          operation :create do
+            param :default_initial_state, :string, :optional, [], "Indicates what the default initial state of a new Machine"
+          end
+      end
+
+      feature :initial_states, :for => :machines do
+        description "Indicates the list of allowable initial states"
+          operation :create do
+            param :default_initial_state, :string, :optional, [], "Indicates the list of allowable initial states"
+          end
+      end
+
+    end
+  end
+end
-- 
1.7.11.7


[PATCH 3/3] CIMI: Initial implementation of resource_metadata (capabilities) for Machine

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/cimi/collections/resource_metadata.rb  |  2 +-
 server/lib/cimi/models/machine.rb                 |  9 ---
 server/lib/cimi/models/resource_metadata.rb       | 92 ++++++++++++++++-------
 server/lib/deltacloud/drivers/mock/mock_driver.rb |  9 +++
 4 files changed, 74 insertions(+), 38 deletions(-)

diff --git a/server/lib/cimi/collections/resource_metadata.rb b/server/lib/cimi/collections/resource_metadata.rb
index edd8d65..54de02a 100644
--- a/server/lib/cimi/collections/resource_metadata.rb
+++ b/server/lib/cimi/collections/resource_metadata.rb
@@ -32,7 +32,7 @@ module CIMI::Collections
       operation :show do
         description "Get the resource metadata for a specific collection"
         control do
-          resource_metadata = ResourceMetadata.find(params[:id], self)
+          resource_metadata = CIMI::Model::ResourceMetadata.find(params[:id], self)
           respond_to do |format|
             format.xml{resource_metadata.to_xml}
             format.json{resource_metadata.to_json}
diff --git a/server/lib/cimi/models/machine.rb b/server/lib/cimi/models/machine.rb
index 53bdd37..e9d774b 100644
--- a/server/lib/cimi/models/machine.rb
+++ b/server/lib/cimi/models/machine.rb
@@ -116,15 +116,6 @@ class CIMI::Model::Machine < CIMI::Model::Base
     context.driver.destroy_instance(context.credentials, id)
   end
 
-  def self.create_resource_metadata(context)
-    cimi_resource = self.name.split("::").last
-    metadata = CIMI::Model::ResourceMetadata.metadata_from_deltacloud_features(cimi_resource, :instances, context)
-    unless metadata.includes_attribute?(:name)
-      metadata.attributes << {:name=>"name", :required=>"false",
-                   :constraints=>"Determined by the cloud provider", :type=>"xs:string"}
-    end
-    metadata
-  end
   #returns the newly attach machine_volume
   def self.attach_volume(volume, location, context)
     context.driver.attach_storage_volume(context.credentials,
diff --git a/server/lib/cimi/models/resource_metadata.rb b/server/lib/cimi/models/resource_metadata.rb
index 5e62061..f216285 100644
--- a/server/lib/cimi/models/resource_metadata.rb
+++ b/server/lib/cimi/models/resource_metadata.rb
@@ -16,8 +16,12 @@
 
 class CIMI::Model::ResourceMetadata < CIMI::Model::Base
 
+  SCHEMA_CAPABILITY_BASE_URI = "http://schemas.dmtf.org/cimi/1/capability"
+
   acts_as_root_entity
 
+  text :name
+
   text :type_uri
 
   array :attributes do
@@ -25,10 +29,22 @@ class CIMI::Model::ResourceMetadata < CIMI::Model::Base
     scalar :namespace
     scalar :type
     scalar :required
-    scalar :constraints
+    array :constraints do
+      text :value
+    end
   end
 
-  array :operations do
+  array :capabilities do
+    scalar :name
+    scalar :uri
+    scalar :description
+    array :values do
+      text :value
+    end
+  end
+
+
+  array :actions do
     scalar :name
     scalar :uri
     scalar :description
@@ -37,49 +53,69 @@ class CIMI::Model::ResourceMetadata < CIMI::Model::Base
     scalar :output_message
   end
 
+  array :operations do
+    scalar :rel, :href
+  end
+
   def self.find(id, context)
-    resource_metadata = []
     if id == :all
+      resource_metadata = []
       CIMI::Model.root_entities.each do |resource_class|
-        resource_metadata << resource_class.create_resource_metadata(context) if resource_class.respond_to?(:create_resource_metadata)
+        meta = resource_metadata_for(resource_class, context)
+        resource_metadata << meta unless none_defined(meta)
       end
       return resource_metadata
     else
       resource_class = CIMI::Model.const_get("#{id.camelize}")
-      if resource_class.respond_to?(:create_resource_metadata)
-        resource_class.create_resource_metadata(context)
-      end
+      resource_metadata_for(resource_class, context)
     end
   end
 
-  def self.metadata_from_deltacloud_features(cimi_resource, dcloud_resource, context)
-    deltacloud_features = context.driver.class.features[dcloud_resource]
-    metadata_attributes = deltacloud_features.map{|f| attributes_from_feature(f)}
-    from_feature(cimi_resource, context, metadata_attributes.flatten!)
-  end
-
-  def includes_attribute?(attribute)
-    self.attributes.any?{|attr| attr[:name] == attribute}
+  def self.resource_metadata_for(resource_class, context)
+    attributes = rm_attributes_for(resource_class, context)
+    capabilities = rm_capabilities_for(resource_class, context)
+    actions = rm_actions_for(resource_class, context)
+    cimi_resource = resource_class.name.split("::").last
+    self.new({ :id => context.resource_metadata_url(cimi_resource.underscore),
+              :name => cimi_resource,
+              :type_uri => context.send("#{cimi_resource.underscore}_url"),
+              :attributes => attributes,
+              :capabilities => capabilities,
+              :actions => actions
+    })
   end
 
   private
 
-  def self.attributes_from_feature(feature)
-    feature = CIMI::FakeCollection.feature(feature)
-    feature.operations.first.params_array.map do |p|
-      {
-        :name=> p.name,
-        :type=> "xs:string",
-        :required=> p.required? ? "true" : "false",
-        :constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" : feature.description): feature.constraints)
-      }
+  def self.rm_attributes_for(resource_class, context)
+    []
+  end
+
+  def self.rm_capabilities_for(resource_class,context)
+    cimi_object = resource_class.name.split("::").last.underscore.pluralize.to_sym
+    capabilities = (context.driver.class.features[cimi_object] || []).inject([]) do |res, cur|
+      feat = CIMI::FakeCollection.feature(cur)
+      feat_param = feat.operations.first.params_array.first
+      values = (context.driver.class.constraints[cimi_object][feat.name][:values] || []).inject([]) do |vals, val|
+        vals << {:value => val}
+        vals
+      end
+      res << {:name => feat_param.name.to_s.camelize,
+       :uri => SCHEMA_CAPABILITY_BASE_URI+"/#{cimi_object.to_s.camelize.singularize}/#{feat_param.name.to_s.camelize}",
+       :description => feat_param.description,
+       :values => values }
+      res
     end
+#cimi_resource.underscore.pluralize.to_sym
+  end
+
+  def self.rm_actions_for(resource_class, context)
+    []
   end
 
-  def self.from_feature(cimi_resource, context, metadata_attributes)
-    self.new(:name => cimi_resource, :uri=>"#{context.resource_metadata_url}/#{cimi_resource.underscore}",
-             :type_uri=> context.send("#{cimi_resource.pluralize.underscore}_url"),
-             :attributes => metadata_attributes)
+  def self.none_defined(metadata)
+    return true if metadata.capabilities.empty? && metadata.capabilities.empty? && metadata.attributes.empty?
+    return false
   end
 
 end
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 111196f..38cb042 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -84,6 +84,15 @@ module Deltacloud::Drivers::Mock
     feature :images, :user_name
     feature :images, :user_description
 
+    #cimi features
+    feature :machines, :default_initial_state do
+      { :values => ["STARTED"] }
+    end
+    feature :machines, :initial_states do
+      { :values => ["STARTED", "STOPPED"]}
+    end
+
+
     def initialize
       if ENV["DELTACLOUD_MOCK_STORAGE"]
         storage_root = ENV["DELTACLOUD_MOCK_STORAGE"]
-- 
1.7.11.7


Re: [PATCH 1/3] CIMI: tidy up - add features for Machine and missing VolumeTemplates

Posted by "marios@redhat.com" <ma...@redhat.com>.
On 19/12/12 00:41, David Lutterkort wrote:
> Hi Marios,
> 
> some comments:
> 
> On Tue, 2012-12-18 at 19:26 +0200, marios@redhat.com wrote:
>> 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
> 
> Shouldn't this go into CIMI::Collections::Base ? We don't want to have
> to repeat that for every entity that exposes capabilities.
> 

yes, good idea done.


>> 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
> 
> I'll just repeat my grumbly point that this should go into a different
> patch, since it doesn't have anything to do with capabilities.
> 

well - the only reason I had to touch volume_templates *_at_all_* here
is that, since we didn't have this collection defined - the
'volume_templates_url' helper wasn't exposed. I needed this for the
'type_uri' of each resourceMetadata entry... (even though I may be wrong
about the typeURI - addressed in the other "RMD Capabilities test plan"
e-mail)


>> 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
> 
> As Ronelle noticed, this will just make retrieving volume templates blow
> up.

as above - i didn't really want to tackle volume_templates here as well
as resource meta - its a separate issue. For rev2 I'll just do the bare
minimum so things don't explode - we can more fully implement volume
templates (using the db layer - needs some thought) afterwards,


marios


> 
> David
> 
> 


Re: [PATCH 1/3] CIMI: tidy up - add features for Machine and missing VolumeTemplates

Posted by David Lutterkort <lu...@redhat.com>.
Hi Marios,

some comments:

On Tue, 2012-12-18 at 19:26 +0200, marios@redhat.com wrote:
> 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

Shouldn't this go into CIMI::Collections::Base ? We don't want to have
to repeat that for every entity that exposes capabilities.

> 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

I'll just repeat my grumbly point that this should go into a different
patch, since it doesn't have anything to do with capabilities.

> 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

As Ronelle noticed, this will just make retrieving volume templates blow
up.

David



Re: [PATCH 1/3] CIMI: tidy up - add features for Machine and missing VolumeTemplates

Posted by "marios@redhat.com" <ma...@redhat.com>.
On 18/12/12 21:58, Ronelle Landy wrote:
>> From: marios@redhat.com
>> To: dev@deltacloud.apache.org
>> 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 <ma...@redhat.com>
>>
>>
>> Signed-off-by: marios <ma...@redhat.com>
>> ---
>>  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.
> 


Re: [PATCH 1/3] CIMI: tidy up - add features for Machine and missing VolumeTemplates

Posted by Ronelle Landy <rl...@redhat.com>.
> From: marios@redhat.com
> To: dev@deltacloud.apache.org
> 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 <ma...@redhat.com>
> 
> 
> Signed-off-by: marios <ma...@redhat.com>
> ---
>  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"):

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:

**********
 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.

[PATCH 1/3] CIMI: tidy up - add features for Machine and missing VolumeTemplates

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 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


Re: Rev1 CIMI ResourceMetadata capabilities

Posted by "marios@redhat.com" <ma...@redhat.com>.
On 18/12/12 23:09, Ronelle Landy wrote:
>> From: marios@redhat.com
>> To: dev@deltacloud.apache.org
>> Sent: Tuesday, December 18, 2012 12:26:20 PM
>> Subject: Rev1 CIMI ResourceMetadata capabilities
>>
>>
>> Initial implementation/rework of CIMI ResourceMetadata:
>>
>> curl --user "mockuser:mockpassword" -H "Accept: application/xml"
>> http://localhost:3001/cimi/resource_metadata
>>
>>
>> *** Usage:
>>
>> CIMI features go in
>> deltacloud/server/lib/deltacloud/drivers/cimi_features.rb - defined
>> in same way as deltacloud features.
>>
>> Example usage in mock driver:
>>
>>  87     #cimi features$
>>  88     feature :machines, :default_initial_state do$
>>  89       { :values => ["STARTED"] }$
>>  90     end$
>>  91     feature :machines, :initial_states do$
>>  92       { :values => ["STARTED", "STOPPED"]}$
>>  93     end$
>>
>> NOTE: these may note make sense for mock (e.g. initial_states) but
>> are here just for testing/example
>>
>> *** Issues
>>
>> imo CIMI spec not entirely clear/I don't understand how 'values' are
>> to be defined for capability (I tried following what is says for
>> 'constraints' of attributes - i need to bring this up in next
>> meeting)... and I can't work out how to serialize them correctly
>> using our dsl - so the XML for example looks like (note how 'value'
>> is specified...):
>>
>> <ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1"
>> resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata">
>>   <id>http://localhost:3001/cimi/resource_metadata/machine</id>
>>   <name>Machine</name>
>>   <typeUri>http://localhost:3001/cimi/machines</typeUri>
>>   <capability name="DefaultInitialState"
>>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
>>   description="Indicates what the default initial state of a new
>>   Machine">
>>     <value>
>>       <value>STARTED</value>
>>     </value>
>>   </capability>
>>   <capability name="DefaultInitialState"
>>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
>>   description="Indicates the list of allowable initial states">
>>     <value>
>>       <value>STARTED</value>
>>     </value>
>>     <value>
>>       <value>STOPPED</value>
>>     </value>
>>   </capability>
>> </ResourceMetadata>
>>
>>
>> marios
>>
> 
> Apologies for the string of emails ... logging stuff as I hit it: 
> 

np - thanks for the feedback:


>  - The XML example above shows name, uri and description for each capability added. After applying the patches, I see the name and uri but no description ... json output is copied below - see empty decsription:
> 
> {"id":"http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/resource_metadata","count":1,"resourceMetadata":[{"id":"http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/resource_metadata/machine","name":"Machine","typeUri":"http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/machines","capabilities":[{"name":"DefaultInitialState","uri":"http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState","description":[],"values":[{"value":"STARTED"}]},{"name":"DefaultInitialState","uri":"http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState","description":[],"values":[{"value":"STARTED"},{"value":"STOPPED"}]}]}],"resourceURI":"http://schemas.dmtf.org/cimi/1/ResourceMetadataCollection"}
> 


couldn't re-create this one... wonder if it's a sinatra-rabbit version
issue... what does gem list sinatra-rabbit say (I am running 1.1.3)



>  -  When creating a new machine, where in the POST command would I specify the desired initial state?
> 

There's an 'initialState' attribute for machineTemplate... at a guess it
would look like (NOTE: our machine create code is not yet setup to parse
and act on this initial state yet):

curl -v --user "user:password" -X POST -H "Content-Type:
application/xml" -H "Accept: application/xml" -d '
<MachineCreate xmlns="http://schemas.dmtf.org/cimi/1">
  <name> myMachine1 </name>
  <description> my machine </description>
  <machineTemplate>
    <initialState> STARTED </initialState>
    <machineConfig
href="http://localhost:3001/cimi/machine_configurations/m1.small">
</machineConfig>
    <machineImage
href="http://localhost:3001/cimi/machine_images/ami-48aa4921">
</machineImage>
  </machineTemplate>
</MachineCreate>' http://localhost:3001/cimi/machines


curl -v --user "user:password" -X POST -H "Content-Type:
application/json" -H "Accept: application/xml" -d
'{ "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate", 	
   "name": "myMachine3", "description": "My very first json machine",
   "machineTemplate":
    { "initialState": "STARTED",
      "machineConfig":
       { "href":
"http://localhost:3001/cimi/machine_configurations/m1.small" },
      "machineImage":
       { "href": "http://localhost:3001/cimi/machine_images/ami-48aa4921"
       }
    }
 }' http://localhost:3001/cimi/machines


marios

> 
> 
>  
> 


Re: Rev1 CIMI ResourceMetadata capabilities

Posted by Ronelle Landy <rl...@redhat.com>.
> From: marios@redhat.com
> To: dev@deltacloud.apache.org
> Sent: Tuesday, December 18, 2012 12:26:20 PM
> Subject: Rev1 CIMI ResourceMetadata capabilities
> 
> 
> Initial implementation/rework of CIMI ResourceMetadata:
> 
> curl --user "mockuser:mockpassword" -H "Accept: application/xml"
> http://localhost:3001/cimi/resource_metadata
> 
> 
> *** Usage:
> 
> CIMI features go in
> deltacloud/server/lib/deltacloud/drivers/cimi_features.rb - defined
> in same way as deltacloud features.
> 
> Example usage in mock driver:
> 
>  87     #cimi features$
>  88     feature :machines, :default_initial_state do$
>  89       { :values => ["STARTED"] }$
>  90     end$
>  91     feature :machines, :initial_states do$
>  92       { :values => ["STARTED", "STOPPED"]}$
>  93     end$
> 
> NOTE: these may note make sense for mock (e.g. initial_states) but
> are here just for testing/example
> 
> *** Issues
> 
> imo CIMI spec not entirely clear/I don't understand how 'values' are
> to be defined for capability (I tried following what is says for
> 'constraints' of attributes - i need to bring this up in next
> meeting)... and I can't work out how to serialize them correctly
> using our dsl - so the XML for example looks like (note how 'value'
> is specified...):
> 
> <ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1"
> resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata">
>   <id>http://localhost:3001/cimi/resource_metadata/machine</id>
>   <name>Machine</name>
>   <typeUri>http://localhost:3001/cimi/machines</typeUri>
>   <capability name="DefaultInitialState"
>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
>   description="Indicates what the default initial state of a new
>   Machine">
>     <value>
>       <value>STARTED</value>
>     </value>
>   </capability>
>   <capability name="DefaultInitialState"
>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
>   description="Indicates the list of allowable initial states">
>     <value>
>       <value>STARTED</value>
>     </value>
>     <value>
>       <value>STOPPED</value>
>     </value>
>   </capability>
> </ResourceMetadata>
> 
> 
> marios
> 

Apologies for the string of emails ... logging stuff as I hit it: 

 - The XML example above shows name, uri and description for each capability added. After applying the patches, I see the name and uri but no description ... json output is copied below - see empty decsription:

{"id":"http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/resource_metadata","count":1,"resourceMetadata":[{"id":"http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/resource_metadata/machine","name":"Machine","typeUri":"http://qeblade39.rhq.lab.eng.bos.redhat.com:3001/cimi/machines","capabilities":[{"name":"DefaultInitialState","uri":"http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState","description":[],"values":[{"value":"STARTED"}]},{"name":"DefaultInitialState","uri":"http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState","description":[],"values":[{"value":"STARTED"},{"value":"STOPPED"}]}]}],"resourceURI":"http://schemas.dmtf.org/cimi/1/ResourceMetadataCollection"}

 -  When creating a new machine, where in the POST command would I specify the desired initial state?



 

Re: Rev1 CIMI ResourceMetadata capabilities

Posted by "marios@redhat.com" <ma...@redhat.com>.
On 18/12/12 22:11, Ronelle Landy wrote:
>> From: marios@redhat.com
>> To: dev@deltacloud.apache.org
>> Sent: Tuesday, December 18, 2012 12:26:20 PM
>> Subject: Rev1 CIMI ResourceMetadata capabilities
>>
>>
>> Initial implementation/rework of CIMI ResourceMetadata:
>>
>> curl --user "mockuser:mockpassword" -H "Accept: application/xml"
>> http://localhost:3001/cimi/resource_metadata
>>
>>
>> *** Usage:
>>
>> CIMI features go in
>> deltacloud/server/lib/deltacloud/drivers/cimi_features.rb - defined
>> in same way as deltacloud features.
>>
>> Example usage in mock driver:
>>
>>  87     #cimi features$
>>  88     feature :machines, :default_initial_state do$
>>  89       { :values => ["STARTED"] }$
>>  90     end$
>>  91     feature :machines, :initial_states do$
>>  92       { :values => ["STARTED", "STOPPED"]}$
>>  93     end$
>>
>> NOTE: these may note make sense for mock (e.g. initial_states) but
>> are here just for testing/example
>>
>> *** Issues
>>
>> imo CIMI spec not entirely clear/I don't understand how 'values' are
>> to be defined for capability (I tried following what is says for
>> 'constraints' of attributes - i need to bring this up in next
>> meeting)... and I can't work out how to serialize them correctly
>> using our dsl - so the XML for example looks like (note how 'value'
>> is specified...):
>>
>> <ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1"
>> resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata">
>>   <id>http://localhost:3001/cimi/resource_metadata/machine</id>
>>   <name>Machine</name>
>>   <typeUri>http://localhost:3001/cimi/machines</typeUri>
>>   <capability name="DefaultInitialState"
>>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
>>   description="Indicates what the default initial state of a new
>>   Machine">
>>     <value>
>>       <value>STARTED</value>
>>     </value>
>>   </capability>
>>   <capability name="DefaultInitialState"
>>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
> 
> Think this should be:
> <capability name="InitialStates"
> uri="http://schemas.dmtf.org/cimi/1/capability/Machine/InitialStates"
> 

awesome - thanks for spotting this! fixed for next rev2 patchset,

marios


> XML entry for DefaultInitialState is listed first.
> 
>>   description="Indicates the list of allowable initial states">
>>     <value>
>>       <value>STARTED</value>
>>     </value>
>>     <value>
>>       <value>STOPPED</value>
>>     </value>
>>   </capability>
>> </ResourceMetadata>
>>
>>
>> marios
>>


Re: Rev1 CIMI ResourceMetadata capabilities

Posted by Ronelle Landy <rl...@redhat.com>.
> From: marios@redhat.com
> To: dev@deltacloud.apache.org
> Sent: Tuesday, December 18, 2012 12:26:20 PM
> Subject: Rev1 CIMI ResourceMetadata capabilities
> 
> 
> Initial implementation/rework of CIMI ResourceMetadata:
> 
> curl --user "mockuser:mockpassword" -H "Accept: application/xml"
> http://localhost:3001/cimi/resource_metadata
> 
> 
> *** Usage:
> 
> CIMI features go in
> deltacloud/server/lib/deltacloud/drivers/cimi_features.rb - defined
> in same way as deltacloud features.
> 
> Example usage in mock driver:
> 
>  87     #cimi features$
>  88     feature :machines, :default_initial_state do$
>  89       { :values => ["STARTED"] }$
>  90     end$
>  91     feature :machines, :initial_states do$
>  92       { :values => ["STARTED", "STOPPED"]}$
>  93     end$
> 
> NOTE: these may note make sense for mock (e.g. initial_states) but
> are here just for testing/example
> 
> *** Issues
> 
> imo CIMI spec not entirely clear/I don't understand how 'values' are
> to be defined for capability (I tried following what is says for
> 'constraints' of attributes - i need to bring this up in next
> meeting)... and I can't work out how to serialize them correctly
> using our dsl - so the XML for example looks like (note how 'value'
> is specified...):
> 
> <ResourceMetadata xmlns="http://schemas.dmtf.org/cimi/1"
> resourceURI="http://schemas.dmtf.org/cimi/1/ResourceMetadata">
>   <id>http://localhost:3001/cimi/resource_metadata/machine</id>
>   <name>Machine</name>
>   <typeUri>http://localhost:3001/cimi/machines</typeUri>
>   <capability name="DefaultInitialState"
>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"
>   description="Indicates what the default initial state of a new
>   Machine">
>     <value>
>       <value>STARTED</value>
>     </value>
>   </capability>
>   <capability name="DefaultInitialState"
>   uri="http://schemas.dmtf.org/cimi/1/capability/Machine/DefaultInitialState"

Think this should be:
<capability name="InitialStates"
uri="http://schemas.dmtf.org/cimi/1/capability/Machine/InitialStates"

XML entry for DefaultInitialState is listed first.

>   description="Indicates the list of allowable initial states">
>     <value>
>       <value>STARTED</value>
>     </value>
>     <value>
>       <value>STOPPED</value>
>     </value>
>   </capability>
> </ResourceMetadata>
> 
> 
> marios
>