我使用Softlayer python API来自动创建VM,并向VM安装一些软件包,然后捕获VM映像。该代码在过去三年中一直有效。该代码在Softlayer内部的VM中运行。但是,从昨天开始,在运行相同代码时,在图像捕获过程中一直出现“对等连接重置”的情况。只是想知道Softlayer中是否有任何变化导致了它?
错误:[Errno 104]对等重置连接
2017-03-31 14:37:03,096-imaginator.cli-Status-错误-失败|
映像生成期间发生未知错误-有关详细信息,请参阅日志。
2017-03-31 14:37:03,097-SoftLayer.transports-信息-开机自检
https://api.service.softlayer.com/xmlrpc/v3/SoftLayer_Virtual_Guest
2017-03-31 14:37:03,097-urllib3.connectionpool-信息-开始新
HTTPS连接(1):api.service.softlayer.com
2017-03-31 14:37:05,719-imaginator.provider.softlayer-信息-
提交的销毁实例请求30219065
我用来捕获图像的代码是:
transactionInfo = self.client['Virtual_Guest'].createArchiveTransaction(name, disks, groupName, id=server.id)
最佳答案
您使用的代码行是正确的。方法createArchiveTransaction()可以正常工作,我能够使用下面的代码示例创建图像模板。
当前,Softlayer的API服务器中存在一些与“对等方重置连接”有关的问题,SoftLayer致力于解决这些问题。一些用户报告说这是暂时的,我建议稍后再试一次。
代码示例:
"""
Create image template.
The script creates a standard image template, it makes a call to the SoftLayer_Virtual_Guest::createArchiveTransaction method
sending the IDs of the disks in the request.
For more information please see below.
Important manual pages:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createArchiveTransaction
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device
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 virtual guest ID you want to create a template
virtualGuestId = 29292929
# The name of the image template
groupName = 'my image name'
# An optional note for the image template
note = 'an optional note'
"""
Build a skeleton SoftLayer_Virtual_Guest_Block_Device object
containing the disks you want to the image.
In this case we are going take an image template of 2 disks
from the virtual machine.
"""
blockDevices = [
{
"id": 45009433,
"complexType": "SoftLayer_Virtual_Guest_Block_Device"
},
{
"id": 45009439,
"complexType": "SoftLayer_Virtual_Guest_Block_Device"
}
]
# Declare a new API service object
client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)
try:
# Creating the transaction for the image template
response = client['SoftLayer_Virtual_Guest'].createArchiveTransaction(groupName, blockDevices, note, id=virtualGuestId)
print(response)
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 the image template. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
问候,
关于python - 捕获VM镜像时,Softlayer获得“对等连接重置”错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43146369/