我在Azure(ARM)中配置了一个负载平衡器,我有两个后端池:prod、stage。通过GUI,当我想将一个登台服务器提升到生产环境时,我会将它从暂存池中移除,并将其放入prod池中。我很困惑这一切是如何工作的,因为当我配置堆栈时,我首先配置负载平衡器,当我配置VM将连接到的NIC时,我将该NIC放在我想要的后端池中。但是,当我想将虚拟机移动到另一个池时,我不再在NIC级别这样做了。我必须在负载平衡器上这样做。在
使用pythonsdk,如果查询LB,我可以看到后端池中的NIC,但似乎没有办法修改它。我还可以查询NIC并查看它与哪个后端池关联,但同样,无法修改(从我所能知道的)。到目前为止,我得到的是:
# Create the client
network_client = azure.mgmt.network.NetworkResourceProviderClient(creds)
# Get all LBs
lbs = network_client.load_balancers
# select LB in question
lb = lbs.get(group,'cc-lb01')
# get all pools
pools = lb.load_balancer.backend_address_pools
# set variables for pools
prod = pools[0]
stage = pools[1]
打印输出(dir(stage))为:
^{pr2}$所以当我看到“后端配置”的时候,我觉得我在想什么。当查看我的选项时(通过键入以下内容):
print(stage.backend_ip_configurations)
它返回一个对象数组:
[<azure.mgmt.network.networkresourceprovider.ResourceId object at 0x03C9C090>]
该数组中只有1个项,因此我将该项设置为变量:
beip = stage.backend_ip_configurations[0].id
当我看到我对“beip”的选择时,这就是我的死胡同。在
/subscriptions/xxx-xxx-xxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/app-green04-nic/ipConfigurations/ipconfig1
打印输出(dir(beip))为:
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
我不知道如何查看后端池中的NIC,以及如何修改该池,而不是通过GUI。在
在github上,Hugues在下面的链接中也回答了同样的问题:https://github.com/Azure/azure-sdk-for-python/issues/471
如果其他社区成员有类似的问题,请在此引用答案:
如果您有任何进一步的担心,请随时告诉我们。在
看看这个视频和GitHub repo,它演示了如何通过REST和Python修改池成员资格。在
最后,它是关于获取通过更新发送的正确json
https://mix.office.com/watch/f4cvoa3cnfoe
注意在下面的
/src
路径具有Python版本https://github.com/cicorias/AzureLoadbalancedPoolUpdater
方法和顺序
实际上,您是从NIC的方向而不是从负载平衡器的角度出发。更新(PUT)针对的是“NIC”。在
总的顺序是loadBalancerBackendAddressPools
留空删除这里是通过PUT创建REST请求。在
相关问题 更多 >
编程相关推荐