<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def status(name=None, id=None):
    '''
    List VMs running on the host, or only the VM specified by ``id``.  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.status           # to list all VMs
        salt '*' vmctl.status name=web1 # to get a single VM
    '''
    ret = {}
    cmd = ['vmctl', 'status']

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

    if result['retcode'] != 0:
        raise CommandExecutionError(
            'Problem encountered running vmctl',
            info={'error': [result['stderr']], 'changes': ret}
        )

    # Grab the header and save it with the lowercase names.
    header = result['stdout'].splitlines()[0].split()
    header = list([x.lower() for x in header])

    # A VM can be in one of the following states (from vmm.c:vcpu_state_decode())
    # - stopped
    # - running
    # - requesting termination
    # - terminated
    # - unknown

    for line in result['stdout'].splitlines()[1:]:
        data = line.split()
        vm = dict(list(zip(header, data)))
        vmname = vm.pop('name')
        if vm['pid'] == '-':
            # If the VM has no PID it's not running.
            vm['state'] = 'stopped'
        elif vmname and data[-2] == '-':
            # When a VM does have a PID and the second to last field is a '-', it's
            # transitioning to another state. A VM name itself cannot contain a
            # '-' so it's safe to split on '-'.
            vm['state'] = data[-1]
        else:
            vm['state'] = 'running'

        # When the status is requested of a single VM (by name) which is stopping,
        # vmctl doesn't print the status line. So we'll parse the full list and
        # return when we've found the requested VM.
        if id and int(vm['id']) == id:
            return {vmname: vm}
        elif name and vmname == name:
            return {vmname: vm}
        else:
            ret[vmname] = vm

    # Assert we've not come this far when an id or name have been provided. That
    # means the requested VM does not exist.
    if id or name:
        return {}

    return ret