Extending the App¶
This document provides guidance on how to extend the Nautobot IGP Models app with additional functionality.
Contributing Guidelines¶
Extending the application is welcome! However, it is best to open an issue first to ensure that a pull request would be accepted and makes sense in terms of features and design direction.
Adding New IGP Protocols¶
To add support for a new IGP protocol (e.g., EIGRP, RIP, BGP):
- Create Protocol Configuration Model: Add a new model inheriting from
PrimaryModelthat includes: - A foreign key to
IGPRoutingInstance - Protocol-specific configuration fields
-
Appropriate validators and constraints
-
Create Interface Configuration Model: Add a corresponding interface configuration model with:
- Foreign key to your protocol configuration model
- Foreign key to
Interfacemodel -
Interface-level protocol settings
-
Add API Components:
- Serializer in
api/serializers.py - ViewSet in
api/views.py -
URL patterns in
api/urls.py -
Add UI Components:
- Form class in
forms.py - Filter class in
filters.py - Table class in
tables.py - Views in
views.py -
Templates in
templates/nautobot_igp_models/ -
Update Navigation: Add navigation menu items in
navigation.py -
Write Tests: Add comprehensive test coverage:
- Model tests
- Form tests
- Filter tests
- API tests
- View tests
Extending Existing Models¶
If you need to add fields to existing models:
- Update the model in
models.py - Create a migration:
nautobot-server makemigrations nautobot_igp_models - Update forms, filters, and serializers accordingly
- Add tests for the new functionality
- Update documentation
Adding Custom Validation¶
Custom validation can be added at multiple levels:
- Model Level: Override the
clean()method in your model - Form Level: Add validation in form's
clean()orclean_<fieldname>()methods - Serializer Level: Add validation in serializer's
validate()orvalidate_<fieldname>()methods
Adding Management Commands¶
To add custom management commands:
- Create a new file in
nautobot_igp_models/management/commands/ - Inherit from
BaseCommand - Implement the
handle()method - Document the command usage
Integration Points¶
The app provides several integration points:
- Signals: The app emits Django signals on model changes that can be used for integration
- REST API: All models are exposed via REST API for external integrations
- GraphQL: Models can be accessed via Nautobot's GraphQL interface
- Custom Scripts/Jobs: Create Nautobot Jobs that interact with IGP models
Best Practices¶
- Follow the existing code style and patterns
- Write comprehensive tests for all new functionality
- Update documentation for user-facing changes
- Use type hints where appropriate
- Validate data at multiple levels (model, form, serializer)
- Consider backwards compatibility when making changes