示例#1
0
文件: responses.py 项目: ZuluPro/moto
    def modify_load_balancer_attributes(self):
        load_balancer_name = self._get_param('LoadBalancerName')
        load_balancer = self.elb_backend.get_load_balancer(load_balancer_name)

        cross_zone = self._get_dict_param("LoadBalancerAttributes.CrossZoneLoadBalancing.")
        if cross_zone:
            attribute = CrossZoneLoadBalancingAttribute()
            attribute.enabled = cross_zone["enabled"] == "true"
            self.elb_backend.set_cross_zone_load_balancing_attribute(load_balancer_name, attribute)

        access_log = self._get_dict_param("LoadBalancerAttributes.AccessLog.")
        if access_log:
            attribute = AccessLogAttribute()
            attribute.enabled = access_log["enabled"] == "true"
            attribute.s3_bucket_name = access_log['s3_bucket_name']
            attribute.s3_bucket_prefix = access_log['s3_bucket_prefix']
            attribute.emit_interval = access_log["emit_interval"]
            self.elb_backend.set_access_log_attribute(load_balancer_name, attribute)

        connection_draining = self._get_dict_param("LoadBalancerAttributes.ConnectionDraining.")
        if connection_draining:
            attribute = ConnectionDrainingAttribute()
            attribute.enabled = connection_draining["enabled"] == "true"
            attribute.timeout = connection_draining["timeout"]
            self.elb_backend.set_connection_draining_attribute(load_balancer_name, attribute)

        connection_settings = self._get_dict_param("LoadBalancerAttributes.ConnectionSettings.")
        if connection_settings:
            attribute = ConnectionSettingAttribute()
            attribute.idle_timeout = connection_settings["idle_timeout"]
            self.elb_backend.set_connection_settings_attribute(load_balancer_name, attribute)

        template = self.response_template(MODIFY_ATTRIBUTES_TEMPLATE)
        return template.render(attributes=load_balancer.attributes)
示例#2
0
    def modify_load_balancer_attributes(self):
        load_balancer_name = self._get_param('LoadBalancerName')
        load_balancer = self.elb_backend.get_load_balancer(load_balancer_name)

        cross_zone = self._get_dict_param("LoadBalancerAttributes.CrossZoneLoadBalancing.")
        if cross_zone:
            attribute = CrossZoneLoadBalancingAttribute()
            attribute.enabled = cross_zone["enabled"] == "true"
            self.elb_backend.set_cross_zone_load_balancing_attribute(load_balancer_name, attribute)

        access_log = self._get_dict_param("LoadBalancerAttributes.AccessLog.")
        if access_log:
            attribute = AccessLogAttribute()
            attribute.enabled = access_log["enabled"] == "true"
            attribute.s3_bucket_name = access_log['s3_bucket_name']
            attribute.s3_bucket_prefix = access_log['s3_bucket_prefix']
            attribute.emit_interval = access_log["emit_interval"]
            self.elb_backend.set_access_log_attribute(load_balancer_name, attribute)

        connection_draining = self._get_dict_param("LoadBalancerAttributes.ConnectionDraining.")
        if connection_draining:
            attribute = ConnectionDrainingAttribute()
            attribute.enabled = connection_draining["enabled"] == "true"
            attribute.timeout = connection_draining["timeout"]
            self.elb_backend.set_connection_draining_attribute(load_balancer_name, attribute)

        connection_settings = self._get_dict_param("LoadBalancerAttributes.ConnectionSettings.")
        if connection_settings:
            attribute = ConnectionSettingAttribute()
            attribute.idle_timeout = connection_settings["idle_timeout"]
            self.elb_backend.set_connection_settings_attribute(load_balancer_name, attribute)

        template = self.response_template(MODIFY_ATTRIBUTES_TEMPLATE)
        return template.render(attributes=load_balancer.attributes)
