我想通过OS reload API更改Baremetal服务器的操作系统版本。
遵循python代码,它适合我的需求。然后我试了这个。 但它不起作用。问题的原因是很老的代码,API已经有些改变了规范。
https://gist.github.com/softlayer/407058
如何更新此代码以获取最新的API版本?
谢谢!
答案 0 :(得分:0)
您可以尝试以下python脚本:
import SoftLayer
from pprint import pprint as pp
# Valid Softlayer username
USERNAME = 'SET-ME'
# Valid Softlayer apiKey token, Generate one for you or your users, or
# view yours at https://control.softlayer.com/account/users
API_KEY = 'SET-ME'
client = SoftLayer.create_client_from_env(username=USERNAME,
api_key=API_KEY)
hardwareService = client['SoftLayer_Hardware_Server']
serverId = 123456 #Change this for the BM server id.
config = {
"itemPrices": [
{"id": 1857} # Windows Server 2008 R2 Standard Edition (64bit)
]
}
try:
""""
reloadOperatingSystem() creates an OS reload for BM server.
"""""
result = hardwareService.reloadOperatingSystem('FORCE', config, id=serverId)
pp(result)
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 create an OS reload transaction, please refer to following error: "
". % s % s " % (e.faultCode, e.faultString))
有关详细信息,请参阅下面的内容(您只需要将REST调用转换为python):
SoftLayer_Account::getOperatingSystemReloadImages
How to reload different version of XenServer in my BMC in SoftLayer?