当前位置: 首页 > 面试题库 >

在订购时配置软层磁盘分区

邢炯
2023-03-14
问题内容

我想知道如何在订购时通过Softlayer Ppython
API指定一个额外的分区以添加到引导驱动器(在本例中为RAID1存储组)中。这样,额外的分区将在重新加载操作系统之类的事务后保留在服务器上。

我假设它会作为一个附加选项添加,类似于下面的示例中的storage_groups(我已编辑了一些信息以使其尽可能通用),但是我不确定如何添加它。

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] },
    ],
}

尽管我从SoftLayer找到了这个要点页面,但我没有在SLDN中找到文档页面,该页面详细介绍了如何在OS重新加载期间添加分区,这似乎很相似。


问题答案:

在为第一个配置的存储组订购具有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订购服务器并为第二个存储组设置自定义分区的示例:

"""
Order a new server with RAID configuration.

Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware_Server
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder

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

import SoftLayer
import json

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

quantity = 1
location = 'AMSTERDAM03'
packageId = 265

# Building a skeleton SoftLayer_Hardware_Server object to model the hostname and
# domain we want for our server. If you set quantity greater then 1 then you
# need to define one hostname/domain pair per server you wish to order.
hardware = [
    {
        'hostname': 'test',
        'domain': 'example.org'
    }
]

# Building a skeleton SoftLayer_Product_Item_Price objects. These objects contain
# much more than ids, but SoftLayer's ordering system only needs the price's id
# to know what you want to order.
# Every item in SoftLayer's product catalog is assigned an id. Use these ids
# to tell the SoftLayer API which options you want in your new server. Use
# the getActivePackages() method in the SoftLayer_Account API service to get
# a list of available item and price options per available package.
prices = [
    {'id': 76175},  # Dual Intel Xeon E5-2690 (8 Cores, 2.90 GHz)
    {'id': 74095},  # 16 GB
    {'id': 44988},  # CentOS 7.x (64 bit)
    {'id': 75005},  # RAID
    {'id': 68789},  # 500 GB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 64817},  # 1.00 TB SATA
    {'id': 50357},  # 500 GB Bandwidth
    {'id': 273},  # 100 Mbps Public & Private Network Uplinks
    {'id': 76205},  # Redundant Power Supply
    {'id': 55},  # Host Ping
    {'id': 58},  # Automated Notification
    {'id': 420},  # Unlimited SSL VPN Users & 1 PPTP VPN User per account
    {'id': 418},  # Nessus Vulnerability Assessment & Reporting
    {'id': 21},  # 1 IP Address
    {'id': 57},  # Email and Ticket
    {'id': 906}  # Reboot / KVM over IP
]

# Building a skeleton SoftLayer_Container_Product_Order_Storage_Group object
# Storage groups will only be used if the 'RAID' disk controller price is selected.
# Any other disk controller types will ignore the storage groups set here.
# The first storage group in this array will be considered the primary storage group,
# which is used for the OS. Any other storage groups will act as data storage.
storageGroups = [
    {
         "arraySize": 1998,
         "arrayTypeId": 3,  # RAID_5
         "hardDrives": [
            1,
            2,
            3,
            4
         ],
         "partitionTemplateId": 6
     },
    {
         "arraySize": 500,
         "arrayTypeId": 9,
         "hardDrives": [
             0
         ],
         # The custom partitions only work on other storage groups
         # different from the primary one
         "partitions": [
             {
                 "isGrow": False,
                 "name": "/test",
                 "size": 100
             },
             {
                 "isGrow": True,
                 "name": "/test2",
                 "size": 200
             }
         ]
     },
    {
         "arraySize": 2264,
         "arrayTypeId": 1,  # RAID_0
         "hardDrives": [
             5,
             6,
             7,
             8
         ],
         "partitions": [
             {
                 "isGrow": False,
                 "name": "/rc",
                 "size": 500
             },
             {
                 "isGrow": True,
                 "name": "/tr",
                 "size": 200
             }
         ]
     }
]

# Building a skeleton SoftLayer_Container_Product_Order_Hardware_Server object
# containing the order you wish to place.
orderTemplate = {
    'quantity': quantity,
    'location': location,
    'packageId': packageId,
    'prices': prices,
    'hardware': hardware,
    'storageGroups': storageGroups
}

# Creating a SoftLayer API client object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)

try:
    # verifyOrder() will check your order for errors. Replace this with a call
    # to placeOrder() when you're ready to order. Both calls return a receipt
    # object that you can use for your records.
    # Once your order is placed it'll go through SoftLayer's approval and
    # provisioning process. When it's done you'll have a new
    # SoftLayer_Hardware_Server object and server ready to use.
    receipt = client['Product_Order'].verifyOrder(orderTemplate)
    print(json.dumps(receipt, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to place a server order faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))
    exit(1)


 类似资料:
  • 我们可通过quota来设置磁盘的配额,限定某个用户只能使用有限的硬盘空间,这在文件服务器和邮件服务器上是很常用的。Linux通过quota程序支持磁盘配额,它以分区(partition)为单位进行设置的。设置步骤如下: 确定内核支持quota功能,然后下载安装quota程序。 debian:~# apt-get install quota 修改/etc/fstab文件,在分区上启用quota功

  • 2.2 磁盘分区 这一章在规划的重点是为了要安装Linux,那Linux系统是安装在计算机元件的那个部分呢?就是磁盘啦!所以我们当然要来认识一下磁盘先。 我们知道一块磁盘是可以被分区成多个分区的(partition),以旧有的Windows观点来看,你可能会有一颗磁盘并且将他分区成为C:, D:, E:盘对吧!那个C, D, E就是分区(partition)啰。但是Linux的设备都是以文件的型态

  • 我们使用标准的“层控件”从传单。实例化如下: 层是按随机顺序动态添加的(取决于xhr请求完成的时间)。然而,似乎Laflet implicity使用相应层的_leaflet_id在层控件中排序,因此我们的层以随机顺序出现。 有没有办法告诉传单应该按哪个顺序显示控件中的图层?例如。通过在调用或方法时传递一些附加参数? 单张版本为1.0-dev

  • 分区概念 首先我们需要知道,硬盘分区的存在,是由硬盘的物理特性决定的,并不会因为操作系统的不同而有所改变。 请您把一块硬盘想象为一本书……即便您不喜欢读书,您也一定非常熟悉它,所有的书都是相同的,包括我们使用的课本……您肯定非常熟悉 一本完整的书,通常包括书名、目录和正文。 如果您需要Linux,您首先需要找到一本书名为《linux》的书,书名相当于硬盘中的MBR,也就是主引导纪录。不同的是,MB

  • 可引导的软盘一般被视为是最后一种方法用于在那些不能从光盘引导安装程序的硬件上引导安装程序, 也适用于其他类似的情况。 磁盘映像是一些装有原始的软盘文件内容的文件。 磁盘映像,比如 boot.img 则不能直接拷贝到软盘中。 一个特殊的程序负责向软盘中 安装原始模式写入磁盘映像文件 raw 。这是一个必须的步骤,因为这些映像 文件是一些原始的磁盘保存方式。所以需要把文件的数据 按扇区拷贝 放到软盘

  • 本文向大家介绍Linux用户磁盘配额设置方法,包括了Linux用户磁盘配额设置方法的使用技巧和注意事项,需要的朋友参考一下 一:内核中支持QUOTA: 如果有上列输出,则表示当前内核已经支持quota。 二:修改/etc/fstab加入QUOTA支持: [root@localhost /]# vim /etc/fstab /dev/sdb1       /dvd    xfs     defaul