将 SAN 或本地磁盘添加到 Softlayer 中已配置的服务器

Add SAN or Local disk to already provisioned Server in Softlayer

我是 softlayer rest API 的新手。我们有一个要求,允许用户将额外的 SAN 或本地磁盘添加到软层中的现有配置服务器。为此,我指的是 REST API guide Our project is build on Ruby on Rails and we are using softlayer_api gem and so I was looking at the api ruby doc。但是这些链接中的 none 帮助了我。 adding a disk 是否有任何 ruby 示例?

请尝试以下示例 upgrade a Virtual Guest in order to add a disk:

require 'rubygems'
require 'softlayer_api'

# Your SoftLayer API username.
SL_API_USERNAME = 'set me'

# Your SoftLayer API key.
SL_API_KEY = 'set me'


# Set the server id that you wish to upgrade.
server_id = 17850400

# Set the new item price id to upgrade the VSI
price_id = 51733  # 10 GB (SAN) "categoryCode": "guest_disk1", "name": "Second Disk"

# Order Template with all new item configurations
object_template = {'packageId'=> 0,
                   'prices'=> [
                       {
                           'id'=> price_id
                       }
                   ],
                   'virtualGuests'=> [
                       {
                           'id'=> server_id
                       }
                   ],
                   'properties'=> [
                       {
                           'name'=> 'NOTE_GENERAL',
                           'value'=> 'Adding a SAN disk'
                       },
                       {
                           'name'=> 'MAINTENANCE_WINDOW',
                           'value'=> 'now'
                       }
                   ],
                   'complexType'=> 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade'
}

softlayer_client = SoftLayer::Client.new(:username => SL_API_USERNAME,
                                         :api_key => SL_API_KEY)
product_order_service = softlayer_client.service_named('SoftLayer_Product_Order')

begin
  result = product_order_service.verifyOrder(object_template)
  puts 'Result:  '
  puts result.inspect
rescue Exception => e
  puts 'Unable to add the new SAN Disk ...'
  $stdout.print(e.inspect)
end

注意:脚本准备就绪后,请将 verifyOrder 更改为 placeOrder

要获得有效的升级价格,请查看:

SoftLayer_Virtual_Guest::getUpgradeItemPrices

参考文献:

SoftLayer_Product_Order

SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade

upgrade_examples