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


Python CloudWatchConnection.build_put_params方法代码示例

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


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

示例1: test_build_put_params_invalid

# 需要导入模块: from boto.ec2.cloudwatch import CloudWatchConnection [as 别名]
# 或者: from boto.ec2.cloudwatch.CloudWatchConnection import build_put_params [as 别名]
 def test_build_put_params_invalid(self):
     c = CloudWatchConnection()
     params = {}
     try:
         c.build_put_params(params, name=["N", "M"], value=[1, 2, 3])
     except:
         pass
     else:
         self.fail("Should not accept lists of different lengths.")
开发者ID:der4im,项目名称:boto,代码行数:11,代码来源:test_connection.py

示例2: test_build_put_params_one

# 需要导入模块: from boto.ec2.cloudwatch import CloudWatchConnection [as 别名]
# 或者: from boto.ec2.cloudwatch.CloudWatchConnection import build_put_params [as 别名]
 def test_build_put_params_one(self):
     c = CloudWatchConnection()
     params = {}
     c.build_put_params(params, name="N", value=1, dimensions={"D": "V"})
     expected_params = {
         'MetricData.member.1.MetricName': 'N',
         'MetricData.member.1.Value': 1,
         'MetricData.member.1.Dimensions.member.1.Name': 'D',
         'MetricData.member.1.Dimensions.member.1.Value': 'V',
         }
     self.assertEqual(params, expected_params)
开发者ID:der4im,项目名称:boto,代码行数:13,代码来源:test_connection.py

示例3: test_build_put_params_multiple_dimensions

# 需要导入模块: from boto.ec2.cloudwatch import CloudWatchConnection [as 别名]
# 或者: from boto.ec2.cloudwatch.CloudWatchConnection import build_put_params [as 别名]
 def test_build_put_params_multiple_dimensions(self):
     c = CloudWatchConnection()
     params = {}
     c.build_put_params(params, name="N", value=[1, 2], dimensions=[{"D": "V"}, {"D": "W"}])
     expected_params = {
         'MetricData.member.1.MetricName': 'N',
         'MetricData.member.1.Value': 1,
         'MetricData.member.1.Dimensions.member.1.Name': 'D',
         'MetricData.member.1.Dimensions.member.1.Value': 'V',
         'MetricData.member.2.MetricName': 'N',
         'MetricData.member.2.Value': 2,
         'MetricData.member.2.Dimensions.member.1.Name': 'D',
         'MetricData.member.2.Dimensions.member.1.Value': 'W',
         }
     self.assertEqual(params, expected_params)
开发者ID:der4im,项目名称:boto,代码行数:17,代码来源:test_connection.py

示例4: test_build_put_params_multiple_metrics

# 需要导入模块: from boto.ec2.cloudwatch import CloudWatchConnection [as 别名]
# 或者: from boto.ec2.cloudwatch.CloudWatchConnection import build_put_params [as 别名]
 def test_build_put_params_multiple_metrics(self):
     c = CloudWatchConnection()
     params = {}
     c.build_put_params(params, name=["N", "M"], value=[1, 2], dimensions={"D": "V"})
     expected_params = {
         "MetricData.member.1.MetricName": "N",
         "MetricData.member.1.Value": 1,
         "MetricData.member.1.Dimensions.member.1.Name": "D",
         "MetricData.member.1.Dimensions.member.1.Value": "V",
         "MetricData.member.2.MetricName": "M",
         "MetricData.member.2.Value": 2,
         "MetricData.member.2.Dimensions.member.1.Name": "D",
         "MetricData.member.2.Dimensions.member.1.Value": "V",
     }
     self.assertEqual(params, expected_params)
开发者ID:jeffreywugz,项目名称:boto,代码行数:17,代码来源:test_connection.py

示例5: test_build_put_params_multiple_parameter_dimension

