def exec_validators_with_resource(idl, schema, resource, http_method): p_table_name = None p_row = None child_resource = resource # Set parent info if a child exists if resource.next is not None: p_table_name = resource.table p_row = idl.tables[p_table_name].rows[resource.row] child_resource = resource.next table_name = child_resource.table row = idl.tables[table_name].rows[child_resource.row] validator.exec_validators(idl, schema, table_name, row, http_method, p_table_name, p_row)
def _exec_validator_with_op(self, op_data): success = True method = op_data.method table_name = op_data.resource_table row = op_data.resource_row p_table_name = op_data.p_resource_table p_row = op_data.p_resource_row try: validator.exec_validators(self.idl, self.schema, table_name, row, method, p_table_name, p_row) except ValidationError as e: app_log.info("Validation failed:") app_log.info(e.error) self.errors.append(e.error) success = False return success
def _exec_validator_with_op(self, op_data): success = True method = op_data.method table_name = op_data.resource_table row = op_data.resource_row p_table_name = op_data.p_resource_table p_row = op_data.p_resource_row try: validator.exec_validators(self.idl, self.extschema, table_name, row, method, p_table_name, p_row) except ValidationError as e: vlog.dbg(str(e.error)) self.errors.append(e.error) success = False except Exception as e: success = False return success
def exec_validators_with_resource(idl, schema, resource, http_method): p_table_name = None p_row = None child_resource = resource # Set parent info if a child exists if resource.next is not None: p_table_name = resource.table p_row = idl.tables[p_table_name].rows[resource.row] child_resource = resource.next table_name = child_resource.table if child_resource.row is None and resource.relation == OVSDB_SCHEMA_CHILD: children = p_row.__getattr__(resource.column) if isinstance(children, ovs.db.idl.Row): children = [children] elif isinstance(children, dict): children = children.values() for row in children: validator.exec_validators(idl, schema, table_name, row, http_method, p_table_name, p_row) elif child_resource.row is None and resource.relation == OVSDB_SCHEMA_BACK_REFERENCE: p_row = idl.tables[p_table_name].rows[resource.row] refcol = None refkeys = schema.ovs_tables[table_name].references for key, value in refkeys.iteritems(): if (value.relation == OVSDB_SCHEMA_PARENT and value.ref_table == p_table_name): refcol = key break for row in idl.tables[child_resource.table].rows.itervalues(): if row.__getattr__(refcol) == p_row: validator.exec_validators(idl, schema, table_name, row, http_method, p_table_name, p_row) else: row = idl.tables[table_name].rows[child_resource.row] validator.exec_validators(idl, schema, table_name, row, http_method, p_table_name, p_row)