本文整理匯總了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