瀏覽代碼

update addBackendServers

liqian 2 年之前
父節點
當前提交
94700f311c
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      rov-sever/server/ess-instance-rov-server.py

+ 6 - 4
rov-sever/server/ess-instance-rov-server.py

@@ -148,10 +148,12 @@ def addBackendServers(slb_id, instance_id):
     request.set_accept_format('json')
     ipaddr = getIpaddr(instance_id)
     request.set_LoadBalancerId(slb_id)
-
-    request.set_BackendServers([{"ServerId": instance_id, "Weight": "100", "Type": "ecs", "ServerIp": ipaddr}])
-    response = client.do_action_with_exception(request)
-    logging.info(response)
+    for i in range(1, 6):
+        weight = i * 20
+        request.set_BackendServers([{"ServerId": instance_id, "Weight": weight, "Type": "ecs", "ServerIp": ipaddr}])
+        response = client.do_action_with_exception(request)
+        logging.info(response)
+        time.sleep(5)
 
 
 def getIpaddr(instance_id):