Browse Source

update setWeight

liqian 2 years ago
parent
commit
a8657f7069
1 changed files with 6 additions and 6 deletions
  1. 6 6
      rov-sever/server/ess-instance-rov-server.py

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

@@ -162,7 +162,7 @@ def setWeight(slb_id, instance_id, weight):
     request.add_query_param('BackendServers', BackendServers)
     request.add_query_param('LoadBalancerId', slb_id)
     try:
-        response = clt.do_action_with_exception(request)
+        response = client.do_action_with_exception(request)
     except Exception as e:
         logging.error(e)
 
@@ -176,11 +176,11 @@ def addBackendServers(slb_id, instance_id):
     request.set_BackendServers([{"ServerId": instance_id, "Weight": "0", "Type": "ecs", "ServerIp": ipaddr}])
     response = client.do_action_with_exception(request)
     logging.info(response)
-    # for i in range(1, 6):
-    #     time.sleep(5)
-    #     weight = i * 20
-    #     logging.info(f"instance_id: {instance_id}, weight: {weight}")
-    #     setWeight(slb_id=slb_id, instance_id=instance_id, weight=weight)
+    for i in range(1, 6):
+        time.sleep(5)
+        weight = i * 20
+        logging.info(f"instance_id: {instance_id}, weight: {weight}")
+        setWeight(slb_id=slb_id, instance_id=instance_id, weight=weight)
 
 
 def getIpaddr(instance_id):