def get_vm_by_property(service_instance, name, datacenter=None, vm_properties=None,
                       traversal_spec=None, parent_ref=None):
    '''
    Get virtual machine properties based on the traversal specs and properties list,
    returns Virtual Machine object with properties.

    service_instance
        Service instance object to access vCenter

    name
        Name of the virtual machine.

    datacenter
        Datacenter name

    vm_properties
        List of vm properties.

    traversal_spec
        Traversal Spec object(s) for searching.

    parent_ref
        Container Reference object for searching under a given object.
    '''
    if datacenter and not parent_ref:
        parent_ref = salt.utils.vmware.get_datacenter(service_instance, datacenter)
    if not vm_properties:
        vm_properties = ['name',
                         'config.hardware.device',
                         'summary.storage.committed',
                         'summary.storage.uncommitted',
                         'summary.storage.unshared',
                         'layoutEx.file',
                         'config.guestFullName',
                         'config.guestId',
                         'guest.net',
                         'config.hardware.memoryMB',
                         'config.hardware.numCPU',
                         'config.files.vmPathName',
                         'summary.runtime.powerState',
                         'guest.toolsStatus']
    vm_list = salt.utils.vmware.get_mors_with_properties(service_instance,
                                                         vim.VirtualMachine,
                                                         vm_properties,
                                                         container_ref=parent_ref,
                                                         traversal_spec=traversal_spec)
    vm_formatted = [vm for vm in vm_list if vm['name'] == name]
    if not vm_formatted:
        raise salt.exceptions.VMwareObjectRetrievalError('The virtual machine was not found.')
    elif len(vm_formatted) > 1:
        raise salt.exceptions.VMwareMultipleObjectsError(' '.join([
            'Multiple virtual machines were found with the'
            'same name, please specify a container.']))
    return vm_formatted[0]
Get virtual machine properties based on the traversal specs and properties list,
    returns Virtual Machine object with properties.

    service_instance
        Service instance object to access vCenter

    name
        Name of the virtual machine.

    datacenter
        Datacenter name

    vm_properties
        List of vm properties.

    traversal_spec
        Traversal Spec object(s) for searching.

    parent_ref
        Container Reference object for searching under a given object.