From: David Lutterkort <[email protected]>

---
 server/server.rb                              |   12 +++++++++---
 server/views/hardware_profiles/index.xml.haml |    4 ++++
 server/views/hardware_profiles/show.xml.haml  |   17 +++++++++++++++++
 3 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 server/views/hardware_profiles/index.xml.haml
 create mode 100644 server/views/hardware_profiles/show.xml.haml

diff --git a/server/server.rb b/server/server.rb
index 67590d0..187aa07 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -278,15 +278,21 @@ collection :instances do
 end
 
 collection :hardware_profiles do
-  description "Hardware profiles"
+  description <<END
+ A hardware profile represents a configuration of resources upon which a
+ machine may be deployed. It defines aspects such as local disk storage,
+ available RAM, and architecture. Each provider is free to define as many
+ (or as few) hardware profiles as desired.
+END
 
   operation :index do
     description "List of available hardware profiles"
     param :id,          :string
+    param :architecture,  :string,  :optional,  [ 'i386', 'x86_64' ]
     control do
-        @profiles = driver.hardware_profiles
+        @profiles = driver.hardware_profiles(credentials, params)
         respond_to do |format|
-          format.xml  { convert_to_xml(:hardware_profiles, @profiles) }
+          format.xml  { haml :'hardware_profiles/index' }
           format.html  { haml :'hardware_profiles/index' }
         end
     end
diff --git a/server/views/hardware_profiles/index.xml.haml 
b/server/views/hardware_profiles/index.xml.haml
new file mode 100644
index 0000000..52f91a4
--- /dev/null
+++ b/server/views/hardware_profiles/index.xml.haml
@@ -0,0 +1,4 @@
+!!! XML
+%hardware-profiles
+  - @profiles.each do |prof|
+    = haml :'hardware_profiles/show', :locals => { :@profile => prof, :partial 
=> true }
diff --git a/server/views/hardware_profiles/show.xml.haml 
b/server/views/hardware_profiles/show.xml.haml
new file mode 100644
index 0000000..4a289a1
--- /dev/null
+++ b/server/views/hardware_profiles/show.xml.haml
@@ -0,0 +1,17 @@
+- unless defined?(partial)
+  !!! XML
+%hardware-profile{ :href => hardware_profile_url(@profile.name) }
+  %id= @profile.name
+  - @profile.each_property do |prop|
+    - attr = { :name => prop.name, :kind => prop.kind, :unit => prop.unit }
+    - if prop.kind == :fixed
+      %property{ attr, :value => prop.value }/
+    - else
+      %property{ attr, :value => prop.default }
+        %param{ :operation => "create", :href => instances_url, :method => 
"post", :name  => prop.param }
+        - if prop.kind == :range
+          %range{ :first => prop.first, :last => prop.last }/
+        - elsif prop.kind == :enum
+          %enum
+            - prop.values.each do |v|
+              %entry{ :value => v }/
-- 
1.6.6.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to