# 需要导入模块: from boto.ec2.cloudwatch import CloudWatchConnection [as 别名]
# 或者: from boto.ec2.cloudwatch.CloudWatchConnection import build_put_params [as 别名]
 def test_build_put_params_multiple_parameter_dimension(self):
     self.maxDiff = None
     c = CloudWatchConnection()
     params = {}
     dimensions = [OrderedDict((("D1", "V"), ("D2", "W")))]
     c.build_put_params(params,
                        name="N",
                        value=[1],
                        dimensions=dimensions)
     expected_params = {
         'MetricData.member.1.MetricName': 'N',
         'MetricData.member.1.Value': 1,
         'MetricData.member.1.Dimensions.member.1.Name': 'D1',
         'MetricData.member.1.Dimensions.member.1.Value': 'V',
         'MetricData.member.1.Dimensions.member.2.Name': 'D2',
         'MetricData.member.1.Dimensions.member.2.Value': 'W',
     }
     self.assertEqual(params, expected_params)
开发者ID:10sr,项目名称:hue,代码行数:20,代码来源:test_connection.py

示例6: EucaELBConnection

# 需要导入模块: from boto.ec2.cloudwatch import CloudWatchConnection [as 别名]
# 或者: from boto.ec2.cloudwatch.CloudWatchConnection import build_put_params [as 别名]
class EucaELBConnection(ELBConnection):
    def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=False, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 security_token=None, validate_certs=True):
        """
        Init method to create a new connection to EC2 Load Balancing Service.

        note:: The region argument is overridden by the region specified in
            the boto configuration file.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region
        self.cw_con = CloudWatchConnection(aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass, debug,
                                    https_connection_factory, region, path,
                                    security_token,
                                    validate_certs=validate_certs)
        ELBConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass, debug,
                                    https_connection_factory, region, path,
                                    security_token,
                                    validate_certs=validate_certs)

    def put_cw_metric(self, servo_instance_id, metric):
        params = {'InstanceId':servo_instance_id}
        namespace = 'Servo'
        name = ['Latency','RequestCount','HTTPCode_ELB_4XX','HTTPCode_ELB_5XX','HTTPCode_Backend_2XX','HTTPCode_Backend_3XX','HTTPCode_Backend_4XX','HTTPCode_Backend_5XX']
        value = [metric.Latency, metric.RequestCount, metric.HTTPCode_ELB_4XX, metric.HTTPCode_ELB_5XX, metric.HTTPCode_Backend_2XX, metric.HTTPCode_Backend_3XX, metric.HTTPCode_Backend_4XX, metric.HTTPCode_Backend_5XX]
        unit = ['Milliseconds','Count','Count','Count','Count','Count','Count','Count']
        self.cw_con.build_put_params(params, name, value=value,timestamp=None, unit=unit, dimensions=None, statistics=None)

        return self.get_status('PutServoStates', params)

    def put_instance_health(self, servo_instance_id, instances):
        """
        Test the internal loadbalancer vms
        """
        params = {'InstanceId':servo_instance_id}
        if instances:
            self.build_list_params(params, instances, 'Instances.member.%d.InstanceId')
        return self.get_status('PutServoStates', params)

    def get_servo_load_balancers(self, servo_instance_id):
        #marker = "servo:%s" % servo_instance_id
        params = {"InstanceId": servo_instance_id}
        lbs = self.get_list('DescribeLoadBalancersByServo', params,
                             [('member', LoadBalancer)])

        for lb in lbs:
            instances = []
            if lb.instances is not None and isinstance(lb.instances, Iterable):
                for inst in lb.instances:
                    inst_id=str(inst.id) 
                    if inst_id.find(':')>=0:
                        token = inst_id.split(':')
                        inst_id=token[0]
                        ipaddr=token[1]
                        hostname_cache.register(inst_id, ipaddr)
                        inst.id = inst_id
 
        return lbs
开发者ID:hnousiainen,项目名称:load-balancer-servo,代码行数:71,代码来源:__init__.py


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