我可以使用REST API来禁用虚拟访客的默认监控,但我似乎无法在Ruby中使用它。
卷曲示例:
curl -s --user "$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY" -X POST --data @editmonitoring.json "https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/26223285/editObject"
editmonitoring.json文件是
{ "parameters": [
{
"monitoringServiceFlag": "false"
}
]
}
我的Ruby文件是
require 'softlayer_api'
require 'pp'
client = SoftLayer::Client.new(:timeout => 120)
parameters = [
{
'id' => 26223283,
'monitoringServiceFlag' => 'false'
}
]
begin
editMonitoring = client['SoftLayer_Virtual_Guest'].editObject(parameters)
puts editMonitoring
rescue Exception => exception
puts "There is an error in the order: #{exception}"
end
我得到的错误是
$ ruby disablemonitoring.rb
There is an error in the order: Object does not exist to execute method on. (SoftLayer_Virtual_Guest::editObject)
答案 0 :(得分:0)
不幸的是,无法将此标志设置为 monitoringServiceFlag = false ,表示服务器已安装高级监控包,这是设置此标志的唯一方法如果不对,则取消该服务。
如果您的目标是取消此服务,请尝试以下ruby脚本:
# Cancel Advanced Monitoring Package for a VSI
#
# Important manual pages
# http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getObject
# http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item_Cancellation_Request/createObject
#
# License: http://sldn.softlayer.com/article/License
# Author: SoftLayer Technologies, Inc.<sldn@softlayer.com>
require 'softlayer_api'
require 'pp'
# Create connection1
client = SoftLayer::Client.new(:timeout => 120)
# Define your vsi's identifier
vsi_id = 15002321
# Define an object mask to get additional information from monitoring
object_mask = 'mask[billingItem[monitoringBillingItems]]'
begin
# Getting vsi information
vsi_result = client['SoftLayer_Virtual_Guest'].object_mask(object_mask).object_with_id(vsi_id).getObject
# Define template to cancel monitoring billing item
template = {
"accountId" => 112233,
"items"=>[{
"billingItemId"=> vsi_result['billingItem']['monitoringBillingItems'][0]['id'],
"immediateCancellationFlag"=> true
}]
}
# Canceling service
result = client['SoftLayer_Billing_Item_Cancellation_Request'].createObject(template)
puts result
rescue Exception => exception
puts "Error: #{exception}"
end