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


Python ResultSet.append方法代码示例

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


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

示例1: get_all_groups

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]
def get_all_groups(names=None, max_records=None, next_token=None):

    groups = ResultSet()

    for i in xrange(1, 3):
        tags = [
            boto.ec2.autoscale.tag.Tag(
                None,
                key='aws:cloudformation:stack-name',
                value='test{0}'.format(i))
        ]

        asg = AutoScalingGroup()
        asg.name = 'test{0}'.format(i)
        asg.tags = tags
        groups.append(asg)
        groups.next_token = None
    return groups
开发者ID:bennythejudge,项目名称:bootstrap-cfn,代码行数:20,代码来源:test_autoscale.py

示例2: test_resultset_two_next

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]
    def test_resultset_two_next(self):
        e1 = Mock()
        e2 = Mock()
        rs1 = ResultSet()
        rs1.append(e1)
        rs1.append(e2)
        rs1.next_token = 't1'

        e3 = Mock()
        e4 = Mock()
        rs2 = ResultSet()
        rs2.append(e3)
        rs2.append(e4)
        rs2.next_token = 't2'

        e5 = Mock()
        e6 = Mock()
        rs3 = ResultSet()
        rs3.append(e5)
        rs3.append(e6)

        func = Mock()

        results = [rs2, rs3]

        def se_invoke(f, *args, **argv):
            return results.pop(0)

        with patch('%s.invoke_with_throttling_retries' % pbm) as mock_invoke:
            mock_invoke.side_effect = se_invoke
            res = _paginate_resultset(rs1, func, 'foo', bar='barval')
        assert isinstance(res, ResultSet)
        assert len(res) == 6
        assert res[0] == e1
        assert res[1] == e2
        assert res[2] == e3
        assert res[3] == e4
        assert res[4] == e5
        assert res[5] == e6
        assert mock_invoke.mock_calls == [
            call(func, 'foo', bar='barval', next_token='t1'),
            call(func, 'foo', bar='barval', next_token='t2')
        ]
开发者ID:pdecat,项目名称:awslimitchecker,代码行数:45,代码来源:test_utils.py

示例3: test_update_limits_from_api

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]
    def test_update_limits_from_api(self):
        mock_conn = Mock(spec_set=EC2Connection)

        rs = ResultSet()
        a1 = AccountAttribute(connection=mock_conn)
        a1.attribute_name = 'supported-platforms'
        a1.attribute_values = ['EC2', 'VPC']
        rs.append(a1)
        a2 = AccountAttribute(connection=mock_conn)
        a2.attribute_name = 'vpc-max-security-groups-per-interface'
        a2.attribute_values = ['5']
        rs.append(a2)
        a3 = AccountAttribute(connection=mock_conn)
        a3.attribute_name = 'max-elastic-ips'
        a3.attribute_values = ['40']
        rs.append(a3)
        a4 = AccountAttribute(connection=mock_conn)
        a4.attribute_name = 'max-instances'
        a4.attribute_values = ['400']
        rs.append(a4)
        a5 = AccountAttribute(connection=mock_conn)
        a5.attribute_name = 'vpc-max-elastic-ips'
        a5.attribute_values = ['200']
        rs.append(a5)
        a6 = AccountAttribute(connection=mock_conn)
        a6.attribute_name = 'default-vpc'
        a6.attribute_values = ['none']
        rs.append(a6)

        cls = _Ec2Service(21, 43)
        cls.conn = mock_conn
        with patch('awslimitchecker.services.ec2.logger') as mock_logger:
            with patch('%s.boto_query_wrapper' % self.pbm) as mock_wrapper:
                mock_wrapper.return_value = rs
                cls._update_limits_from_api()
        assert mock_wrapper.mock_calls == [
            call(mock_conn.describe_account_attributes)
        ]
        assert mock_conn.mock_calls == []
        assert mock_logger.mock_calls == [
            call.info("Querying EC2 DescribeAccountAttributes for limits"),
            call.debug('Done setting limits from API')
        ]
        assert cls.limits['Elastic IP addresses (EIPs)'].api_limit == 40
        assert cls.limits['Running On-Demand EC2 instances'].api_limit == 400
        assert cls.limits['VPC Elastic IP addresses (EIPs)'].api_limit == 200
        assert cls.limits['VPC security groups per elastic '
                          'network interface'].api_limit == 5
开发者ID:pdecat,项目名称:awslimitchecker,代码行数:50,代码来源:test_ec2.py

