本文整理汇总了Python中hm.model.load_balancer.LoadBalancer.list方法的典型用法代码示例。如果您正苦于以下问题:Python LoadBalancer.list方法的具体用法?Python LoadBalancer.list怎么用?Python LoadBalancer.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hm.model.load_balancer.LoadBalancer
的用法示例。
在下文中一共展示了LoadBalancer.list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from hm.model.load_balancer import LoadBalancer [as 别名]
# 或者: from hm.model.load_balancer.LoadBalancer import list [as 别名]
def run(self, config):
self.init_config(config)
session_resumption_rotate = int(self.config.get("SESSION_RESUMPTION_TICKET_ROTATE", 3600))
instances_to_rotate = self.config.get("SESSION_RESUMPTION_INSTANCES", None)
service_name = self.config.get("RPAAS_SERVICE_NAME", "rpaas")
service_instance_lock = "session_resumption:{}:instance".format(service_name)
instance_lock = self.config.get("SESSION_RESUMPTION_INSTANCE_LOCK_PREFIX", service_instance_lock)
if instances_to_rotate:
instances_to_rotate = instances_to_rotate.split(",")
lb_data = LoadBalancer.list(conf=self.config)
for lb in lb_data:
if instances_to_rotate and lb.name not in instances_to_rotate:
continue
lock_name = "{}:{}".format(instance_lock, lb.name)
if self.lock_manager.lock(lock_name, session_resumption_rotate):
try:
self.rotate_session_ticket(lb.hosts)
except Exception as e:
logging.error("Error renewing session ticket for {}: {}".format(lb.name, repr(e)))
finally:
self.lock_manager.unlock(lock_name)