Helper function to remove a virtual machine

    name
        Name of the virtual machine

    service_instance
        vCenter service instance for connection and configuration

    datacenter
        Datacenter of the virtual machine

    placement
        Placement information of the virtual machine

def _remove_vm(name, datacenter, service_instance, placement=None,
               power_off=None):
    '''
    Helper function to remove a virtual machine

    name
        Name of the virtual machine

    service_instance
        vCenter service instance for connection and configuration

    datacenter
        Datacenter of the virtual machine

    placement
        Placement information of the virtual machine
    '''
    results = {}
    if placement:
        (resourcepool_object, placement_object) = \
            salt.utils.vmware.get_placement(service_instance,
                                            datacenter,
                                            placement)
    else:
        placement_object = salt.utils.vmware.get_datacenter(service_instance,
                                                            datacenter)
    if power_off:
        power_off_vm(name, datacenter, service_instance)
        results['powered_off'] = True
    vm_ref = salt.utils.vmware.get_mor_by_property(
        service_instance,
        vim.VirtualMachine,
        name,
        property_name='name',
        container_ref=placement_object)
    if not vm_ref:
        raise salt.exceptions.VMwareObjectRetrievalError(
            'The virtual machine object {0} in datacenter '
            '{1} was not found'.format(name, datacenter))
    return results, vm_ref