softlayer / softlayer-ruby

http://softlayer.github.io/softlayer-ruby/
MIT License
54 stars 35 forks source link

NoMethodError: undefined method `capacity_restriction_maximum=' #103

Closed huskercane closed 8 years ago

huskercane commented 8 years ago

Using softlayer_api (3.1.0)

NoMethodError: undefined method capacity_restriction_maximum=' for #<SoftLayer::ProductConfigurationOption:0x0000000325b2c0> /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:40:ininitialize' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:114:in new' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:114:inblock (4 levels) in class:ProductItemCategory' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:113:in collect' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:113:inblock (3 levels) in class:ProductItemCategory' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:112:in collect' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:112:inblock (2 levels) in class:ProductItemCategory' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/DynamicAttribute.rb:138:in block in sl_dynamic_attr' /home/rohits/.rvm/gems/ruby-2.2.1@global/gems/softlayer_api-3.1.0/lib/softlayer/ProductItemCategory.rb:138:indefault_option' ./lib/sliwdautomation/esxi.rb:147:in `block in build_config_base'

huskercane commented 8 years ago

Scott thank you for the help.

did U fix the problem or U want me to make change?

Since I do not call any of this method

this is the code that runs into this error require 'softlayer_api' require 'pp'

@client = SoftLayer::Client.new packages = SoftLayer::ProductPackage.bare_metal_server_packages(@client)

packages.each { |package| puts "#{package.id}\t#{package.name}" }

package_ids = packages.map &:id # { |pacakge| pacakge.id }

server and ram

File.open('/tmp/prices.txt', 'w') do |f| package_ids.each do |packageid| f.puts "\n============================" f.puts packageid f.puts '============================'

packageid = package.id

sl_bm_package = SoftLayer::ProductPackage.package_with_id(packageid, @client)

# Now we need to now what ProductItemCategories are required to
# configure a server in that package. This code prints out a table
# of the required category codes with a description of each
f.puts "\nRequired Categories for '#{sl_bm_package.name}':"
required_categories = sl_bm_package.configuration.select { |x| x.name.to_s.downcase == 'server' || x.name.to_s.downcase == 'ram' }
# puts required_categories.size()
# pp required_categories

required_categories.each do |category|
  config_options = category.configuration_options
  f.puts "\nConfiguration options in the '#{category.name}' category:"
  config_options.each { |option| f.printf "%5s\t#{option.description}\n", option.price_id }
end
f.fsync

end end

code print out all packages and cpu/ram details

SLsthompson commented 8 years ago

I apologize. I had responded while looking at an older version of the code. Then I realized my mistake and deleted my comment. Then I fixed the problem and released a 3.1.1 release with the fix. If you gem update softlayer_api, you should get the 3.1.1 build with the bug fix.

huskercane commented 8 years ago

As always you are great

yep it did fix problem that I encountered. Thank you