当前位置: 首页>>代码示例>>Python>>正文


Python ELBConnection.get_lb_attribute方法代码示例

本文整理汇总了Python中boto.ec2.elb.ELBConnection.get_lb_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python ELBConnection.get_lb_attribute方法的具体用法?Python ELBConnection.get_lb_attribute怎么用?Python ELBConnection.get_lb_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.ec2.elb.ELBConnection的用法示例。


在下文中一共展示了ELBConnection.get_lb_attribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ELBConnectionTest

# 需要导入模块: from boto.ec2.elb import ELBConnection [as 别名]
# 或者: from boto.ec2.elb.ELBConnection import get_lb_attribute [as 别名]

#.........这里部分代码省略.........
        )

        balancers = self.conn.get_all_load_balancers(
            load_balancer_names=[self.name]
        )
        self.assertEqual([lb.name for lb in balancers], [self.name])
        self.assertEqual(
            sorted(l.get_complex_tuple() for l in balancers[0].listeners),
            # We need an extra 'HTTP' here over what ``self.listeners`` uses.
            sorted([(80, 8000, 'HTTP', 'HTTP')] + complex_listeners)
        )

    def test_load_balancer_access_log(self):
        attributes = self.balancer.get_attributes()

        self.assertEqual(False, attributes.access_log.enabled)

        attributes.access_log.enabled = True
        attributes.access_log.s3_bucket_name = self.bucket_name
        attributes.access_log.s3_bucket_prefix = 'access-logs'
        attributes.access_log.emit_interval = 5

        self.conn.modify_lb_attribute(self.balancer.name, 'accessLog',
                                      attributes.access_log)

        new_attributes = self.balancer.get_attributes()

        self.assertEqual(True, new_attributes.access_log.enabled)
        self.assertEqual(self.bucket_name,
            new_attributes.access_log.s3_bucket_name)
        self.assertEqual('access-logs',
            new_attributes.access_log.s3_bucket_prefix)
        self.assertEqual(5, new_attributes.access_log.emit_interval)

    def test_load_balancer_get_attributes(self):
        attributes = self.balancer.get_attributes()
        connection_draining = self.conn.get_lb_attribute(self.balancer.name,
                                                         'ConnectionDraining')
        self.assertEqual(connection_draining.enabled,
                         attributes.connection_draining.enabled)
        self.assertEqual(connection_draining.timeout,
                         attributes.connection_draining.timeout)

        access_log = self.conn.get_lb_attribute(self.balancer.name,
                                                'AccessLog')
        self.assertEqual(access_log.enabled, attributes.access_log.enabled)
        self.assertEqual(access_log.s3_bucket_name, attributes.access_log.s3_bucket_name)
        self.assertEqual(access_log.s3_bucket_prefix, attributes.access_log.s3_bucket_prefix)
        self.assertEqual(access_log.emit_interval, attributes.access_log.emit_interval)

        cross_zone_load_balancing = self.conn.get_lb_attribute(self.balancer.name,
                                                'CrossZoneLoadBalancing')
        self.assertEqual(cross_zone_load_balancing,
                         attributes.cross_zone_load_balancing.enabled)

    def change_and_verify_load_balancer_connection_draining(self, enabled, timeout = None):
        attributes = self.balancer.get_attributes()

        attributes.connection_draining.enabled = enabled
        if timeout != None:
            attributes.connection_draining.timeout = timeout

	self.conn.modify_lb_attribute(self.balancer.name,
                                      'ConnectionDraining', attributes.connection_draining)

        attributes = self.balancer.get_attributes()
        self.assertEqual(enabled, attributes.connection_draining.enabled)
        if timeout != None:
            self.assertEqual(timeout, attributes.connection_draining.timeout)

    def test_load_balancer_connection_draining_config(self):
    	self.change_and_verify_load_balancer_connection_draining(True, 128)
    	self.change_and_verify_load_balancer_connection_draining(True, 256)
    	self.change_and_verify_load_balancer_connection_draining(False)
    	self.change_and_verify_load_balancer_connection_draining(True, 64) 

    def test_set_load_balancer_policies_of_listeners(self):
        more_listeners = [(443, 8001, 'HTTP')]
        self.conn.create_load_balancer_listeners(self.name, more_listeners)

        lb_policy_name = 'lb-policy'
        self.conn.create_lb_cookie_stickiness_policy(
            1000,
            self.name,
            lb_policy_name
        )
        self.conn.set_lb_policies_of_listener(
            self.name,
            self.listeners[0][0],
            lb_policy_name
        )

        # Try to remove the policy by passing empty list.
        # http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerPoliciesOfListener.html
        # documents this as the way to remove policies.
        self.conn.set_lb_policies_of_listener(
            self.name,
            self.listeners[0][0],
            []
        )
开发者ID:AlexanderNapierski,项目名称:boto,代码行数:104,代码来源:test_connection.py


注:本文中的boto.ec2.elb.ELBConnection.get_lb_attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。