Softlayer API 获取负载均衡器 destinationIpAddress
Softlayer API get load balancer destinationIpAddress
我想找出负载均衡器正在向其分配流量的服务器的 ID。
我们已经对以下问题中概述的一些调用进行了试验,但似乎无法找到列出服务器的方法。
softlayer local Load Balancer manage API
是否可以获取负载均衡器将流量分配到的服务器列表?谢谢!
您可以使用下一个 REST 请求获取负载均衡器将流量分配到的服务器列表,或者您也可以使用此 python 脚本:
https://$username:$apiKey@api.softlayer.com/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. <sldn@softlayer.com>
"""
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:$apiKey@api.softlayer.com/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、主机名和域)。
我想找出负载均衡器正在向其分配流量的服务器的 ID。
我们已经对以下问题中概述的一些调用进行了试验,但似乎无法找到列出服务器的方法。
softlayer local Load Balancer manage API
是否可以获取负载均衡器将流量分配到的服务器列表?谢谢!
您可以使用下一个 REST 请求获取负载均衡器将流量分配到的服务器列表,或者您也可以使用此 python 脚本:
https://$username:$apiKey@api.softlayer.com/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. <sldn@softlayer.com>
"""
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:$apiKey@api.softlayer.com/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、主机名和域)。