示例#3
0
    def modify_load_balancer_attributes(self):
        load_balancer_name = self.querystring.get('LoadBalancerName')[0]
        load_balancer = self.elb_backend.describe_load_balancers(
            load_balancer_name)[0]

        def parse_attribute(attribute_name):
            """
            Transform self.querystring parameters matching `LoadBalancerAttributes.attribute_name.attribute_key`
            into a dictionary of (attribute_name, attribute_key)` pairs.
            """
            attribute_prefix = "LoadBalancerAttributes." + attribute_name
            return dict((key.lstrip(attribute_prefix), value[0])
                        for key, value in self.querystring.items()
                        if key.startswith(attribute_prefix))

        cross_zone = parse_attribute("CrossZoneLoadBalancing")
        if cross_zone:
            attribute = CrossZoneLoadBalancingAttribute()
            attribute.enabled = cross_zone["Enabled"] == "true"
            self.elb_backend.set_cross_zone_load_balancing_attribute(
                load_balancer_name, attribute)

        access_log = parse_attribute("AccessLog")
        if access_log:
            attribute = AccessLogAttribute()
            attribute.enabled = access_log["Enabled"] == "true"
            attribute.s3_bucket_name = access_log["S3BucketName"]
            attribute.s3_bucket_prefix = access_log["S3BucketPrefix"]
            attribute.emit_interval = access_log["EmitInterval"]
            self.elb_backend.set_access_log_attribute(load_balancer_name,
                                                      attribute)

        connection_draining = parse_attribute("ConnectionDraining")
        if connection_draining:
            attribute = ConnectionDrainingAttribute()
            attribute.enabled = connection_draining["Enabled"] == "true"
            attribute.timeout = connection_draining["Timeout"]
            self.elb_backend.set_connection_draining_attribute(
                load_balancer_name, attribute)

        connection_settings = parse_attribute("ConnectionSettings")
        if connection_settings:
            attribute = ConnectionSettingAttribute()
            attribute.idle_timeout = connection_settings["IdleTimeout"]
            self.elb_backend.set_connection_settings_attribute(
                load_balancer_name, attribute)

        template = self.response_template(MODIFY_ATTRIBUTES_TEMPLATE)
        return template.render(attributes=load_balancer.attributes)
示例#4
0
文件: responses.py 项目: deuxpi/moto
    def modify_load_balancer_attributes(self):
        load_balancer_name = self.querystring.get('LoadBalancerName')[0]
        load_balancer = self.elb_backend.describe_load_balancers(load_balancer_name)[0]

        def parse_attribute(attribute_name):
            """
            Transform self.querystring parameters matching `LoadBalancerAttributes.attribute_name.attribute_key`
            into a dictionary of (attribute_name, attribute_key)` pairs.
            """
            attribute_prefix = "LoadBalancerAttributes." + attribute_name
            return dict((key.lstrip(attribute_prefix), value[0]) for key, value in self.querystring.items() if key.startswith(attribute_prefix))

        cross_zone = parse_attribute("CrossZoneLoadBalancing")
        if cross_zone:
            attribute = CrossZoneLoadBalancingAttribute()
            attribute.enabled = cross_zone["Enabled"] == "true"
            self.elb_backend.set_cross_zone_load_balancing_attribute(load_balancer_name, attribute)

        access_log = parse_attribute("AccessLog")
        if access_log:
            attribute = AccessLogAttribute()
            attribute.enabled = access_log["Enabled"] == "true"
            attribute.s3_bucket_name = access_log["S3BucketName"]
            attribute.s3_bucket_prefix = access_log["S3BucketPrefix"]
            attribute.emit_interval = access_log["EmitInterval"]
            self.elb_backend.set_access_log_attribute(load_balancer_name, attribute)

        connection_draining = parse_attribute("ConnectionDraining")
        if connection_draining:
            attribute = ConnectionDrainingAttribute()
            attribute.enabled = connection_draining["Enabled"] == "true"
            attribute.timeout = connection_draining["Timeout"]
            self.elb_backend.set_connection_draining_attribute(load_balancer_name, attribute)

        connection_settings = parse_attribute("ConnectionSettings")
        if connection_settings:
            attribute = ConnectionSettingAttribute()
            attribute.idle_timeout = connection_settings["IdleTimeout"]
            self.elb_backend.set_connection_settings_attribute(load_balancer_name, attribute)

        template = self.response_template(MODIFY_ATTRIBUTES_TEMPLATE)
        return template.render(attributes=load_balancer.attributes)