【问题标题】:How to get route table/acl content using boto?如何使用 boto 获取路由表/acl 内容?
【发布时间】:2014-07-09 17:37:58
【问题描述】:

我正在尝试使用 boto 获取路由表和 acl(如 Destination、target...等)的内容。我能够获取 ID 而不是内容,请提出解决此问题的方法。

【问题讨论】:

    标签: boto amazon-vpc


    【解决方案1】:

    要检索数据,您需要执行以下步骤:

    1. 首先导入 VPC CONNECTION,即 from boto.vpc import VPCConnection
    2. 连接到您想要的区域

    conn=boto.vpc.connect_to_region("ap-southeast-1")

    1. 现在使用您创建的 conn 对象获取对象中的所有路由表。此对象将返回路由表列表。

    c=conn.get_all_route_tables()

    1. c 具有 RouteTable 类的对象,该对象还具有 Route 类的 1 个数据成员。您需要从该数据成员中检索详细信息:

    对于 c1 中的 c:

    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/ 希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 2021-10-14
      • 1970-01-01
      • 2018-05-16
      • 1970-01-01
      • 1970-01-01
      • 2021-01-27
      • 2019-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多