You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:43:16 UTC

svn commit: r962283 - /incubator/deltacloud/trunk/server/lib/deltacloud/hardware_profile.rb

Author: lutter
Date: Thu Jul  8 23:43:16 2010
New Revision: 962283

URL: http://svn.apache.org/viewvc?rev=962283&view=rev
Log:
Hardware profiles: produce parameters

For any dimension that is not fixed in a HWP, produce a parameter
describing what's acceptable for this dimension, e.g. in a create instance
operation.

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/hardware_profile.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/hardware_profile.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/hardware_profile.rb?rev=962283&r1=962282&r2=962283&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/hardware_profile.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/hardware_profile.rb Thu Jul  8 23:43:16 2010
@@ -52,6 +52,17 @@ module Deltacloud
       def fixed?
         kind == :fixed
       end
+
+      def to_param
+        return nil if kind == :fixed
+        if kind == :range
+          # FIXME: We can't validate ranges currently
+          args = [param, :string, :optional]
+        else
+          args = [param, :string, :optional, values.collect { |v| v.to_s} ]
+        end
+        Validation::Param.new(args)
+      end
     end
 
     class << self
@@ -95,5 +106,11 @@ module Deltacloud
       p = @properties[prop.to_sym]
       p && p.default.to_s == v
     end
+
+    def params
+      @properties.values.inject([]) { |m, prop|
+        m << prop.to_param
+      }.compact
+    end
   end
 end