我想知道负载均衡器将流量分配给的服务器的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,主机名和域名)属于负载均衡器。