'Serialize the restart policy from an ``IRestartPolicy`` to the format
expected by the docker API.
:param IRestartPolicy restart_policy: The model of the restart policy.
:returns: A dictionary suitable to pass to docker
:raises ValueError: if an unknown policy is passed.'

def _serialize_restart_policy(self, restart_policy):

    SERIALIZERS = {RestartNever: (lambda policy: {u'Name': u''}), RestartAlways: (lambda policy: {u'Name': u'always'}), RestartOnFailure: (lambda policy: {u'Name': u'on-failure', u'MaximumRetryCount': (policy.maximum_retry_count or 0)})}
    try:
        return SERIALIZERS[restart_policy.__class__](restart_policy)
    except KeyError:
        raise ValueError(('Unknown    restart    policy:    %r' % (restart_policy,)))