示例4: LoadBalancer

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]
class LoadBalancer(object):
    """
    Represents an EC2 Load Balancer.
    """

    def __init__(self, connection=None, name=None, endpoints=None):
        """
        :ivar boto.ec2.elb.ELBConnection connection: The connection this load
            balancer was instance was instantiated from.
        :ivar list listeners: A list of tuples in the form of
            ``(<Inbound port>, <Outbound port>, <Protocol>)``
        :ivar boto.ec2.elb.healthcheck.HealthCheck health_check: The health
            check policy for this load balancer.
        :ivar boto.ec2.elb.policies.Policies policies: Cookie stickiness and
            other policies.
        :ivar str dns_name: The external DNS name for the balancer.
        :ivar str created_time: A date+time string showing when the
            load balancer was created.
        :ivar list instances: A list of :py:class:`boto.ec2.instanceinfo.InstanceInfo`
            instances, representing the EC2 instances this load balancer is
            distributing requests to.
        :ivar list availability_zones: The availability zones this balancer
            covers.
        :ivar str canonical_hosted_zone_name: Current CNAME for the balancer.
        :ivar str canonical_hosted_zone_name_id: The Route 53 hosted zone
            ID of this balancer. Needed when creating an Alias record in a
            Route 53 hosted zone.
        :ivar boto.ec2.elb.securitygroup.SecurityGroup source_security_group:
            The security group that you can use as part of your inbound rules
            for your load balancer back-end instances to disallow traffic
            from sources other than your load balancer.
        :ivar list subnets: A list of subnets this balancer is on.
        :ivar list security_groups: A list of additional security groups that
            have been applied.
        :ivar str vpc_id: The ID of the VPC that this ELB resides within.
        :ivar list backends: A list of :py:class:`boto.ec2.elb.loadbalancer.Backend
            back-end server descriptions.
        """
        self.connection = connection
        self.name = name
        self.listeners = None
        self.health_check = None
        self.policies = None
        self.dns_name = None
        self.created_time = None
        self.instances = None
        self.availability_zones = ListElement()
        self.canonical_hosted_zone_name = None
        self.canonical_hosted_zone_name_id = None
        self.source_security_group = None
        self.subnets = ListElement()
        self.security_groups = ListElement()
        self.vpc_id = None
        self.scheme = None
        self.backends = None
        self._attributes = None

    def __repr__(self):
        return "LoadBalancer:%s" % self.name

    def startElement(self, name, attrs, connection):
        if name == "HealthCheck":
            self.health_check = HealthCheck(self)
            return self.health_check
        elif name == "ListenerDescriptions":
            self.listeners = ResultSet([("member", Listener)])
            return self.listeners
        elif name == "AvailabilityZones":
            return self.availability_zones
        elif name == "Instances":
            self.instances = ResultSet([("member", InstanceInfo)])
            return self.instances
        elif name == "Policies":
            self.policies = Policies(self)
            return self.policies
        elif name == "SourceSecurityGroup":
            self.source_security_group = SecurityGroup()
            return self.source_security_group
        elif name == "Subnets":
            return self.subnets
        elif name == "SecurityGroups":
            return self.security_groups
        elif name == "VPCId":
            pass
        elif name == "BackendServerDescriptions":
            self.backends = ResultSet([("member", Backend)])
            return self.backends
        else:
            return None

    def endElement(self, name, value, connection):
        if name == "LoadBalancerName":
            self.name = value
        elif name == "DNSName":
            self.dns_name = value
        elif name == "CreatedTime":
            self.created_time = value
        elif name == "InstanceId":
            self.instances.append(value)
        elif name == "CanonicalHostedZoneName":
#.........这里部分代码省略.........
开发者ID:rmamba,项目名称:boto,代码行数:103,代码来源:loadbalancer.py

