如何使用SoftLayer API设置硬件注释

如何使用SoftLayer API设置硬件注释,api,ibm-cloud-infrastructure,Api,Ibm Cloud Infrastructure,如何使用python通过API在硬件服务器上设置注释?我一直在查看中的可用方法,但没有看到setNote的方法 要添加注释或编辑其他SoftLayer\u Hardware\u Server属性,需要使用SoftLayer\u Hardware\u Server::editObject方法 下面您可以看到一个向BMS添加注释(id为123456)的示例 """ Edit a bare metal server's basic information This example shows how

如何使用python通过API在硬件服务器上设置注释?我一直在查看中的可用方法,但没有看到
setNote
的方法

要添加注释或编辑其他SoftLayer\u Hardware\u Server属性,需要使用SoftLayer\u Hardware\u Server::editObject方法

下面您可以看到一个向BMS添加注释(id为123456)的示例

"""
Edit a bare metal server's basic information

This example shows how to edit the property 'notes' for a single bare metal server by
using the editObject() method in the SoftLayer_Hardware_Server API service.
See below for more details.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/editObject

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer


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

# The id of the bare metal you wish to edit
hardwareId = 123456

'''
The template object used to edit a SoftLayer_Hardware_Server.
Take account you can edit other properties by using a similar skeleton
'''
templateObject = {
    'notes': 'This is my bare metal server!'
}

# Declare a new API service object
client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)

try:
    # Add notes to the Bare Metal server
    result = client['SoftLayer_Hardware_Server'].editObject(templateObject,
                                                            id=hardwareId)
    print('Bare Metal Server edited')
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to edit the server: %s, %s" % (e.faultCode, e.faultString))
“”“
编辑裸机服务器的基本信息
此示例显示如何通过编辑单个裸机服务器的属性“notes”
在SoftLayer_Hardware_Server API服务中使用editObject()方法。
有关更多详细信息,请参见下文。
重要手册页:
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/editObject
许可证:http://sldn.softlayer.com/article/License
作者:SoftLayer Technologies,Inc。
"""
导入软层
#您的SoftLayer API用户名和密钥。
用户名='设置我'
API_KEY='设置我'
#要编辑的裸机的id
硬件ID=123456
'''
用于编辑SoftLayer\u Hardware\u服务器的模板对象。
请考虑,您可以使用类似的骨架编辑其他特性
'''
templateObject={
“注意”:“这是我的裸机服务器!”
}
#声明一个新的API服务对象
客户端=软件层。从环境创建客户端(用户名=用户名,api密钥=api密钥)
尝试:
#向裸机服务器添加注释
结果=客户端['SoftLayer\U Hardware\U Server'].editObject(templateObject,
id=硬件id)
打印('裸机服务器已编辑')
除SoftLayer.SoftLayer外,错误为e:
打印(“无法编辑服务器:%s,%s”%(e.faultCode,e.faultString))
参考资料:


我希望这对你有帮助

问候,