def validate_trigger_payload(trigger_type_ref, payload):
 if (not trigger_type_ref):
  return None
 is_system_trigger = (trigger_type_ref in SYSTEM_TRIGGER_TYPES)
 if is_system_trigger:
  payload_schema = SYSTEM_TRIGGER_TYPES[trigger_type_ref]['payload_schema']
 else:
  trigger_type_db = triggers.get_trigger_type_db(trigger_type_ref)
  if (not trigger_type_db):
   return None
  payload_schema = getattr(trigger_type_db, 'payload_schema', {})
  if (not payload_schema):
   return None
 if ((not is_system_trigger) and (not cfg.CONF.system.validate_trigger_payload)):
  LOG.debug(('Got non-system trigger "%s", but trigger payload validation for non-systemtriggers is disabled, skipping validation.' % trigger_type_ref))
  return None
 cleaned = util_schema.validate(instance=payload, schema=payload_schema, cls=util_schema.CustomValidator, use_default=True, allow_default_none=True)
 return cleaned

def validate_trigger_payload ( trigger_type_ref , payload ) : if ( not trigger_type_ref ) : return None is_system_trigger = ( trigger_type_ref in SYSTEM_TRIGGER_TYPES ) if is_system_trigger : payload_schema = SYSTEM_TRIGGER_TYPES [ trigger_type_ref ] [ 'payload_schema' ] else : trigger_type_db = triggers . get_trigger_type_db ( trigger_type_ref ) if ( not trigger_type_db ) : return None payload_schema = getattr ( trigger_type_db , 'payload_schema' , { } ) if ( not payload_schema ) : return None if ( ( not is_system_trigger ) and ( not cfg . CONF . system . validate_trigger_payload ) ) : LOG . debug ( ( 'Got non-system trigger "%s", but trigger payload validation for non-systemtriggers is disabled, skipping validation.' % trigger_type_ref ) ) return None cleaned = util_schema . validate ( instance = payload , schema = payload_schema , cls = util_schema . CustomValidator , use_default = True , allow_default_none = True ) return cleaned
this function validates trigger payload parameters for system and user-defined triggers .