2017-03-20 7 views
0

Softlayer APIを介して監視パッケージを追加することは可能ですか?ポータルでは、Monitoringセクションに行き、 "Monitoring Package - Basic"を注文して、その仮想ゲストに関連付けることができます。API経由で仮想ゲストに基本監視パッケージを追加する

placeOrderコール中、または最初のplaceOrderコールの後でこれを行うことは可能ですか(つまり、サーバーのプロビジョニング後に基本監視を追加する場合)。

私は例を調べようとしましたが、利用可能な監視エージェントがあるとみなしていましたが、私の場合はそれではありませんでした。私もGoing Further with Softlayer part 3を調べましたが、Product_Package Serviceから基本監視パッケージを抽出する方法がわかりません。

私はこれを行うためにPythonを使用しているため、作成中または作成後にMonitoringサービスを関連付ける際の参考になると非常に役に立ちます。

ありがとうございました!

答えて

1

はこれを試してみてください。

""" 
Order a Monitoring Package 

Build a SoftLayer_Container_Product_Order_Monitoring_Package object for a new 
monitoring order and pass it to the SoftLayer_Product_Order API service to order it 
In this care we'll order a Basic (Hardware and OS) package with Basic Monitoring Package - Linux 
configuration for more details see below 

Important manual pages: 
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Monitoring_Package 
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price 
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder 
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder 
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Monitoring_Agent_Configuration_Template_Group 

License: http://sldn.softlayer.com/article/License 
Author: SoftLayer Technologies, Inc. <[email protected]> 
""" 

import SoftLayer 

USERNAME = 'set me' 
API_KEY = 'set me' 

""" 
Build a skeleton SoftLayer_Container_Product_Order_Monitoring_Package object 
containing the order you wish to place. 
""" 
oderTemplate = { 
    'complexType': 'SoftLayer_Container_Product_Order_Monitoring_Package', 
    'packageId': 0, # the packageID for order monitoring packages is 0 
    'prices': [ 
     {'id': 2302} # this is the price for Monitoring Package - Basic ((Hardware and OS)) 
    ], 
    'quantity': 0, # the quantity for order a service (in this case monitoring package) must be 0 
    'sendQuoteEmailFlag': True, 
    'useHourlyPricing': True, 
    'virtualGuests': [ 
     {'id': 4906034} # the virtual guest ID where you want add the monitoring package 
    ], 
    'configurationTemplateGroups': [ 
     {'id': 3} # the templateID for the monitoring group (in this case Basic Monitoring package for Unix/Linux operating system.) 
    ] 
} 

# Declare the API client to use the SoftLayer_Product_Order API service 
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY) 
productOrderService = client['SoftLayer_Product_Order'] 

""" 
verifyOrder() will check your order for errors. Replace this with a call to 
placeOrder() when you're ready to order. Both calls return a receipt object 
that you can use for your records. 

Once your order is placed it'll go through SoftLayer's provisioning process. 
""" 
try: 
    order = productOrderService.verifyOrder(oderTemplate) 
    print(order) 
except SoftLayer.SoftLayerAPIError as e: 
    print("Unable to verify the order! faultCode=%s, faultString=%s" 
      % (e.faultCode, e.faultString)) 
    exit(1) 

これは

""" 
Create network monitoring 

The script creates a monitoring network with Service ping 
in a determinate IP address 

Important manual pages 
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Monitor_Version1_Query_Host 
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Monitor_Version1_Query_Host 

License: http://sldn.softlayer.com/article/License 
Author: SoftLayer Technologies, Inc. <[email protected]> 
""" 
import SoftLayer.API 
from pprint import pprint as pp 

# Your SoftLayer API username and key. 
USERNAME = 'set me' 
API_KEY = 'set me' 


# The ID of the server you wish to monitor 
serverId = 7698842 

""" 
ID of the query type which can be found with SoftLayer_Network_Monitor_Version1_Query_Host_Stratum/getAllQueryTypes. 
This example uses SERVICE PING: Test ping to address, will not fail on slow server response due to high latency or 
high server load 
""" 
queryTypeId = 1 

# IP address on the previously defined server to monitor 
ipAddress = '10.104.50.118' 

# Declare the API client 
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY) 
networkMonitorVersion = client['SoftLayer_Network_Monitor_Version1_Query_Host'] 

# Define the SoftLayer_Network_Monitor_Version1_Query_Host templateObject. 
newMonitor = { 
    'guestId': serverId, 
    'queryTypeId': queryTypeId, 
    'ipAddress': ipAddress 
} 

# Send the request for object creation and display the return value 
try: 
    result = networkMonitorVersion.createObject(newMonitor) 
    pp(result) 
except SoftLayer.SoftLayerAPIError as e: 
    print("Unable to create new network monitoring " 
      % (e.faultCode, e.faultString)) 
    exit(1) 

よろしく

+0

にどうもありがとうを監視ネットワークを作成するための一例です。これを試してみる – rajasaur

+0

サービスのpingを使ってネットワーク監視を作成する別の例を追加した場合には、 –

関連する問題