本文整理汇总了Python中boto.vpc.VPCConnection.accept_vpc_peering_connection方法的典型用法代码示例。如果您正苦于以下问题:Python VPCConnection.accept_vpc_peering_connection方法的具体用法?Python VPCConnection.accept_vpc_peering_connection怎么用?Python VPCConnection.accept_vpc_peering_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.vpc.VPCConnection
的用法示例。
在下文中一共展示了VPCConnection.accept_vpc_peering_connection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_peering_connections
# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import accept_vpc_peering_connection [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)