Browse Source

update addBackendServers

liqian 2 years ago
parent
commit
94700f311c
1 changed files with 6 additions and 4 deletions
  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):