Delete a single VM, and all of its volumes

def destroy(name, conn=None, call=None):
    '''
    Delete a single VM, and all of its volumes
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    __utils__['cloud.fire_event'](
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        sock_dir=__opts__['sock_dir'],
        args={'name': name},
    )

    if not conn:
        conn = get_conn()   # pylint: disable=E0602

    node = get_node(conn, name)
    if node is None:
        log.error('Unable to find the VM %s', name)
    volumes = conn.list_volumes(node)
    if volumes is None:
        log.error('Unable to find volumes of the VM %s', name)
    # TODO add an option like 'delete_sshkeys' below
    for volume in volumes:
        if volume.extra['volume_type'] != 'DATADISK':
            log.info(
                'Ignoring volume type %s: %s',
                volume.extra['volume_type'], volume.name
            )
            continue
        log.info('Detaching volume: %s', volume.name)
        __utils__['cloud.fire_event'](
            'event',
            'detaching volume',
            'salt/cloud/{0}/detaching'.format(volume.name),
            sock_dir=__opts__['sock_dir'],
            args={'name': volume.name},
        )
        if not conn.detach_volume(volume):
            log.error('Failed to Detach volume: %s', volume.name)
            return False
        log.info('Detached volume: %s', volume.name)
        __utils__['cloud.fire_event'](
            'event',
            'detached volume',
            'salt/cloud/{0}/detached'.format(volume.name),
            sock_dir=__opts__['sock_dir'],
            args={'name': volume.name},
        )

        log.info('Destroying volume: %s', volume.name)
        __utils__['cloud.fire_event'](
            'event',
            'destroying volume',
            'salt/cloud/{0}/destroying'.format(volume.name),
            sock_dir=__opts__['sock_dir'],
            args={'name': volume.name},
        )
        if not conn.destroy_volume(volume):
            log.error('Failed to Destroy volume: %s', volume.name)
            return False
        log.info('Destroyed volume: %s', volume.name)
        __utils__['cloud.fire_event'](
            'event',
            'destroyed volume',
            'salt/cloud/{0}/destroyed'.format(volume.name),
            sock_dir=__opts__['sock_dir'],
            args={'name': volume.name},
        )
    log.info('Destroying VM: %s', name)
    ret = conn.destroy_node(node)
    if not ret:
        log.error('Failed to Destroy VM: %s', name)
        return False
    log.info('Destroyed VM: %s', name)
    # Fire destroy action
    event = salt.utils.event.SaltEvent('master', __opts__['sock_dir'])
    __utils__['cloud.fire_event'](
        'event',
        'destroyed instance',
        'salt/cloud/{0}/destroyed'.format(name),
        sock_dir=__opts__['sock_dir'],
        args={'name': name},
    )
    if __opts__['delete_sshkeys'] is True:
        salt.utils.cloud.remove_sshkey(node.public_ips[0])
    return True