本文整理匯總了Python中boto.ec2.autoscale.AutoScaleConnection.desired_capacity方法的典型用法代碼示例。如果您正苦於以下問題:Python AutoScaleConnection.desired_capacity方法的具體用法?Python AutoScaleConnection.desired_capacity怎麽用?Python AutoScaleConnection.desired_capacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類boto.ec2.autoscale.AutoScaleConnection
的用法示例。
在下文中一共展示了AutoScaleConnection.desired_capacity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from boto.ec2.autoscale import AutoScaleConnection [as 別名]
# 或者: from boto.ec2.autoscale.AutoScaleConnection import desired_capacity [as 別名]
def main():
"""
Main entry point for the automated scaling daemon.
"""
# Configure logging.
logging.basicConfig(
format = "%(asctime)-15s %(levelname)5s %(message)s",
level = logging.INFO
)
# Read configuration.
options = yaml.load(open("config.yaml"))
# Connect to the RabbitMQ cluster.
params = pika.ConnectionParameters(host=options["amqp"])
conn = pika.BlockingConnection(params)
channel = conn.channel()
while True:
# Ensure that we have things stuck in the queue for the given amount
# of time.
for i in xrange(DELAY / 5):
queue_length = get_queue_length(channel, "stable")
logging.info("Queue length: {}".format(queue_length))
if queue_length == 0:
break
time.sleep(5)
else:
# Scale up!
group = AutoScaleConnection().get_all_groups(["LSDA Worker Pool"])[0]
group.desired_capacity = min(
group.desired_capacity + 2, group.max_size)
group.update()
logging.info(
"Triggering increase to {}".format(group.desired_capacity))
time.sleep(300)
# Wait until next polling event.
time.sleep(30)