def _change_state(cmd,
                  name,
                  expected,
                  stdin=_marker,
                  stdout=_marker,
                  stderr=_marker,
                  with_communicate=_marker,
                  use_vt=_marker,
                  path=None):
    pre = state(name, path=path)
    if pre == expected:
        return {'result': True,
                'state': {'old': expected, 'new': expected},
                'comment': 'Container \'{0}\' already {1}'
                           .format(name, expected)}

    if cmd == 'lxc-destroy':
        # Kill the container first
        scmd = 'lxc-stop'
        if path:
            scmd += ' -P {0}'.format(pipes.quote(path))
        scmd += ' -k -n {0}'.format(name)
        __salt__['cmd.run'](scmd,
                            python_shell=False)

    if path and cmd not in ' -P ':
        cmd += ' -P {0}'.format(pipes.quote(path))
    cmd += ' -n {0}'.format(name)

    # certain lxc commands need to be taken with care (lxc-start)
    # as te command itself mess with double forks; we must not
    # communicate with it, but just wait for the exit status
    pkwargs = {'python_shell': False,
               'with_communicate': with_communicate,
               'use_vt': use_vt,
               'stdin': stdin,
               'stdout': stdout,
               'stderr': stderr}
    for i in [a for a in pkwargs]:
        val = pkwargs[i]
        if val is _marker:
            pkwargs.pop(i, None)

    error = __salt__['cmd.run_stderr'](cmd, **pkwargs)

    if error:
        raise CommandExecutionError(
            'Error changing state for container \'{0}\' using command '
            '\'{1}\': {2}'.format(name, cmd, error)
        )
    if expected is not None:
        # some commands do not wait, so we will
        rcmd = 'lxc-wait'
        if path:
            rcmd += ' -P {0}'.format(pipes.quote(path))
        rcmd += ' -n {0} -s {1}'.format(name, expected.upper())
        __salt__['cmd.run'](rcmd, python_shell=False, timeout=30)
    _clear_context()
    post = state(name, path=path)
    ret = {'result': post == expected,
           'state': {'old': pre, 'new': post}}
    return ret
dataset/ETHPy150Open saltstack/salt/salt/modules/lxc.py/_change_state/swapped operands of `not in`