2016-01-11 67 views
0

我想訂購幾個非常特定的節點類型,並想知道如何通過SoftLayer API來完成此操作。當運行命令slcli server create-options或在Python API中調用get_create_options()函數時,我沒有收到可用硬件,操作系統,網絡控制器選項(主要是由於沒有冗餘選項)和子網類型。換句話說,API中的選擇與SoftLayer門戶網站中的選擇不匹配。我想要假設訂購的節點在下面指定。SoftLayer API硬件訂單選項規格

Chassis: 4U 
CPU: 4*E7-4850 v2 (12-core HT, 2.30 GHz) 
RAM: 256GB 
HDD: 2*1TB SATA RAID 1 (Boot); 8*600GB SAS RAID 10 (Ephemeral) (10 total) 
NIC: 2*10Gbps 
OS: Ubuntu 14.04 LTS Minimal Install 

Chassis: 2U 
CPU: 2*E5-2650 v3 (10-core HT, 2.30 GHz) 
RAM: 64 GB 
HDD: 2*1TB SATA RAID 1 (Boot); 6*600GB SAS RAID 10 (Data) (8 total) 
NIC: 2*10 Gbps 
OS: Ubuntu 14.04 LTS Minimal Install 

Chassis: 2U 
CPU: 2*E5-2690 v3 (12-core HT, 2.60 GHz) 
RAM: 128GB 
HDD: 2*1TB SATA RAID 1 (Boot); 4*600GB SAS RAID 10 (Ephemeral) (6 total) 
NIC: 2*1 Gbps 
OS: Ubuntu 14.04 LTS Minimal Install 

是否有任何有關完整硬件訂購選項的文檔?任何幫助是極大的讚賞。

回答

0

slcli僅顯示「快速服務器」,這些服務器具有預設配置,這使配置過程變得輕鬆快捷。 您可以在這裏看到有關裸機服務器中預設配置的更多信息: http://sldn.softlayer.com/blog/bpotter/ordering-bare-metal-servers-using-softlayer-api 因此,使用scli,目前無法訂購SL門戶等所有裸機服務器。 但是這個任務可以使用API​​調用,因爲您需要調用palceOrder()方法(這與SL門戶使用的方法相同)。請參閱此文檔以瞭解如何使用API​​訂購設備: http://sldn.softlayer.com/es/blog/bpotter/Going-Further-SoftLayer-API-Python-Client-Part-3 查看此代碼以使用placeOrder方法訂購裸機服務器。

""" 
Order a new server. 

Build a SoftLayer_Container_Product_Order object for a new 
server order and pass it to the SoftLayer_Product_Order API service to order 
it. In this care we'll order a Xeon 3460 server with 2G RAM, 100mbit NICs, 
2000GB bandwidth, a 500G SATA drive, CentOS 5 32-bit, and default server 
order options. See below for more details. 

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 


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


# The number of servers you wish to order in this configuration. 
quantity = 1 

""" 
Where you'd like your new server provisioned. 

This can either be the id of the datacenter you wish your new server to be 
provisioned in or the string. 

Location id 3  = Dallas 
Location id 18171 = Seattle 
Location id 37473 = Washington, D.C. 

""" 
location = 'AMSTERDAM' 

""" 
The id of the SoftLayer_Product_Package you wish to order. 

In this case the Intel Xeon 3460's package id is 145. 
""" 

packageId = 146 

""" 
Build 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', # The hostname of the server you wish to order. 
     'domain': 'example.org' # The domain name of the server you wish to order. 
    } 
] 


""" 
Build 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': 17232}, # Single Processor Quad Core Xeon 3460 - 2.80GHz (Lynnfield) - 1 x 8MB cache w/HT 
    {'id': 637}, # 2 GB DDR2 667 
    {'id': 682}, # CentOS 5.x (32 bit) 
    {'id': 876}, # 2 GB DDR2 667 
    {'id': 20}, # 500GB SATA II 
    {'id': 342}, # 20000 GB Bandwidth 
    {'id': 273}, # 100 Mbps Public & Private Network Uplinks 
    {'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 
] 

""" 
Build 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 
} 

# Create 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(receipt) 
except SoftLayer.SoftLayerAPIError as e: 
    print("Unable to place a server order faultCode=%s, faultString=%s" 
      % (e.faultCode, e.faultString)) 
    exit(1) 

而且也看到這個例子返回所有可用的服務器訂購:

""" 
List all the servers to order. 

Important manual pages: 
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package_Server/getAllObjects 
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Package_Server/ 
http://sldn.softlayer.com/article/Object-Filters 

License: http://sldn.softlayer.com/article/License 
Author: SoftLayer Technologies, Inc. <[email protected]> 
""" 

import SoftLayer 
import json 

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

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

objectFilter = {"packageType": {"operation": "in", "options": [{"name": "data", "value": ["BARE_METAL_CORE", "BARE_METAL_CPU", "BARE_METAL_CPU_FAST_PROVISION"]}]}} 

try: 
    servers = packageService.getAllObjects(filter=objectFilter) 
    print(json.dumps(servers, sort_keys=True, indent=2, separators=(',', ': '))) 
except SoftLayer.SoftLayerAPIError as e: 
    print("Unable to list the servers to order. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString 
+0

謝謝!這正是我們正在尋找的! – user5775628

相關問題