本文整理汇总了Python中boto.ec2.blockdevicemapping.BlockDeviceType方法的典型用法代码示例。如果您正苦于以下问题:Python blockdevicemapping.BlockDeviceType方法的具体用法?Python blockdevicemapping.BlockDeviceType怎么用?Python blockdevicemapping.BlockDeviceType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.ec2.blockdevicemapping
的用法示例。
在下文中一共展示了blockdevicemapping.BlockDeviceType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getBlockDeviceMapping
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceType [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: launchCluster
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
def launchCluster(self):
from toil.lib.ec2 import wait_instances_running
from boto.ec2.blockdevicemapping import BlockDeviceType
self.createClusterUtil(args=['--leaderStorage', str(self.requestedLeaderStorage),
'--nodeTypes', ",".join(self.instanceTypes), '-w', ",".join(self.numWorkers), '--nodeStorage', str(self.requestedLeaderStorage)])
self.cluster = clusterFactory(provisioner='aws', clusterName=self.clusterName)
nodes = self.cluster._getNodesInCluster(both=True)
nodes.sort(key=lambda x: x.launch_time)
# assuming that leader is first
workers = nodes[1:]
# test that two worker nodes were created
self.assertEqual(2, len(workers))
# test that workers have expected storage size
# just use the first worker
worker = workers[0]
worker = next(wait_instances_running(self.cluster._ctx.ec2, [worker]))
rootBlockDevice = worker.block_device_mapping["/dev/xvda"]
self.assertTrue(isinstance(rootBlockDevice, BlockDeviceType))
rootVolume = self.cluster._ctx.ec2.get_all_volumes(volume_ids=[rootBlockDevice.volume_id])[0]
self.assertGreaterEqual(rootVolume.size, self.requestedNodeStorage)
示例3: getRootVolID
# 需要导入模块: from boto.ec2 import blockdevicemapping [as 别名]
# 或者: from boto.ec2.blockdevicemapping import BlockDeviceType [as 别名]
def getRootVolID(self):
instances = self.cluster._getNodesInCluster(nodeType=None, both=True)
instances.sort(key=lambda x: x.launch_time)
leader = instances[0] # assume leader was launched first
from boto.ec2.blockdevicemapping import BlockDeviceType
rootBlockDevice = leader.block_device_mapping["/dev/xvda"]
assert isinstance(rootBlockDevice, BlockDeviceType)
return rootBlockDevice.volume_id