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


Python VPCConnection.get_all_vpc_peering_connections方法代码示例

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


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

示例1: create_peering_connections

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_vpc_peering_connections [as 别名]
 def create_peering_connections(peering_configs):
     """ create vpc peering configuration from the peering config dictionary"""
     vpc_conn = VPCConnection()
     for peering in peering_configs.keys():
         vpc_map = peering_configs[peering]['vpc_map']
         vpc_metanetwork_map = peering_configs[peering]['vpc_metanetwork_map']
         vpc_ids = [vpc.vpc.id for vpc in vpc_map.values()]
         existing_peerings = vpc_conn.get_all_vpc_peering_connections(
             filters=[
                 ('status-code', 'active'),
                 ('accepter-vpc-info.vpc-id', vpc_ids[0]),
                 ('requester-vpc-info.vpc-id', vpc_ids[1])
             ]
         ) + vpc_conn.get_all_vpc_peering_connections(
             filters=[
                 ('status-code', 'active'),
                 ('accepter-vpc-info.vpc-id', vpc_ids[1]),
                 ('requester-vpc-info.vpc-id', vpc_ids[0])
             ]
         )
         # create peering when peering doesn't exist
         if not existing_peerings:
             peering_conn = vpc_conn.create_vpc_peering_connection(*vpc_ids)
             vpc_conn.accept_vpc_peering_connection(peering_conn.id)
             logging.info("create new peering connection %s for %s", peering_conn.id, peering)
         else:
             peering_conn = existing_peerings[0]
             logging.info("peering connection %s exists for %s", existing_peerings[0].id, peering)
         DiscoVPC.create_peering_routes(vpc_conn, vpc_map, vpc_metanetwork_map, peering_conn)
开发者ID:Angakkuit,项目名称:asiaq-aws,代码行数:31,代码来源:disco_vpc.py

示例2: list_peerings

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_vpc_peering_connections [as 别名]
    def list_peerings(vpc_id=None, include_failed=False):
        """
        Return list of live vpc peering connection id.
        If vpc_id is given, return only that vpcs peerings
        Peerings that cannot be manipulated are ignored.
        """
        vpc_conn = VPCConnection()
        if vpc_id:
            peerings = vpc_conn.get_all_vpc_peering_connections(
                filters=[('requester-vpc-info.vpc-id', vpc_id)]
            ) + vpc_conn.get_all_vpc_peering_connections(
                filters=[('accepter-vpc-info.vpc-id', vpc_id)]
            )
        else:
            peerings = vpc_conn.get_all_vpc_peering_connections()

        peering_states = LIVE_PEERING_STATES + (["failed"] if include_failed else [])
        return [
            peering
            for peering in peerings
            if peering.status_code in peering_states
        ]
开发者ID:Angakkuit,项目名称:asiaq-aws,代码行数:24,代码来源:disco_vpc.py

示例3: test_delete_vpc_peering_connection

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_vpc_peering_connections [as 别名]
    def test_delete_vpc_peering_connection(self):
        vpc_conn = VPCConnection(aws_access_key_id='aws_access_key_id',
                                 aws_secret_access_key='aws_secret_access_key')

        mock_response = mock.Mock()
        mock_response.read.return_value = self.DESCRIBE_VPC_PEERING_CONNECTIONS
        mock_response.status = 200
        vpc_conn.make_request = mock.Mock(return_value=mock_response)
        vpc_peering_connections = vpc_conn.get_all_vpc_peering_connections()

        self.assertEquals(1, len(vpc_peering_connections))
        vpc_peering_connection = vpc_peering_connections[0]

        mock_response = mock.Mock()
        mock_response.read.return_value = self.DELETE_VPC_PEERING_CONNECTION
        mock_response.status = 200
        vpc_conn.make_request = mock.Mock(return_value=mock_response)
        self.assertEquals(True, vpc_peering_connection.delete())

        self.assertIn('DeleteVpcPeeringConnection', vpc_conn.make_request.call_args_list[0][0])
        self.assertNotIn('DeleteVpc', vpc_conn.make_request.call_args_list[0][0])
开发者ID:17patelumang,项目名称:boto,代码行数:23,代码来源:test_vpc_peering_connection.py


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