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

I believe attach_data. Device is what your looking for. Part of volume Heres an example, not sure if this is the best way, but it outputs volumeid, instanceid, and attachment_data something like: Attached Volume ID - Instance ID - Device Name vol-12345678 - i-ab345678 - /dev/sdp vol-12345678 - i-ab345678 - /dev/sda1 vol-12345678 - i-cd345678 - /dev/sda1 import boto ec2 = boto.

Connect_ec2() res = ec2. Get_all_instances() instances = instances = I for r in res for I in r. Instances vol = ec2.

Get_all_volumes() def attachedvolumes(): print 'Attached Volume ID - Instance ID','-','Device Name' for volumes in vol: if volumes. Attachment_state() == 'attached': filter = {'block-device-mapping. Volume-id':volumes.Id} volumesinstance = ec2.

Get_all_instances(filters=filter) ids = ids = z for k in volumesinstance for z in k. Instances for s in ids: print volumes.Id,'-',s. Id,'-',volumes.

Attach_data. Device # Get a list of unattached volumes def unattachedvolumes(): for unattachedvol in vol: state = unattachedvol. Attachment_state() if state == None: print unattachedvol.

Id, state attachedvolumes() unattachedvolumes().

I believe attach_data. Device is what your looking for. Part of volume.

Heres an example, not sure if this is the best way, but it outputs volumeid, instanceid, and attachment_data something like: Attached Volume ID - Instance ID - Device Name vol-12345678 - i-ab345678 - /dev/sdp vol-12345678 - i-ab345678 - /dev/sda1 vol-12345678 - i-cd345678 - /dev/sda1 import boto ec2 = boto. Connect_ec2() res = ec2. Get_all_instances() instances = instances = I for r in res for I in r.

Instances vol = ec2. Get_all_volumes() def attachedvolumes(): print 'Attached Volume ID - Instance ID','-','Device Name' for volumes in vol: if volumes. Attachment_state() == 'attached': filter = {'block-device-mapping.

Volume-id':volumes. Id} volumesinstance = ec2. Get_all_instances(filters=filter) ids = ids = z for k in volumesinstance for z in k.

Instances for s in ids: print volumes. Id,'-',s. Id,'-',volumes.

Attach_data. Device # Get a list of unattached volumes def unattachedvolumes(): for unattachedvol in vol: state = unattachedvol. Attachment_state() if state == None: print unattachedvol.Id, state attachedvolumes() unattachedvolumes().

It isn't clear if you're running this from the instance itself or externally. If the latter, you will not need the metadata call. Just supply the instance id.

From boto. Ec2. Connection import EC2Connection from boto.

Utils import get_instance_metadata conn = EC2Connection() m = get_instance_metadata() volumes = v for v in conn. Get_all_volumes() if v. Attach_data.

Instance_id == m'instance-id' print volumes0. Attach_data. Device Note that an instance may have multiple volumes, so robust code won't assume there's a single device.

Works like a charm- thanks! – Vincent Theeten Mar 10 at 9:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions