I am new to the softlayer rest APIs. We have a requirement where user will be allowed to add a additional SAN or Local Disk to the existing provisioned server in softlayer. For that I was referring to the 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. But none of these links helped me. Are there any ruby examples for adding a disk
?
Please try the following example to 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
Note: Once your script is ready, please change from verifyOrder
to placeOrder
.
To get valid prices for upgrade, please review:
SoftLayer_Virtual_Guest::getUpgradeItemPrices
References: