Susan D
Susan D

Reputation: 11

Softlayer Got "Connection reset by peer" error when capturing a VM image

I use the Softlayer python API to automate create a VM and install some packages to the VM, then capture the VM image. The code worked for the last three years. The code runs in a VM inside Softlayer. But I kept getting "Connection reset by peer" during image capturing when running the same code since yesterday. Just wondering if anything has changed in Softlayer that causing it?

error: [Errno 104] Connection reset by peer

2017-03-31 14:37:03,096 - imaginator.cli-Status - ERROR - Failed | Unknown errors occurred during image building - see log for details.

2017-03-31 14:37:03,097 - SoftLayer.transports - INFO - POST https://api.service.softlayer.com/xmlrpc/v3/SoftLayer_Virtual_Guest

2017-03-31 14:37:03,097 - urllib3.connectionpool - INFO - Starting new HTTPS connection (1): api.service.softlayer.com

2017-03-31 14:37:05,719 - imaginator.provider.softlayer - INFO - Submitted request to destroy instance 30219065

The code I used to capture the image is:

transactionInfo = self.client['Virtual_Guest'].createArchiveTransaction(name, disks, groupName, id=server.id)

Upvotes: 1

Views: 222

Answers (1)

Albert Camacho
Albert Camacho

Reputation: 1104

The code line you are using is correct. The method createArchiveTransaction() is working as expected, I was able to create an image template using the code example below.

Currently, there are some issues in Softlayer's API server related to “connection reset by peer” and SoftLayer is working to resolve them. Some users reported that this is temporal, I suggest to try it again after a while.

Code example:

"""
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))   

Regards,

Upvotes: 2

Related Questions