我正在致力于自动配置 Softlayer 裸机实例。我有一个合适的 json 用于订购硬件,但我似乎无法弄清楚如何指定磁盘布局。
下面来自 Nelson 的答案显示了该过程的关键部分:使用 Chrome 开发人员工具获取价格 ID 和 raid 配置。
在门户网站上,我订购了一个测试系统,指定 4 个 4000GB Western Digital WD RE 驱动器,并使用 1 TB 标准 linux 和 7 TB 附加分区配置存储组。
并使用 chrome 开发工具捕获生成的 json,我看到了存储组配置
data[Order][primaryDiskPartitionId]:1
data[Order][storageGroups][storage-group-1][arrayTypeId]:5
data[Order][storageGroups][storage-group-1][arraySize]:1000
data[Order][storageGroups][storage-group-1][lvmFlag]:0
data[Order][storageGroups][storage-group-1][partitionTemplateId]:1
data[Order][storageGroups][storage-group-1][hardDrives][]:0
data[Order][storageGroups][storage-group-1][hardDrives][]:1
data[Order][storageGroups][storage-group-1][hardDrives][]:2
data[Order][storageGroups][storage-group-1][hardDrives][]:3
data[Order][storageGroups][storage-group-2][arrayTypeId]:5
data[Order][storageGroups][storage-group-2][arraySize]:7000
data[Order][storageGroups][storage-group-2][lvmFlag]:0
data[Order][storageGroups][storage-group-2][hardDrives][]:0
data[Order][storageGroups][storage-group-2][hardDrives][]:1
data[Order][storageGroups][storage-group-2][hardDrives][]:2
data[Order][storageGroups][storage-group-2][hardDrives][]:3
当系统实现时,我看到磁盘如下:
/dev/sda6 1006602 1850 953597 1% / <------ sda - 1Tb linux parttion set
/dev/sda1 237 68 158 30% /boot
/dev/sdb1 6553650 54 6487522 1% /disk1 <- sdb - remaining 7Tb
并且磁盘结构是
-> fdisk -l /dev/sda
Disk /dev/sda: 1000 GiB, 1073741824000 bytes, 2097152000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0xab520822
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 2097149951 2096648194 999.8G 5 Extended
/dev/sda5 501760 2500607 1998848 976M 82 Linux swap / Solaris
/dev/sda6 2502656 2097149951 2094647296 998.8G 83 Linux
Partition 2 does not start on physical sector boundary.
-> fdisk -l /dev/sdb
Disk /dev/sdb: 6.3 TiB, 6926708506624 bytes, 13528727552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: gpt
Disk identifier: ADFDCBE8-94E3-4C23-85C6-D43F332AA1BB
Device Start End Sectors Size Type
/dev/sdb1 2048 13528725503 13528723456 6.3T Linux filesystem
SL 创建了一个 raid 10 设备,将其刻成 2 个单独的磁盘,1 个作为 1 TB linux basic,1 个作为 7 TB fs 安装在 /disk1
现在我们需要弄清楚通过python创建相同的语法。 SoftLayer API:Provision Server with Basic RAID Configuration展示了如何创建一个基本的 raid10 linux 分区。并且在订购时配置 Softlayer 磁盘分区扩展了这一点,以展示如何创建各种配置。但是,两者都没有显示如何创建上面的配置。第二个表示当时不可能。
这是没有 storageGroup 块的订单 json。请注意,答案中讨论的 chrome 开发工具中提供了价格 ID。
worker_json = {
"quantity" : 1,
"packageId": 551,
"location" : datacenterId,
"hardware" : [
{
"hostname": module.params.get('hostname'),
"domain": module.params.get('domain'),
"primaryNetworkComponent": {
"networkVlanId": public,
},
"primaryBackendNetworkComponent": {
"networkVlanId": private,
}
}
],
"prices": [
{ "id": 171621 },
{ "id": 177669 },
{ "id": 165723 },
{ "id": 29691 , "item" : {"description": "RAID 10 - SATA/SAS - MegaRAID SAS 9361-8i" }},
{ "id": 49841 , "item" : {"description": "Hard Drive 4000GB Western Digital WD RE" }},
{ "id": 49841 , "item" : {"description": "Hard Drive 4000GB Western Digital WD RE" }},
{ "id": 49841 , "item" : {"description": "Hard Drive 4000GB Western Digital WD RE" }},
{ "id": 49841 , "item" : {"description": "Hard Drive 4000GB Western Digital WD RE" }},
{ "id": 33483 },
{ "id": 35686 },
{ "id": 50359 },
{ "id": 34807 },
{ "id": 27023 },
{ "id": 35310 },
{ "id": 50223 },
{ "id": 25014 },
{ "id": 34996 },
{ "id": 32500 }
],
"storageGroups": [
{ What to put here? }
]
}
这是从上面的 chrome 开发工具输出创建的最终 storageGoup json。这产生了所需的突袭配置:
"primaryDiskPartitionId": 1,
"storageGroups": [
{
"arraySize": 1000,
"arrayTypeId": 5,
"hardDrives": [ 0, 1, 2, 3 ],
"partitionTemplateId" : 1
},
{
"arraySize": 7000,
"arrayTypeId": 5,
"hardDrives": [ 0, 1, 2, 3 ]
}
]