Using Boto to find to which device and EBS Volume is mounted

前端 未结 4 947
清歌不尽
清歌不尽 2021-02-01 10:11

How do I find to which device an EBS Volume is mounted with Python Boto v2.0?

boto.ec2.Volume has some interesting properies like attachment_state and

4条回答
  •  梦如初夏
    2021-02-01 10:28

    The best way I've found is to get all resources in one region at a time and associate them yourself:

    #!/usr/bin/env python2
    import boto.ec2
    
    REGION = 'us-east'
    CONN = boto.ec2.connect_to_region(REGION)
    
    def main():
        volumes = conn.get_all_volumes()
    
        for volume in volumes:
            print volume
    
            # Match to an instance id
            print volume.attach_data.instance_id
    
            # # Object attributes:
            # print volume.__dict__
    
            # # Object methods:
            # print(dir(volume))
    
    if __name__ == '__main__':
        main()
    

提交回复
热议问题