示例5: LoadBalancer

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]
class LoadBalancer(object):
    """
    Represents an EC2 Load Balancer
    """

    def __init__(self, connection=None, name=None, endpoints=None):
        self.connection = connection
        self.name = name
        self.listeners = None
        self.health_check = None
        self.dns_name = None
        self.created_time = None
        self.instances = None
        self.availability_zones = ListElement()

    def __repr__(self):
        return 'LoadBalancer:%s' % self.name

    def startElement(self, name, attrs, connection):
        if name == 'HealthCheck':
            self.health_check = HealthCheck(self)
            return self.health_check
        elif name == 'Listeners':
            self.listeners = ResultSet([('member', Listener)])
            return self.listeners
        elif name == 'AvailabilityZones':
            return self.availability_zones
        elif name == 'Instances':
            self.instances = ResultSet([('member', InstanceInfo)])
            return self.instances
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'LoadBalancerName':
            self.name = value
        elif name == 'DNSName':
            self.dns_name = value
        elif name == 'CreatedTime':
            self.created_time = value
        elif name == 'InstanceId':
            self.instances.append(value)
        else:
            setattr(self, name, value)

    def enable_zones(self, zones):
        """
        Enable availability zones to this Access Point.
        All zones must be in the same region as the Access Point.

        :type zones: string or List of strings
        :param zones: The name of the zone(s) to add.

        """
        if isinstance(zones, str) or isinstance(zones, unicode):
            zones = [zones]
        new_zones = self.connection.enable_availability_zones(self.name, zones)
        self.availability_zones = new_zones

    def disable_zones(self, zones):
        """
        Disable availability zones from this Access Point.

        :type zones: string or List of strings
        :param zones: The name of the zone(s) to add.

        """
        if isinstance(zones, str) or isinstance(zones, unicode):
            zones = [zones]
        new_zones = self.connection.disable_availability_zones(self.name, zones)
        self.availability_zones = new_zones

    def register_instances(self, instances):
        """
        Add instances to this Load Balancer
        All instances must be in the same region as the Load Balancer.
        Adding endpoints that are already registered with the Load Balancer
        has no effect.

        :type zones: string or List of instance id's
        :param zones: The name of the endpoint(s) to add.

        """
        if isinstance(instances, str) or isinstance(instances, unicode):
            instances = [instances]
        new_instances = self.connection.register_instances(self.name, instances)
        self.instances = new_instances

    def deregister_instances(self, instances):
        """
        Remove instances from this Load Balancer.
        Removing instances that are not registered with the Load Balancer
        has no effect.

        :type zones: string or List of instance id's
        :param zones: The name of the endpoint(s) to add.

        """
        if isinstance(instances, str) or isinstance(instances, unicode):
            instances = [instances]
#.........这里部分代码省略.........
开发者ID:JeremyGrosser,项目名称:boto,代码行数:103,代码来源:loadbalancer.py

