尋找幫助,開始以運行關機,開機和重啓虛擬機對SoftLayer的機器指令使用slcli。我在ubuntu 14.04下安裝了軟件包sudo apt-get install python-softlayer,現在試圖運行slcli setup命令,但是無法定位從哪裏運行,它不在bash shell的路徑中,也沒有在python之後導入SoftLayer,我錯過了什麼?如何設置slcli的SoftLayer API
0
A
回答
0
從任何地方提供正確安裝包可以運行slcli config setup
命令。我通常建議使用pip來安裝SoftLayer軟件包。
sudo apt-get purge python-softlayer
sudo apt-get install python-setuptools python-pip
sudo pip install softlayer
0
確保蟒蛇和PIP的安裝是否正確,然後運行:
sudo apt-get install python-softlayer
然而,如果這不是工作,然後嘗試使用PIP安裝:
sudo pip install softlayer
一旦slcli是正確安裝運行slcli
無參數應顯示選項菜單,您可以使用獲得額外信息
使用slcli setup
來設置您的默認值和slcli config show
來顯示它。
爲了管理VS與slcli使用以下命令:
slcli vs list
slcli vs power-on 1234567
slcli vs power-off 1234567
slcli vs reboot 1234567
將虛擬客戶ID獲得使用slcli vs list
也有可能完成上述使用標準的python腳本,這裏舉一些例子:
"""
Power off Guest
The scripts will look for a VSI which has an specific
hostname and the it powers off the VSI by making a single call
to the SoftLayer_Virtual_Guest::powerOff method.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Acount/
http://sldn.softlayer.com/reference/services/SoftLayer_Acount/getVirtualGuests
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/setTags
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
"""
# Your SoftLayer API username and key.
#
# Generate an API key at the SoftLayer Customer Portal:
# https://manage.softlayer.com/Administrative/apiKeychain
"""
username = 'set me'
key = 'set me'
# The name of the machine you wish to power off
virtualGuestName = 'rctest'
# Declare a new API service object
client = SoftLayer.Client(username=username, api_key=key)
try:
# Getting all virtual guest that the account has:
virtualGuests = client['SoftLayer_Account'].getVirtualGuests()
except SoftLayer.SoftLayerAPIError as e:
"""
If there was an error returned from the SoftLayer API then bomb out with the
error message.
"""
print("Unable to retrieve hardware. "
% (e.faultCode, e.faultString))
# Looking for the virtual guest
virtualGuestId = ''
for virtualGuest in virtualGuests:
if virtualGuest['hostname'] == virtualGuestName:
virtualGuestId = virtualGuest['id']
try:
# Power off the virtual guest
virtualMachines = client['SoftLayer_Virtual_Guest'].powerOff(id=virtualGuestId)
print ("powered off")
except SoftLayer.SoftLayerAPIError as e:
"""
If there was an error returned from the SoftLayer API then bomb out with the
error message.
"""
print("Unable to power off the virtual guest"
% (e.faultCode, e.faultString))
重新啓動
"""
Reboot Virtual Guest.
It reboots a SoftLayer Virtual Guest
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/rebootDefault
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
# So we can talk to the SoftLayer API:
import SoftLayer
# From pprint import pprint as pp
# For nice debug output
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# If you don't know your server id you can call getVirtualGuests() in the
# SoftLayer_Account API service to get a list of Virtual Guests
serverId = 10403817
# Create a connection to API service.
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY
)
# Reboot the Virtual Guest
try:
result = client['Virtual_Guest'].rebootDefault(id=serverId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to reboot the server faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
相關問題
- 1. (的SoftLayer API)如何設置時間在雲存儲住SOFTLAYER
- 2. 是否可以使用slcli或Python API訂購/配置IBM SoftLayer文件存儲?
- 3. 的SoftLayer API: - 如何
- 4. 如何使用SoftLayer API設置硬件筆記
- 5. SoftLayer的命令行界面 - 無法從slcli
- 6. SoftLayer API OpenIdConnect重置密碼
- 7. SoftLayer API如何過濾MetricDataTypes
- 8. 如何使用slcli或sl api更新Softlayer中Windows虛擬機的「管理員」用戶密碼?
- 9. SoftLayer slcli使用多個SAN磁盤捕獲映像
- 10. 如何使用SoftLayer API查找EVault的位置?
- 11. 以JSON順序設置標籤Softlayer API Python
- 12. Softlayer API錯誤「java.net.SocketException:連接重置」
- 13. SoftLayer API硬件:createObject:postInstallScriptUri:ObjectStorage
- 14. Softlayer API:瞭解Product_Package_Server
- 15. S3 API創建SOFTLAYER
- 16. 的SoftLayer API錯誤 - 在dal10
- 17. 的SoftLayer API檢索硬件
- 18. 用於VLAN Trunk的Softlayer API
- 19. Softlayer API - 調用softlayer api時發生異常
- 20. 如何使用SoftLayer API在SoftLayer門戶中更新Netscaler的密碼信息?
- 21. 如何使用SoftLayer API瀏覽器獲取Softlayer門票中的對話內容
- 22. 如何設置API URL
- 23. SoftLayer API:什麼是SoftLayer API以獲取添加子網的有效設備列表IP地址
- 24. SoftLayer API - 檢索發票
- 25. Softlayer API - 刪除顯示器
- 26. SoftLayer API版本3.x
- 27. Softlayer API:存儲信息
- 28. Softlayer API - 自定義Hardware_Component_Partition_Template
- 29. Softlayer API:帳戶銷燬?
- 30. SoftLayer Evault驗證API錯誤