我正在尝试使用 boto 获取路由表和 acl 的内容,例如 Destination、target...等。我能够获取 ID 而不是内容,请提出解决此问题的方法。
问问题
1544 次
1 回答
2
要检索数据,您需要执行以下步骤:
- 首先导入VPC CONNECTION这是
from boto.vpc import VPCConnection
- 连接到您想要的区域
conn=boto.vpc.connect_to_region("ap-southeast-1")
- 现在使用您创建的 conn 对象获取对象中的所有路由表。此对象将返回路由表列表。
c=conn.get_all_route_tables()
- c 具有 RouteTable 类的对象,该对象还具有 Route 类的 1 个数据成员。您需要从该数据成员中检索详细信息:
对于 c 中的 c1:
for a in c1.routes:
print a.destination_cidr_block
print a.instance_id
print a.gateway_id
print a.state
print a.dry_run
如果您对第 4 点感到困惑,可以在这里查看:http: //pydoc.net/Python/boto/2.1.1/boto.vpc.routetable/ 希望对您有所帮助!
于 2014-07-09T09:37:58.350 回答