示例6: LoadBalancer

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]
class LoadBalancer(object):
    """
    Represents an EC2 Load Balancer
    """

    def __init__(self, connection=None, name=None, endpoints=None):
        self.connection = connection
        self.name = name
        self.listeners = None
        self.health_check = None
        self.policies = None
        self.dns_name = None
        self.created_time = None
        self.instances = None
        self.availability_zones = ListElement()
        self.canonical_hosted_zone_name = None
        self.canonical_hosted_zone_name_id = None
        self.source_security_group = None
        self.subnets = ListElement() 
        self.security_groups = ListElement()
        self.vpc_id = None 


    def __repr__(self):
        return 'LoadBalancer:%s' % self.name

    def startElement(self, name, attrs, connection):
        if name == 'HealthCheck':
            self.health_check = HealthCheck(self)
            return self.health_check
        elif name == 'ListenerDescriptions':
            self.listeners = ResultSet([('member', Listener)])
            return self.listeners
        elif name == 'AvailabilityZones':
            return self.availability_zones
        elif name == 'Instances':
            self.instances = ResultSet([('member', InstanceInfo)])
            return self.instances
        elif name == 'Policies':
            self.policies = Policies(self)
            return self.policies
        elif name == 'SourceSecurityGroup':
            self.source_security_group = SecurityGroup()
            return self.source_security_group
        elif name == 'Subnets':
            return self.subnets
        elif name == 'SecurityGroups':
            return self.security_groups
        elif name == 'VPCId':
            pass
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'LoadBalancerName':
            self.name = value
        elif name == 'DNSName':
            self.dns_name = value
        elif name == 'CreatedTime':
            self.created_time = value
        elif name == 'InstanceId':
            self.instances.append(value)
        elif name == 'CanonicalHostedZoneName':
            self.canonical_hosted_zone_name = value
        elif name == 'CanonicalHostedZoneNameID':
            self.canonical_hosted_zone_name_id = value
        elif name == 'VPCId':
            self.vpc_id = value
        else:
            setattr(self, name, value)

    def enable_zones(self, zones):
        """
        Enable availability zones to this Access Point.
        All zones must be in the same region as the Access Point.

        :type zones: string or List of strings
        :param zones: The name of the zone(s) to add.

        """
        if isinstance(zones, str) or isinstance(zones, unicode):
            zones = [zones]
        new_zones = self.connection.enable_availability_zones(self.name, zones)
        self.availability_zones = new_zones

    def disable_zones(self, zones):
        """
        Disable availability zones from this Access Point.

        :type zones: string or List of strings
        :param zones: The name of the zone(s) to add.

        """
        if isinstance(zones, str) or isinstance(zones, unicode):
            zones = [zones]
        new_zones = self.connection.disable_availability_zones(self.name, zones)
        self.availability_zones = new_zones

    def register_instances(self, instances):
        """
#.........这里部分代码省略.........
开发者ID:djacobs,项目名称:boto,代码行数:103,代码来源:loadbalancer.py

示例7: LoadBalancer

# 需要导入模块: from boto.resultset import ResultSet [as 别名]
# 或者: from boto.resultset.ResultSet import append [as 别名]

#.........这里部分代码省略.........
            check policy for this load balancer.
        :ivar list servo.ws.policies.PolicyDescription: A list of load balancer policies
        :ivar str name: The name of the Load Balancer.
        :ivar str dns_name: The external DNS name for the balancer.
        :ivar str created_time: A date+time string showing when the
            load balancer was created.
        :ivar list instances: A list of :py:class:`servo.ws.backend_instance.BackendInstance`
            instances, representing the EC2 instances this load balancer is
            distributing requests to.
        :ivar list availability_zones: The availability zones this balancer
            covers.
        :ivar str canonical_hosted_zone_name: Current CNAME for the balancer.
        :ivar str canonical_hosted_zone_name_id: The Route 53 hosted zone
            ID of this balancer. Needed when creating an Alias record in a
            Route 53 hosted zone.
        :ivar boto.ec2.elb.securitygroup.SecurityGroup source_security_group:
            The security group that you can use as part of your inbound rules
            for your load balancer back-end instances to disallow traffic
            from sources other than your load balancer.
        :ivar list subnets: A list of subnets this balancer is on.
        :ivar list security_groups: A list of additional security groups that
            have been applied.
        :ivar str vpc_id: The ID of the VPC that this ELB resides within.
        :ivar list backends: A list of :py:class:`boto.ec2.elb.loadbalancer.Backend
            back-end server descriptions.
        """
        self.connection = connection
        self.name = name
        self.listeners = None
        self.health_check = None
        self.policy_descriptions = None
        self.dns_name = None
        self.created_time = None
        self.instances = None
        self.availability_zones = ListElement()
        self.canonical_hosted_zone_name = None
        self.canonical_hosted_zone_name_id = None
        self.source_security_group = None
        self.subnets = ListElement()
        self.security_groups = ListElement()
        self.vpc_id = None
        self.scheme = None
        self.backends = None
        self.attributes = None

    def __repr__(self):
        return 'LoadBalancer:%s' % self.name

    def startElement(self, name, attrs, connection):
        if name == 'HealthCheck':
            self.health_check = HealthCheck(self)
            return self.health_check
        elif name == 'ListenerDescriptions':
            self.listeners = ResultSet([('member', Listener)])
            return self.listeners
        elif name == 'AvailabilityZones':
            return self.availability_zones
        elif name == 'BackendInstances':
            self.instances = ResultSet([('member', BackendInstance)])
            return self.instances
        elif name == 'PolicyDescriptions':
            self.policy_descriptions = ResultSet([('member', PolicyDescription)])
            return self.policy_descriptions
        elif name == 'SourceSecurityGroup':
            self.source_security_group = SecurityGroup()
            return self.source_security_group
        elif name == 'Subnets':
            return self.subnets
        elif name == 'SecurityGroups':
            return self.security_groups
        elif name == 'VPCId':
            pass
        elif name == "BackendServerDescriptions":
            self.backends = ResultSet([('member', Backend)])
            return self.backends
        elif name == "LoadBalancerAttributes":
            self.attributes = LbAttributes(self)
            return self.attributes
        else:
            return None

    def endElement(self, name, value, connection):
        if name == 'LoadBalancerName':
            self.name = value
        elif name == 'DNSName':
            self.dns_name = value
        elif name == 'CreatedTime':
            self.created_time = value
        elif name == 'InstanceId':
            self.instances.append(value)
        elif name == 'CanonicalHostedZoneName':
            self.canonical_hosted_zone_name = value
        elif name == 'CanonicalHostedZoneNameID':
            self.canonical_hosted_zone_name_id = value
        elif name == 'VPCId':
            self.vpc_id = value
        elif name == 'Scheme':
            self.scheme = value
        else:
            setattr(self, name, value)
开发者ID:eucalyptus,项目名称:load-balancer-servo,代码行数:104,代码来源:loadbalancer.py


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