我已經做了一些在stackoverflow搜索,並通過API看,但似乎無法找到答案具體。 我在python中創建了一些自動化腳本,想知道是否有辦法抓取primaryNetworkComponent
和primaryBackendNetworkComponent
對,並根據位置?有getVlans()
方法,但不知道哪些vlans走到一起,除非我去gui。 vlan對上的機器數量沒有限制嗎?如果沒有的話,拿起路由器就可以接受,只要拿到前兩個vlans?訂購Softlayer Vlan對
0
A
回答
0
下面的腳本可以幫助檢索特定位置的VLAN:
"""
Retrieves vlans from specific location
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getNetworkVlans
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Vlan/
http://sldn.softlayer.com/article/object-Masks
http://sldn.softlayer.com/article/object-filters
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'
# Define location
datacenter = "Seoul 1"
# Declare the API client
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
# Declaring an object mask and object filter to get vlans from datacenter
objectMask = "mask[primaryRouter[datacenter], networkSpace]"
objectFilter = {"networkVlans": {"primaryRouter": {"datacenter": {"longName": {"operation": datacenter}}}}}
try:
# Getting the VLANs
vlans = client['SoftLayer_Account'].getNetworkVlans(mask=objectMask, filter=objectFilter)
# Print vlans
print("PRIMARY NETWORK COMPONENT")
for vlan in vlans:
if vlan['networkSpace'] == 'PUBLIC':
print("Id: %s Vlan Number: %s Primary Router: %s" % (vlan['id'], vlan['vlanNumber'], vlan['primaryRouter']['hostname']))
print("\nPRIMARY BACKEND NETWORK COMPONENT")
for vlan in vlans:
if vlan['networkSpace'] == 'PRIVATE':
print("Id: %s Vlan Number: %s Primary Router: %s" % (vlan['id'], vlan['vlanNumber'], vlan['primaryRouter']['hostname']))
except SoftLayer.SoftLayerAPIError as e:
print("Unable to get Vlans. faultCode=%s, faultString=%s"
% (e.faultCode, e.faultString))
有在公網VLAN服務器的數量沒有限制,但是這取決於從可用的IP地址,同樣的情況對私人VLAN。如果私有VLAN有256個IP地址的限制。
如果vlan具有硬件防火牆,則它具有30臺服務器(VSI或BMS)的限制。
從路由器中檢索第一個vlans是不可能的,因爲這是受限制的,您只能檢索您購買的vlans。
參考文獻:
0
我有這樣的代碼
mask = 'id, hostname, domain, hardwareStatus, globalIdentifier, remoteManagementAccounts, primaryBackendIpAddress, primaryIpAddress'
hardware_list = mgr.list_hardware(mask=mask)
for hardware in hardware_list:
if "someGLobalID" == hardware['globalIdentifier']:
在我試圖讓全球標識符,但我不斷收到一個關鍵錯誤
在訂單完成並處於部署狀態後,會生成全局標識符嗎?
我試圖尋找像域不同的密鑰,它工作
+0
我發佈了一個新的答案,如果您需要進一步的幫助,請讓我知道 –
0
我有以下腳本成功:
"""
List Hardware
Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware
https://github.com/softlayer/softlayer-python/blob/master/SoftLayer/managers/hardware.py
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'
# Declare the API client
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
mgr = SoftLayer.HardwareManager(client)
globalIdentifier = '93e99548-bb97-4a18-b728-9c8ebba6s9e3'
try:
mask = 'id, hostname, domain, hardwareStatus, globalIdentifier, remoteManagementAccounts, primaryBackendIpAddress, primaryIpAddress'
hardware_list = mgr.list_hardware(mask=mask)
for hardware in hardware_list:
if globalIdentifier == hardware['globalIdentifier']:
print(hardware['globalIdentifier'])
except SoftLayer.SoftLayerAPIError as e:
print("Error. "
% (e.faultCode, e.faultString))
你是對的,在收到訂單生成的全局標識符,但他們連接到服務器,直到提供過程完成。所以,有必要等到服務器的供應過程完成後才能進行搜索。
相關問題
- 1. Softlayer API:訂單專用vlan
- 2. SoftLayer:訂購帶寬包
- 3. SoftLayer對trunk vlan的API調用失敗
- 4. 如何通過SoftLayer API訂購「路由到VLAN」便攜式子網
- 5. Softlayer api:如何識別兩個VLAN匹配VLAN路由器對?
- 6. 用於VLAN Trunk的Softlayer API
- 7. 在Softlayer上選購可購買的Vlans
- 8. SoftLayer VLAN問題資源不足
- 9. 將Softlayer中的vlan與java相關聯
- 10. 如何使用Terraform創建SoftLayer Vlan?
- 11. Softlayer中的自動調節Vlan選擇
- 12. SoftLayer的VLAN關聯和保護選項
- 13. 無法使用softlayer API取消vlan
- 14. 訂購INT對
- 15. SoftLayer - 如何解決最近訂購的服務中的ResourceTableIds
- 16. 訂購admin.ModelAdmin對象
- 17. SoftLayer方面的任何當前問題與對象存儲訂購或配置?
- 18. 的SoftLayer API:訂購安全證書CSR驗證
- 19. 如何使用SoftLayer API以編程方式訂購EVault插件?
- 20. 用於訂購VMware許可證的Softlayer API
- 21. 用於訂購虛擬服務器的Softlayer API
- 22. SoftLayer REST API訂購100Mbps硬件防火牆
- 23. 如何使用Softlayer REST API訂購子網?
- 24. 的SoftLayer API知道,總以及可用IP一個VLAN
- 25. 如何識別SoftLayer的網絡網關VLAN
- 26. SoftLayer Python客戶端API - 在公共VLAN上創建實例
- 27. ios NSFetchRequest,訂購子對象
- 28. TSQL對訂購集編號
- 29. Monogame中的訂購對象
- 30. 用lodash對象訂購
非常感謝ruber! – Patrick