[英]How can i get the aws volumes available size by boto3
#/usr/bin/python
import boto3
ec2 = boto3.resource('ec2', region_name='us-west-2')
instance = ec2.Instance('i-xxxxxx')
volumes = instance.volumes.all()
print volumes
The answer I got ec2.Instance.volumesCollection(ec2.Instance(id='i-xxxxxx'), ec2.Volume)
答案我得到了
ec2.Instance.volumesCollection(ec2.Instance(id='i-xxxxxx'), ec2.Volume)
It just list the volume total size and status(available,in-use...)
, how can i get it? 它只列出了卷的总大小和
status(available,in-use...)
,我该如何获得它?
Assuming you are using Python 2.7 : 假设您使用的是Python 2.7 :
for volume in volumes:
print volume.size, volume.state
Output 产量
16 in-use
500 in-use
For other attributes: 对于其他属性:
dir(volume)
[u'attach_to_instance', u'attachments', u'availability_zone', u'create_snapshot', u'create_tags', u'create_time', u'delete', u'describe_attribute', u'describe_status', u'detach_from_instance', u'enable_io', u'encrypted', 'get_available_subresources', u'id', u'iops', u'kms_key_id', 'load', 'meta', u'modify_attribute', 'reload', u'size', u'snapshot_id', u'snapshots', u'state', u'tags', u'volume_id', u'volume_type']
[u'attach_to_instance',u'attachments',u'availability_zone',u'create_snapshot',u'create_tags',u'create_time',u'delete',u'describe_attribute',u'describe_status',u'detach_from_instance' ,u'enable_io',u'encrypted','get_available_subresources',u'id',u'iops',u'kms_key_id','load','meta',u'modify_attribute','reload',u'size ',u'snapshot_id',u'snapshots',u'state',u'tags',u'volume_id',u'volume_type']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.