2017-09-25 4 views
0

SoftLayer API를 사용하여 개발 VM을 설정하고 해체합니다. 이러한 VM의 Ping 모니터 자동 설정은 상태에 대한 불필요한 메시지를 보내고 있습니다. 특정 VM에 대한 모니터를 SoftLayer API를 통해, 특히 Python을 통해 제거하는 방법이 있습니까? 문서를 살펴 봤는데 모니터를 추가/제거하는 방법이 보이지 않습니다.Softlayer API - 모니터 제거

답변

0

""" 
Delete network monitoring 

The script makes a single call to SoftLayer_Network_Monitor_Version1_Query_Host::deleteObject 
method to delete the network monitoring for more information see below 

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

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 network monitor you wish to delete 
to get the network monitorings on your machine use this code: 
virtualGuestService = client['SoftLayer_Virtual_Guest'] 
virtualGuestId = 7698842 
networkMonitors = virtualGuestService.getNetworkMonitors(id = virtualGuestId) 
print (networkMonitors) 
""" 
idNetworkMonitoringToDelete = 1738019 

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

# Send the request to delete the object 
try: 
    result = networkMonitorVersionService.deleteObject(id=idNetworkMonitoringToDelete) 
    pp(result) 
except SoftLayer.SoftLayerAPIError as e: 
    print("Unable to delete the network monitoring " 
      % (e.faultCode, e.faultString)) 
    exit(1) 
+0

가 완벽하게 작동이 코드를 참조하십시오. 감사! –

관련 문제