code: def _change_state(name, action, expected, *args, **kwargs):
      '''
      Change the state of a container
      '''
      pre = state(name)
      if action != 'restart' and pre == expected:
          return {'result': False,
                  'state': {'old': expected, 'new': expected},
                  'comment': ('Container \'{0}\' already {1}'
                              .format(name, expected))}
      _client_wrapper(action, name, *args, **kwargs)
      _clear_context()
      try:
          post = state(name)
      except CommandExecutionError:
          # Container doesn't exist anymore
          post = None
      ret = {'result': post == expected,
             'state': {'old': pre, 'new': post}}
      return ref _change_state(name, action, expected, *args, **kwargs):
      '''
      Change the state of a container
      '''
      pre = state(name)
      if action != 'restart' and pre == expected:
          return {'result': False,
                  'state': {'old': expected, 'new': expected},
                  'comment': ('Container \'{0}\' already {1}'
                              .format(name, expected))}
      _client_wrapper(action, name, *args, **kwargs)
      _clear_context()
      try:
          post = state(name)
      except CommandExecutionError:
          # Container doesn't exist anymore
          post = None
      ret = {'result': post == expected,
             'state': {'old': pre, 'new': post}}
      return ret
docs: Change the state of a container