使用SoftLayer Ruby API将虚拟服务器与特定的其他磁盘一起使用时出错 [英] Error when using SoftLayer Ruby API to specific additional disks with a virtual server

查看:36
本文介绍了使用SoftLayer Ruby API将虚拟服务器与特定的其他磁盘一起使用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们看到与本文中的SoftLayer Ruby API相同的问题:

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

CLI-使用磁盘参数时出错

此代码可以重现该问题:

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

导致此错误:

/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>'

我知道API不允许您指定磁盘,但是您可以通过SoftLayer门户使用图像模板来执行此操作,那么有什么方法可以通过API来做到这一点?

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?

推荐答案

您看到的是相同的错误,因为在两种情况下,您都使用了

You are seeing the same error, because in both cases you are using the createObject method to create the VSI.

如果您查看文档,将会看到以下内容:

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

blockDevices

blockDevices

用于计算的块设备和磁盘映像设置 instance Optional Type-的数组 [[SoftLayer_Virtual_Guest_Block_Device (类型)| SoftLayer_Virtual_Guest_Block_Device]]

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

注意:当指定映像模板时,磁盘容量将由模板提供".

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

门户网站使用另一种方法来创建允许更多选项的订单,但是缺点是创建订单并不容易.您可以查看有关该方法的更多信息在此处,本文将向您展示使用在softlayer中订购设备的基础知识placeOrder 方法.基本上,在您的情况下,使用placeOrder方法,您只需要指定所需磁盘的价格以及图像模板即可.

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 here, the article will show you the basics to order devices in softlayer using the placeOrder 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

这篇关于使用SoftLayer Ruby API将虚拟服务器与特定的其他磁盘一起使用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