我想知道負載均衡器將流量分配給的服務器的ID。Softlayer API獲取負載均衡器destinationIpAddress
我們已經嘗試了一些概述了以下問題的電話,但似乎沒有能夠找到一種方法來列出服務器。
softlayer local Load Balancer manage API
是否有可能得到負載平衡器分發流量的服務器列表?謝謝!
我想知道負載均衡器將流量分配給的服務器的ID。Softlayer API獲取負載均衡器destinationIpAddress
我們已經嘗試了一些概述了以下問題的電話,但似乎沒有能夠找到一種方法來列出服務器。
softlayer local Load Balancer manage API
是否有可能得到負載平衡器分發流量的服務器列表?謝謝!
,可以獲取負載平衡器分發流量的服務器列表,使用下一個REST請求,或者您可以使用此python腳本,以及:
https://$username:[email protected]/rest/v3/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/$loadBalancerId/getVirtualServers.json?objectMask=mask[serviceGroups[services[ipAddress[virtualGuest]]]]
Method: GET
Python腳本
"""
Retrieve the servers that a load balancer is distributing traffic to.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/getVirtualServers
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
import json
# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'
loadBalancerId = 79945
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
loadBalancerService = client['SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress']
objectMask = 'mask[serviceGroups[id,services[id,ipAddress[virtualGuest]]]]'
try:
virtualServers = loadBalancerService.getVirtualServers(mask=objectMask, id=loadBalancerId)
print(json.dumps(virtualServers, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
print("Unable to retrieve Virtual Servers. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
exit(1)
試試這個:
https://$username:[email protected]/rest/v3/SoftLayer_Network_Application_Delivery_Controller_LoadBalancer_VirtualIpAddress/$loadBalancerId/getVirtualServers.json?objectMask=mask[id,serviceGroups[id,services[id,ipAddress[id,virtualGuest[id,hostname,domain]]]]]
Method: Get
它將提供虛擬客人(ID,主機名和域名)屬於負載均衡器。