按顺序配置软层磁盘分区

2024-05-16 06:16:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道如何通过软层Ppython API指定一个额外的分区来添加到引导驱动器(在本例中是RAID1存储组)。这样,在像操作系统这样的事务重新加载之后,额外的分区将继续存在于服务器上。在

我假设它将作为一个额外的选项添加,类似于下面示例中的存储组(我已经编辑了一些信息以使其尽可能通用),但我不确定如何添加它。在

RAID_1  = 2
SERVERS = [
       {
    "types": [
        { "name": "NAME", "type": "TYPE" },
    ],
    "package": PACKAGE_DESCRIPTION
    "prices": [
        "CPU",                             
        "RAM",                        
        "OS", 
        "DISK_CONTROLLER_RAID",                             # RAID
        "HARD_DRIVE_960GB_SSD",
        "HARD_DRIVE_960GB_SSD",
        "HARD_DRIVE_4_00_TB_SATA",
        "NETWORKING AND EXTRA OPTIONS"
    ],
    "storage_groups": [
        { "arrayTypeId": RAID_1,  # RAID 1
          "hardDrives": [0,1] },
    ],
}

我在SLDN中没有找到关于这个的文档页,不过我从SoftLayer找到了this gist page,它详细说明了如何在操作系统重新加载期间添加分区,这看起来很相似。在


Tags: 服务器api示例选项drive事务驱动器分区
1条回答
网友
1楼 · 发布于 2024-05-16 06:16:35

目前,要为第一个配置的存储组订购具有RAID配置的裸机服务器,您不能设置自定义分区,您只能选择一个分区模板(请参阅下面的代码以获取分区模板,可能其中一个模板符合您的要求)。这里记录如下: http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Storage_Group

“分区

定义存储组的分区。 如果此存储组不是辅助存储组,则不会使用此存储组。“

以防万一,我添加了一个代码来订购裸机服务器并在第二个存储组中配置一个自定义分区(见下文)。在

订购裸机服务器的另一种方法是订购裸机服务器,在配置了所需的分区后,使用所需的分区对其进行配置,并从该服务器创建映像模板,然后可以使用该映像模板创建新的裸机服务器,它们应以你想要的分区配置。在

这里是一个获取有效分区模板的示例。在

"""
List the partition templates available for the first disk.
The partition templates available will depend on the OS selected and the disk type assigned.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Component_Partition_OperatingSystem/getByDescription
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware_Component_Partition_OperatingSystem/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""

import SoftLayer
import json

USERNAME = 'set me'
API_KEY = 'set me'

# To get the valid list of description values use SoftLayer_Hardware_Component_Partition_OperatingSystem::getAllObjects method.
description = "linux"

client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
packageService = client['SoftLayer_Hardware_Component_Partition_OperatingSystem']

objectMask = "mask[partitionTemplates[data]]"

try:
    templates = packageService.getByDescription(description, mask=objectMask)
    print(json.dumps(templates, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to list the partition templates. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))

下面是订购带有Raid的服务器并为第二个存储组设置自定义分区的示例:

^{pr2}$

相关问题 更多 >