Python 如何通过boto3获得aws卷的可用大小
我得到的答案是Python 如何通过boto3获得aws卷的可用大小,python,python-2.7,amazon-web-services,amazon-ec2,boto3,Python,Python 2.7,Amazon Web Services,Amazon Ec2,Boto3,我得到的答案是ec2.Instance.volumesCollection(ec2.Instance(id='I-xxxxxx'),ec2.Volume) 它只列出卷的总大小和状态(可用,正在使用…),如何获取它?假设您使用的是Python 2.7: #/usr/bin/python import boto3 ec2 = boto3.resource('ec2', region_name='us-west-2') instance = ec2.Instance('i-xxxxxx') volum
ec2.Instance.volumesCollection(ec2.Instance(id='I-xxxxxx'),ec2.Volume)
它只列出卷的总大小和状态(可用,正在使用…),如何获取它?假设您使用的是Python 2.7:
#/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
输出
for volume in volumes:
print volume.size, volume.state
对于其他属性:
16 in-use
500 in-use
[u'attached_to_instance',u'attachments',
u'availability_zone'、u'create_snapshot'、u'create_tags',
u'create_time',u'delete',u'description_attribute',u'description_status',u',
u'detach_from_instance',u'enable_io',u'encrypted',
“获取可用的子资源”,u'id',u'iops',u'kms\u key\u id',load',
'meta',u'modify_attribute','reload',u'size',u'snapshot_id',
u'snapshots',u'state',u'tags',u'volume\u id',u'volume\u type']
假设您正在使用Python 2.7:
#/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
输出
for volume in volumes:
print volume.size, volume.state
对于其他属性:
16 in-use
500 in-use
[u'attached_to_instance',u'attachments',
u'availability_zone'、u'create_snapshot'、u'create_tags',
u'create_time',u'delete',u'description_attribute',u'description_status',u',
u'detach_from_instance',u'enable_io',u'encrypted',
“获取可用的子资源”,u'id',u'iops',u'kms\u key\u id',load',
'meta',u'modify_attribute','reload',u'size',u'snapshot_id',
u'snapshots',u'state',u'tags',u'volume\u id',u'volume\u type']
请更新问题您正在使用哪种编程语言,您的代码在哪里运行等。请更新问题您正在使用哪种编程语言,您的代码在哪里运行等。但是volume.size是总大小,哪个键可以获得可用大小?请考虑一下。SDK/API可以获得的是虚拟机监控程序级别的可用信息。只有总大小(以及其他此类信息)在虚拟机监控程序中可用。操作系统将知道可用的大小。你能在AWS控制台中看到可用的尺寸吗?没有。但是volume.size是总大小,哪个键可以获得可用的大小?想想看。SDK/API可以获得的是虚拟机监控程序级别的可用信息。只有总大小(以及其他此类信息)在虚拟机监控程序中可用。操作系统将知道可用的大小。你能在AWS控制台中看到可用的尺寸吗?不