Destroy a node.

    .. versionadded:: 2018.3.0

    Disconnect a minion from the master, and remove its keys.

    Optionally, (if ``remove_config_on_destroy`` is ``True``),
      disables salt-minion from running on the minion, and
      erases the Salt configuration files from it.

    Optionally, (if ``shutdown_on_destroy`` is ``True``),
      orders the minion to halt.

    CLI Example:

    .. code-block:: bash

        salt-cloud --destroy mymachine

def destroy(name, call=None):
    ''' Destroy a node.

    .. versionadded:: 2018.3.0

    Disconnect a minion from the master, and remove its keys.

    Optionally, (if ``remove_config_on_destroy`` is ``True``),
      disables salt-minion from running on the minion, and
      erases the Salt configuration files from it.

    Optionally, (if ``shutdown_on_destroy`` is ``True``),
      orders the minion to halt.

    CLI Example:

    .. code-block:: bash

        salt-cloud --destroy mymachine

    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a, or --action.'
        )

    opts = __opts__

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

    vm_ = get_configured_provider()
    local = salt.client.LocalClient()
    my_info = local.cmd(name, 'grains.get', ['salt-cloud'])
    try:
        vm_.update(my_info[name])  # get profile name to get config value
    except (IndexError, TypeError):
        pass
    if config.get_cloud_config_value(
           'remove_config_on_destroy', vm_, opts, default=True
            ):
        ret = local.cmd(name,  # prevent generating new keys on restart
                        'service.disable',
                        ['salt-minion'])
        if ret and ret[name]:
            log.info('disabled salt-minion service on %s', name)
        ret = local.cmd(name, 'config.get', ['conf_file'])
        if ret and ret[name]:
            confile = ret[name]
            ret = local.cmd(name, 'file.remove', [confile])
            if ret and ret[name]:
                log.info('removed minion %s configuration file %s',
                         name, confile)
        ret = local.cmd(name, 'config.get', ['pki_dir'])
        if ret and ret[name]:
            pki_dir = ret[name]
            ret = local.cmd(name, 'file.remove', [pki_dir])
            if ret and ret[name]:
                log.info(
                    'removed minion %s key files in %s',
                    name,
                    pki_dir)

    if config.get_cloud_config_value(
        'shutdown_on_destroy', vm_, opts, default=False
        ):
        ret = local.cmd(name, 'system.shutdown')
        if ret and ret[name]:
            log.info('system.shutdown for minion %s successful', name)

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

    return {'Destroyed': '{0} was destroyed.'.format(name)}