# Buggy code
def get_mors_with_properties(
    service_instance, object_type, property_list=None, container_ref=None
):
    """
    Returns a list containing properties and managed object references for the managed object.

    service_instance
        The Service Instance from which to obtain managed object references.

    object_type
        The type of content for which to obtain managed object references.

    property_list
        An optional list of object properties used to return even more filtered managed object reference results.

    container_ref
        An optional reference to the managed object to search under. Can either be an object of type Folder, Datacenter,
        ComputeResource, Resource Pool or HostSystem. If not specified, default behaviour is to search under the inventory
        rootFolder.
    """
    # Get all the content
    content_args = [service_instance, object_type]
    content_kwargs = {
        "property_list": property_list,
        "container_ref": container_ref,
    }
    try:
        content = get_content(*content_args, **content_kwargs)
    except BadStatusLine:
        content = get_content(*content_args, **content_kwargs)

    object_list = []
    for obj in content:
        properties = {}
        for prop in obj.propSet:
            properties[prop.name] = prop.val
            properties["object"] = obj.obj
        object_list.append(properties)

    return object_list


# Traceback (ConnectionResetError)
client.action(fun='create_folder',provider='vmware',kwargs=folderSpec)
{'vmware': {'vmware': {'/TESTDC/vm/DevDeploys03': 'specfied path already exists'}}}
client.profile('vmware-57e946358a5da51360a475ea',names=['testigj99',])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/install/salt_code_git/salt_develop/salt/cloud/__init__.py", line 348, in profile
mapper.run_profile(profile, names, vm_overrides=vm_overrides)
File "/home/install/salt_code_git/salt_develop/salt/cloud/__init__.py", line 1455, in run_profile
ret[name] = self.create(vm_)
File "/home/install/salt_code_git/salt_develop/salt/cloud/__init__.py", line 1284, in create
output = self.clouds[func](vm_)
File "/home/install/salt_code_git/salt_develop/salt/cloud/clouds/vmware.py", line 2340, in create
datacenter_ref = salt.utils.vmware.get_mor_by_property(_get_si(), vim.Datacenter, datacenter)
File "/home/install/salt_code_git/salt_develop/salt/utils/vmware.py", line 696, in get_mor_by_property
object_list = get_mors_with_properties(service_instance, object_type, property_list=[property_name], container_ref=container_ref)
File "/home/install/salt_code_git/salt_develop/salt/utils/vmware.py", line 738, in get_mors_with_properties
local_properties=local_properties)
File "/home/install/salt_code_git/salt_develop/salt/utils/vmware.py", line 622, in get_content
container_ref = service_instance.content.rootFolder
File "/var/www/html/api/venv_api2/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 574, in __call__
return self.f(*args, **kwargs)
File "/var/www/html/api/venv_api2/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 394, in _InvokeAccessor
return self._stub.InvokeAccessor(self, info)
File "/var/www/html/api/venv_api2/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py", line 42, in InvokeAccessor
options=self._pcType.RetrieveOptions(maxObjects=1))
File "/var/www/html/api/venv_api2/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 580, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "/var/www/html/api/venv_api2/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 386, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/var/www/html/api/venv_api2/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1327, in InvokeMethod
resp = conn.getresponse()
File "/usr/lib/python2.7/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python2.7/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python2.7/socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python2.7/ssl.py", line 929, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python2.7/ssl.py", line 791, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python2.7/ssl.py", line 575, in read
v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

# Fixed code
def get_mors_with_properties(
    service_instance, object_type, property_list=None, container_ref=None
):
    """
    Returns a list containing properties and managed object references for the managed object.

    service_instance
        The Service Instance from which to obtain managed object references.

    object_type
        The type of content for which to obtain managed object references.

    property_list
        An optional list of object properties used to return even more filtered managed object reference results.

    container_ref
        An optional reference to the managed object to search under. Can either be an object of type Folder, Datacenter,
        ComputeResource, Resource Pool or HostSystem. If not specified, default behaviour is to search under the inventory
        rootFolder.
    """
    # Get all the content
    content_args = [service_instance, object_type]
    content_kwargs = {
        "property_list": property_list,
        "container_ref": container_ref,
    }
    try:
        content = get_content(*content_args, **content_kwargs)
    except BadStatusLine:
        content = get_content(*content_args, **content_kwargs)
    except IOError as e:
        if e.errno != errno.EPIPE:
            raise e
        content = get_content(*content_args, **content_kwargs)

    object_list = []
    for obj in content:
        properties = {}
        for prop in obj.propSet:
            properties[prop.name] = prop.val
            properties["object"] = obj.obj
        object_list.append(properties)

    return object_list