當前位置: 首頁>>代碼示例>>Python>>正文


Python blockdevicemapping.BlockDeviceType方法代碼示例

本文整理匯總了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 
開發者ID:DataBiosphere,項目名稱:toil,代碼行數:18,代碼來源:awsProvisioner.py

示例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) 
開發者ID:DataBiosphere,項目名稱:toil,代碼行數:23,代碼來源:awsProvisionerTest.py

示例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 
開發者ID:DataBiosphere,項目名稱:toil,代碼行數:11,代碼來源:awsProvisionerTest.py


注:本文中的boto.ec2.blockdevicemapping.BlockDeviceType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。