'Ensure the value matches the reference\'s ID, if any.'

def _require_matching_id(self, value, ref):

    if (('id' in ref) and (ref['id'] != value)):
        raise exception.ValidationError('Cannot    change    ID')
