2017-03-20 2 views
0

Softlayer API를 통해 모니터링 패키지를 추가 할 수 있습니까? 포털에서 모니터링 섹션으로 가서 "모니터링 패키지 - 기본"을 주문하면 가상 게스트와 연관시킬 수 있습니다.API를 통해 가상 게스트에 기본 모니터링 패키지 추가

placeOrder 호출 중에 또는 초기 placeOrder 호출 후에 (즉, 고객이 서버를 프로비저닝 한 후 기본 모니터링을 추가하려는 경우)이 작업을 수행 할 수 있습니까?

예제를 살펴 보았지만 사용할 수있는 모니터링 에이전트가 있다고 가정했지만 모두 내 경우에는 그렇지 않았습니다. 또한 Going Further with Softlayer part 3을 살펴 보았지만 Product_Package Service에서 기본 모니터링 패키지를 추출하는 방법을 모르겠습니다.

필자는 이것을 수행하기 위해 Python을 사용하므로 만들기 또는 생성 후 모니터링 서비스를 연결하는 데 도움이 될 것입니다.

미리 감사드립니다.

답변

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

경우에 대비해 서비스 핑을 사용하여 네트워크 모니터링을 만드는 또 다른 예제를 추가했을 수도 있습니다. –

관련 문제