本文整理汇总了Python中boto.ec2.blockdevicemapping.BlockDeviceMapping方法的典型用法代码示例。如果您正苦于以下问题:Python blockdevicemapping.BlockDeviceMapping方法的具体用法?Python blockdevicemapping.BlockDeviceMapping怎么用?Python blockdevicemapping.BlockDeviceMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.ec2.blockdevicemapping
的用法示例。
在下文中一共展示了blockdevicemapping.BlockDeviceMapping方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getBlockDeviceMapping
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def _getBlockDeviceMapping(cls, instanceType, rootVolSize=50):
# determine number of ephemeral drives via cgcloud-lib (actually this is moved into toil's lib
bdtKeys = [''] + ['/dev/xvd{}'.format(c) for c in string.ascii_lowercase[1:]]
bdm = BlockDeviceMapping()
# Change root volume size to allow for bigger Docker instances
root_vol = BlockDeviceType(delete_on_termination=True)
root_vol.size = rootVolSize
bdm["/dev/xvda"] = root_vol
# The first disk is already attached for us so start with 2nd.
# Disk count is weirdly a float in our instance database, so make it an int here.
for disk in range(1, int(instanceType.disks) + 1):
bdm[bdtKeys[disk]] = BlockDeviceType(
ephemeral_name='ephemeral{}'.format(disk - 1)) # ephemeral counts start at 0
logger.debug('Device mapping: %s', bdm)
return bdm
示例2: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
retval = TaggedEC2Object.startElement(self, name, attrs, connection)
if retval is not None:
return retval
if name == 'monitoring':
self._in_monitoring_element = True
elif name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
elif name == 'productCodes':
return self.product_codes
elif name == 'stateReason':
self.state_reason = StateReason()
return self.state_reason
elif name == 'groupSet':
self.groups = ResultSet([('item', Group)])
return self.groups
return None
示例3: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
retval = super(Image, self).startElement(name, attrs, connection)
if retval is not None:
return retval
if name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
elif name == 'productCodes':
return self.product_codes
elif name == 'billingProducts':
return self.billing_products
else:
return None
示例4: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
if name == 'groupSet':
self.groups = ResultSet([('item', Group)])
return self.groups
elif name == 'monitoring':
self._in_monitoring_element = True
elif name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
elif name == 'iamInstanceProfile':
self.instance_profile = SubParse('iamInstanceProfile')
return self.instance_profile
else:
return None
示例5: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
retval = super(Instance, self).startElement(name, attrs, connection)
if retval is not None:
return retval
if name == 'monitoring':
self._in_monitoring_element = True
elif name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
elif name == 'productCodes':
return self.product_codes
elif name == 'stateReason':
self.state_reason = SubParse('stateReason')
return self.state_reason
elif name == 'groupSet':
self.groups = ResultSet([('item', Group)])
return self.groups
elif name == "eventsSet":
self.eventsSet = SubParse('eventsSet')
return self.eventsSet
elif name == 'networkInterfaceSet':
self.interfaces = ResultSet([('item', NetworkInterface)])
return self.interfaces
elif name == 'iamInstanceProfile':
self.instance_profile = SubParse('iamInstanceProfile')
return self.instance_profile
elif name == 'currentState':
return self._state
elif name == 'previousState':
self._previous_state = InstanceState()
return self._previous_state
elif name == 'instanceState':
return self._state
elif name == 'placement':
return self._placement
return None
示例6: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
if name == 'SecurityGroups':
return self.security_groups
elif name == 'ClassicLinkVPCSecurityGroups':
return self.classic_link_vpc_security_groups
elif name == 'BlockDeviceMappings':
if self.use_block_device_types:
self.block_device_mappings = BDM()
else:
self.block_device_mappings = ResultSet([('member', BlockDeviceMapping)])
return self.block_device_mappings
elif name == 'InstanceMonitoring':
self.instance_monitoring = InstanceMonitoring(self)
return self.instance_monitoring
示例7: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
retval = TaggedEC2Object.startElement(self, name, attrs, connection)
if retval is not None:
return retval
if name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
elif name == 'productCodes':
return self.product_codes
else:
return None
示例8: startElement
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def startElement(self, name, attrs, connection):
if name == 'groupSet':
self.groups = ResultSet([('item', Group)])
return self.groups
elif name == 'monitoring':
self._in_monitoring_element = True
elif name == 'blockDeviceMapping':
self.block_device_mapping = BlockDeviceMapping()
return self.block_device_mapping
else:
return None
示例9: create_image
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceMapping [as 别名]
def create_image(self, instance_id, name,
description=None, no_reboot=False,
block_device_mapping=None, dry_run=False):
"""
Will create an AMI from the instance in the running or stopped
state.
:type instance_id: string
:param instance_id: the ID of the instance to image.
:type name: string
:param name: The name of the new image
:type description: string
:param description: An optional human-readable string describing
the contents and purpose of the AMI.
:type no_reboot: bool
:param no_reboot: An optional flag indicating that the
bundling process should not attempt to shutdown the
instance before bundling. If this flag is True, the
responsibility of maintaining file system integrity is
left to the owner of the instance.
:type block_device_mapping: :class:`boto.ec2.blockdevicemapping.BlockDeviceMapping`
:param block_device_mapping: A BlockDeviceMapping data structure
describing the EBS volumes associated with the Image.
:type dry_run: bool
:param dry_run: Set to True if the operation should not actually run.
:rtype: string
:return: The new image id
"""
params = {'InstanceId': instance_id,
'Name': name}
if description:
params['Description'] = description
if no_reboot:
params['NoReboot'] = 'true'
if block_device_mapping:
block_device_mapping.ec2_build_list_params(params)
if dry_run:
params['DryRun'] = 'true'
img = self.get_object('CreateImage', params, Image, verb='POST')
return img.id
# ImageAttribute methods