Beispiel #1
0
 def references_inbound(self) -> Set[str]:
     """
     Get a set of field names under which other objects refer to
     this object. E.g. for a person object, this would typically
     return {'zone-c', 'admin-c', 'tech-c'}.
     """
     result = set()
     from irrd.rpsl.rpsl_objects import OBJECT_CLASS_MAPPING
     for rpsl_object in OBJECT_CLASS_MAPPING.values():
         for field_name, field in rpsl_object.fields.items():
             if self.rpsl_object_class in getattr(field, 'referring', []):
                 result.add(field_name)
     return result
Beispiel #2
0
    def _set_rpsl_object_schemas(self):
        """
        Create the schemas for each specific RPSL object class.
        Each of these implements RPSLObject, and RPSLPerson/RPSLRole
        implement RPSLContact as well.
        """
        self.graphql_types = defaultdict(dict)
        schemas = OrderedDict()
        for object_class, klass in OBJECT_CLASS_MAPPING.items():
            object_name = klass.__name__
            graphql_fields = OrderedDict()
            graphql_fields['rpslPk'] = 'String'
            graphql_fields['objectClass'] = 'String'
            graphql_fields['objectText'] = 'String'
            graphql_fields['updated'] = 'String'
            graphql_fields['journal'] = '[RPSLJournalEntry]'
            for field_name, field in klass.fields.items():
                graphql_type = self._graphql_type_for_rpsl_field(field)
                graphql_fields[snake_to_camel_case(field_name)] = graphql_type
                self.graphql_types[snake_to_camel_case(
                    object_name)][field_name] = graphql_type

                reference_name, reference_type = self._grapql_type_for_reference_field(
                    field_name, field)
                if reference_name and reference_type:
                    graphql_fields[reference_name] = reference_type
                    self.graphql_types[object_name][
                        reference_name] = reference_type

            for field_name in klass.field_extracts:
                if field_name.startswith('asn'):
                    graphql_type = 'ASN'
                elif field_name == 'prefix':
                    graphql_type = 'IP'
                elif field_name == 'prefix_length':
                    graphql_type = 'Int'
                else:
                    graphql_type = 'String'
                graphql_fields[snake_to_camel_case(field_name)] = graphql_type
            if klass.rpki_relevant:
                graphql_fields['rpkiStatus'] = 'RPKIStatus'
                graphql_fields['rpkiMaxLength'] = 'Int'
                self.graphql_types[object_name]['rpki_max_length'] = 'Int'
            implements = 'RPSLContact & RPSLObject' if klass in [
                RPSLPerson, RPSLRole
            ] else 'RPSLObject'
            schema = self._generate_schema_str(object_name, 'type',
                                               graphql_fields, implements)
            schemas[object_name] = schema
        self.rpsl_object_schemas = schemas
Beispiel #3
0
 def delete_all_rpsl_objects_with_journal(self, source):
     """
     Delete all RPSL objects for a source from the database,
     all journal entries and the database status.
     This is intended for cases where a full re-import is done.
     Note that no journal records are kept of this change itself.
     """
     self._flush_rpsl_object_writing_buffer()
     table = RPSLDatabaseObject.__table__
     stmt = table.delete(table.c.source == source)
     self._connection.execute(stmt)
     table = RPSLDatabaseJournal.__table__
     stmt = table.delete(table.c.source == source)
     self._connection.execute(stmt)
     table = RPSLDatabaseStatus.__table__
     stmt = table.delete(table.c.source == source)
     self._connection.execute(stmt)
     # All objects are presumed to have been changed.
     self._object_classes_modified.update(OBJECT_CLASS_MAPPING.keys())
Beispiel #4
0
 def _set_rpsl_object_interface_schema(self):
     """
     Create the schema for RPSLObject, which contains only fields that
     are common to every known RPSL object, along with meta
     """
     common_fields = None
     for rpsl_object_class in OBJECT_CLASS_MAPPING.values():
         if common_fields is None:
             common_fields = set(rpsl_object_class.fields.keys())
         else:
             common_fields = common_fields.intersection(
                 set(rpsl_object_class.fields.keys()))
     common_fields = list(common_fields)
     common_fields = ['rpslPk', 'objectClass', 'objectText', 'updated'
                      ] + common_fields
     common_field_dict = self._dict_for_common_fields(common_fields)
     common_field_dict['journal'] = '[RPSLJournalEntry]'
     schema = self._generate_schema_str('RPSLObject', 'interface',
                                        common_field_dict)
     self.rpsl_object_interface_schema = schema
Beispiel #5
0
     'smtp': {},
     'recipient_override': {},
     'notification_header': {},
 },
 'auth': {
     'override_password': {},
     'authenticate_parents_route_creation': {},
     'gnupg_keyring': {},
     'set_creation': {
         rpsl_object_class: {
             'prefix_required': {},
             'autnum_authentication': {}
         }
         for rpsl_object_class in [
             set_object.rpsl_object_class
             for set_object in OBJECT_CLASS_MAPPING.values()
             if issubclass(set_object, RPSLSet)
         ] + [AUTH_SET_CREATION_COMMON_KEY]
     },
     'password_hashers': {
         hasher_name.lower(): {}
         for hasher_name in PASSWORD_HASHERS_ALL.keys()
     }
 },
 'rpki': {
     'roa_source': {},
     'roa_import_timer': {},
     'slurm_source': {},
     'pseudo_irr_remarks': {},
     'notify_invalid_enabled': {},
     'notify_invalid_subject': {},