我是softlayer rest API的新手。我们要求允许用户在softlayer中向现有的配置服务器添加额外的SAN或本地磁盘。为此,我指的是REST API guide我们的项目建立在Ruby on Rails
上,我们正在使用softlayer_api
gem,因此我正在查看api ruby doc。但这些链接都没有帮助我。 adding a disk
是否有任何红宝石示例?
答案 0 :(得分:0)
请尝试以下示例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
<强>参考文献:强>