deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH 1/3] CIMI: tidy up - add features for Machine and missing VolumeTemplates
Date Tue, 18 Dec 2012 17:26:21 GMT
From: marios <marios@redhat.com>


Signed-off-by: marios <marios@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


Mime
View raw message