55572

Error when using SoftLayer Ruby API to specific additional disks with a virtual server

Question:

We are seeing same issue with the SoftLayer Ruby API as in this post:

<a href="https://stackoverflow.com/questions/36826483/cli-error-when-disk-parameter-is-in-use" rel="nofollow">CLI - Error when disk parameter is in use</a>

This code can reproduce the issue:

#!/usr/bin/ruby require 'softlayer_api' def image_template_id(sl_client, image_template_name) templates = sl_client['Account'].getBlockDeviceTemplateGroups templates.each do | template | if image_template_name == template['name'] return SoftLayer::ImageTemplate.template_with_id(template['id'], {:client => sl_client}) end end return nil end sl_username = "USER" sl_apikey = "API-KEY" sl_client = SoftLayer::Client.new(username: sl_username, api_key: sl_apikey) server_order = SoftLayer::VirtualServerOrder.new(sl_client) server_order.hostname = "test" server_order.domain = "mycompany.com" server_order.datacenter = SoftLayer::Datacenter.datacenter_named("par02", sl_client) server_order.cores = 2 server_order.memory = 4 server_order.image_template = image_template_id(sl_client, "IMAGE NAME") server_order.disks = [100, 100] puts server_order.verify

which results in this in this error:

/usr/share/ruby/xmlrpc/client.rb:414:in `call': Invalid value provided for 'blockDevices'. Block devices may not be provided when using an image template. (XMLRPC::FaultException) from /fs/home/richb/.gem/ruby/1.9.1/gems/softlayer_api-3.0.0/lib/softlayer/Service.rb:281:in `call_softlayer_api_with_params' from /fs/home/richb/.gem/ruby/1.9.1/gems/softlayer_api-3.0.0/lib/softlayer/Service.rb:210:in `method_missing' from /fs/home/richb/.gem/ruby/1.9.1/gems/softlayer_api-3.0.0/lib/softlayer/VirtualServerOrder.rb:122:in `verify' from ./sltest:29:in `<main>'

I understand that the API is not allowing you to specify disks but this is something you can do with an image template via the SoftLayer portal so is there any way to do this via the API?

Answer1:

You are seeing the same error, because in both cases you are using the <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject" rel="nofollow">createObject</a> method to create the VSI.

If you take a look to the docuemntation you will see this:

<blockquote>

blockDevices

Block device and disk image settings for the computing instance Optional Type - array of [[SoftLayer_Virtual_Guest_Block_Device (type)|SoftLayer_Virtual_Guest_Block_Device]]

Default - The smallest available capacity for the primary disk will be used. If an image template is specified the disk capacity will be be provided by the template

</blockquote>

Note: "When an image template is specified the disk capacity will be provided by the template"

The portal uses another method to create the orders which allow more options, but the drawback is that is not so easy to create the orders. You can see more information about that method <a href="http://sldn.softlayer.com/blog/bpotter/going-further-softlayer-api-python-client-part-3" rel="nofollow">here</a>, the article will show you the basics to order devices in softlayer using the <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder" rel="nofollow">placeOrder</a> method. Basically in your case, using the placeOrder method, you just need specify the prices of the disk you want plus the image template.

I hope it helps Regards

Recommend

  • Softlayer filtering not working
  • Detect the version of CloudFoundry/Bluemix
  • How to mock a method in an ENUM class?
  • Spring: Access bean property from another bean
  • Visual Studio Setup Project - Use exe Icon for installed Shortcuts
  • Cassandra Python driver: force using a single node
  • If error happens while creating VM on Azure, where would I find the error log
  • Visio 2010 using a page name in mailto link
  • Jira attach file to issue with PHP and CURL
  • Wait until first async function is completed then execute the second async function
  • Map collection size in Dozer
  • google API calendar watch doesn't work but channel is created
  • Mixing declarative beans and annotated beans: org.hibernate.HibernateException No Session found for
  • Maven: compile a project using shade-plugin specifying main class and properties file
  • How to chain APIs using Azure API management
  • Hyperjaxb @Entity
  • Why am I getting a (401) Unauthorized Error in Google Calendar API
  • Error when using SoftLayer Ruby API to specific additional disks with a virtual server
  • Could not load file or assembly in Visual Studio 2012, C#
  • Datastax cassandra driver giving wrong metadata information about host states
  • Sponsor's Renewal function stops being called
  • Using cookie authentication with bitbucket and curl
  • How would you add maven to an existing GWT project in Eclipse with m2e installed?
  • Trusting X-Forwarded-For to “identify” a visitor
  • How to debug using superdev mode?
  • jaxb xsd prefix package names
  • When to use PDO prepared queries. mysql_real_escape error
  • Ansible: setting user on dynamic ec2
  • How to obtain service credentials for a service instance created on IBM Bluemix without binding the
  • How to autoplay video in angularjs?
  • Laravel Eloquent integration in Codeigniter
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Email verification using google app script and google forms
  • Python urlparse: small issue
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • JSON with duplicate key names losing information when parsed
  • Jquery - Jquery Wysiwyg return html as a string
  • How do you join a server to an Active Directory (domain)?