From: David Lutterkort lutter@redhat.com
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. --- server/lib/deltacloud/hardware_profile.rb | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/server/lib/deltacloud/hardware_profile.rb b/server/lib/deltacloud/hardware_profile.rb index 6c0605b..e7eaf8b 100644 --- a/server/lib/deltacloud/hardware_profile.rb +++ b/server/lib/deltacloud/hardware_profile.rb @@ -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