我是softlayer rest API的新手。我们有一个要求,其中允许用户向软层中的现有预配置服务器添加额外的SAN或本地磁盘。为此,我指的是REST API指南。我们的项目是建立在Ruby on Rails
我们之上的,并且我们使用的是softlayer_api
gem,所以我一直在看api ruby doc。但是这些链接都没有帮助我。有红宝石的例子adding a disk
吗?
请尝试以下示例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
参考:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句