2016-02-18 4 views
3

Мне было интересно, как можно указать дополнительный раздел для добавления в загрузочный диск (в данном случае группу хранения RAID1) во время заказа через API Softlayer Ppython. Таким образом, дополнительный раздел будет сохраняться на сервере после транзакций, таких как перезагрузка ОС.Конфигурирование разделов диска Softlayer во время заказа

Я предполагаю, что он будет добавлен как дополнительная опция, аналогичная памяти_групп в приведенном ниже примере (я отредактировал некоторую информацию, чтобы сохранить ее как можно более общую), но я не уверен, как добавить это.

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, хотя я нашел this gist page от SoftLayer, которые подробно описано, как добавлять разделы во время перезагрузки операционной системы, которая, кажется, похожи.

+0

Я только что закончил упражнение очень похоже на это. Нельсон предоставил [удивительный совет о том, как получить цены] (https://stackoverflow.com/questions/45426242/softlayer-hardware-how-to-setup-multiple-raid10-storagegroups-on-the-same-set- o) и конфигурацию хранилища при заказе на портале Softlayer. – pdorwin

ответ

2

На данный момент для заказа голого металлического сервера с конфигурацией 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. <[email protected]> 
""" 

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. <[email protected]> 
""" 

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) 
+0

Я понимаю решение, которое у вас есть, и пытаюсь его реализовать, где я могу найти список 'arrayTypeId's' для различных версий RAID. Я хочу использовать RAID1, но не знаю правильный код для этого. –

+0

вызовите этот метод http://sldn.softlayer.com/reference/services/SoftLayer_Configuration_Storage_Group_Array_Type/getAllObjects –

 Смежные вопросы

  • Нет связанных вопросов^_^