Stop (terminate) the VM identified by the given id or name.
    When both a name and id are provided, the id is ignored.

    name:
        Name of the defined VM.

    id:
        VM id.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.stop name=alpine

def stop(name=None, id=None):
    '''
    Stop (terminate) the VM identified by the given id or name.
    When both a name and id are provided, the id is ignored.

    name:
        Name of the defined VM.

    id:
        VM id.

    CLI Example:

    .. code-block:: bash

        salt '*' vmctl.stop name=alpine
    '''
    ret = {}
    cmd = ['vmctl', 'stop']

    if not (name or id):
        raise SaltInvocationError('Must provide either "name" or "id"')
    elif name:
        cmd.append(name)
    else:
        cmd.append(id)

    result = __salt__['cmd.run_all'](cmd,
                                     output_loglevel='trace',
                                     python_shell=False)

    if result['retcode'] == 0:
        if re.match('^vmctl: sent request to terminate vm.*', result['stderr']):
            ret['changes'] = True
        else:
            ret['changes'] = False
    else:
        raise CommandExecutionError(
            'Problem encountered running vmctl',
            info={'errors': [result['stderr']], 'changes': ret}
        )

    return ret