本文整理汇总了Python中boto.ec2.blockdevicemapping.BlockDeviceType.delete_on_terminate方法的典型用法代码示例。如果您正苦于以下问题:Python BlockDeviceType.delete_on_terminate方法的具体用法?Python BlockDeviceType.delete_on_terminate怎么用?Python BlockDeviceType.delete_on_terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.ec2.blockdevicemapping.BlockDeviceType
的用法示例。
在下文中一共展示了BlockDeviceType.delete_on_terminate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_block_device_mappings
# 需要导入模块: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
# 或者: from boto.ec2.blockdevicemapping.BlockDeviceType import delete_on_terminate [as 别名]
def _process_block_device_mappings(self, launch_config, zone=None):
"""
Processes block device mapping information
and returns a Boto BlockDeviceMapping object. If new volumes
are requested (source is None and destination is VOLUME), they will be
created and the relevant volume ids included in the mapping.
"""
bdm = BlockDeviceMapping()
# Assign letters from f onwards
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html
next_letter = iter(list(string.ascii_lowercase[6:]))
# assign ephemeral devices from 0 onwards
ephemeral_counter = 0
for device in launch_config.block_devices:
bd_type = BlockDeviceType()
if device.is_volume:
if device.is_root:
bdm['/dev/sda1'] = bd_type
else:
bdm['sd' + next(next_letter)] = bd_type
if isinstance(device.source, Snapshot):
bd_type.snapshot_id = device.source.id
elif isinstance(device.source, Volume):
bd_type.volume_id = device.source.id
elif isinstance(device.source, MachineImage):
# Not supported
pass
else:
# source is None, but destination is volume, therefore
# create a blank volume. If the Zone is None, this
# could fail since the volume and instance may be created
# in two different zones.
if not zone:
raise InvalidConfigurationException(
"A zone must be specified when launching with a"
" new blank volume block device mapping.")
new_vol = self.provider.block_store.volumes.create(
'',
device.size,
zone)
bd_type.volume_id = new_vol.id
bd_type.delete_on_terminate = device.delete_on_terminate
if device.size:
bd_type.size = device.size
else: # device is ephemeral
bd_type.ephemeral_name = 'ephemeral%s' % ephemeral_counter
return bdm