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

前端 未结 4 1018
清歌不尽
清歌不尽 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:51

    If you also want the block device mappings (in linux, the local device name of the EBS volume), you can also use EC2Connection.get_instance_attribute to retrieve a list of the local device names and their corresponding EBS objects:

    def get_block_device_mapping(instance_id):
        return conn.get_instance_attribute(
                instance_id=instance_id,
                attribute='blockDeviceMapping'
                )['blockDeviceMapping']
    

    This will return a dictionary with local device names as keys, and EBS objects as values (from which you can get all sorts of things like the volume-id).

提交回复
热议问题