diff --git a/.github/workflows/manifest-modified.yaml b/.github/workflows/manifest-modified.yaml new file mode 100644 index 0000000..28bd89e --- /dev/null +++ b/.github/workflows/manifest-modified.yaml @@ -0,0 +1,15 @@ +name: NetBox plugin manifest modified + +on: + push: + branches: [ develop ] + paths: + - netbox-plugin.yaml + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + manifest-modified: + uses: netboxlabs/public-workflows/.github/workflows/reusable-plugin-manifest-modified.yml@release diff --git a/README.md b/README.md index 396430d..13f5b29 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This plugin provide following Models: | NetBox 3.7.x | >= 0.12.0 | | NetBox 4.0.x | >= 0.13.3 | | NetBox 4.1.x | >= 0.14.0 | +| NetBox 4.2.x | 0.15.x | ## Installation diff --git a/develop/Dockerfile b/develop/Dockerfile index 0f2f9ff..c32e83d 100644 --- a/develop/Dockerfile +++ b/develop/Dockerfile @@ -1,7 +1,7 @@ ARG python_ver=3.12 FROM python:${python_ver} -ARG netbox_ver=v4.1.3 +ARG netbox_ver=v4.2.1 ENV PYTHONUNBUFFERED 1 RUN mkdir -p /opt diff --git a/netbox-plugin.yaml b/netbox-plugin.yaml new file mode 100644 index 0000000..507ef37 --- /dev/null +++ b/netbox-plugin.yaml @@ -0,0 +1,15 @@ +version: 0.1 +package_name: netbox-bgp +compatibility: + - release: 0.15.0 + netbox_min: 4.2.0 + netbox_max: 4.2.1 + - release: 0.14.0 + netbox_min: 4.1.0 + netbox_max: 4.1.11 + - release: 0.13.3 + netbox_min: 4.0.9 + netbox_max: 4.0.11 + - release: 0.13.2 + netbox_min: 4.0.0 + netbox_max: 4.0.9 diff --git a/netbox_bgp/__init__.py b/netbox_bgp/__init__.py index 6e4280f..5822381 100644 --- a/netbox_bgp/__init__.py +++ b/netbox_bgp/__init__.py @@ -11,8 +11,8 @@ class BGPConfig(PluginConfig): author_email = 'mgk.kolek@gmail.com' base_url = 'bgp' required_settings = [] - min_version = '4.1.0' - max_version = '4.1.99' + min_version = '4.2.0' + max_version = '4.2.99' default_settings = { 'device_ext_page': 'right', 'top_level_menu' : False, diff --git a/netbox_bgp/api/serializers.py b/netbox_bgp/api/serializers.py index 492f155..14232a4 100644 --- a/netbox_bgp/api/serializers.py +++ b/netbox_bgp/api/serializers.py @@ -261,6 +261,7 @@ class RoutingPolicyRuleSerializer(NetBoxModelSerializer): many=True, ) routing_policy = RoutingPolicySerializer(nested=True) + match_community = SerializedPKRelatedField( queryset=Community.objects.all(), serializer=CommunitySerializer, @@ -293,6 +294,7 @@ class Meta: "set_actions", "match_ipv6_address", "description", + "continue_entry", "tags", "custom_fields", "comments", diff --git a/netbox_bgp/forms.py b/netbox_bgp/forms.py index 10801fa..a148162 100644 --- a/netbox_bgp/forms.py +++ b/netbox_bgp/forms.py @@ -20,6 +20,7 @@ CSVChoiceField, CommentField, ) +from utilities.forms import add_blank_choice from utilities.forms.widgets import APISelect, APISelectMultiple from netbox.forms import ( NetBoxModelForm, @@ -27,6 +28,7 @@ NetBoxModelFilterSetForm, NetBoxModelImportForm, ) +from .choices import SessionStatusChoices from .models import ( Community, @@ -206,6 +208,7 @@ class BGPSessionForm(NetBoxModelForm): ) comments = CommentField() + fieldsets = ( FieldSet( "name", @@ -424,10 +427,11 @@ class BGPSessionBulkEditForm(NetBoxModelBulkEditForm): site = DynamicModelChoiceField( label=_("Site"), queryset=Site.objects.all(), required=False ) + status = forms.ChoiceField( - label=_("Status"), - required=False, - choices=SessionStatusChoices, + label=_('Status'), + choices=add_blank_choice(SessionStatusChoices), + required=False ) description = forms.CharField( label=_("Description"), max_length=200, required=False @@ -604,12 +608,21 @@ class RoutingPolicyRuleForm(NetBoxModelForm): queryset=CommunityList.objects.all(), required=False, ) - match_ip_address = forms.MultipleChoiceField( - choices=[], required=False, label="Match IPv4 address Prefix lists" + + match_ip_address = DynamicModelMultipleChoiceField( + queryset=PrefixList.objects.all(), + required=False, + query_params={ + 'family': 'ipv4' + } ) - match_ipv6_address = forms.MultipleChoiceField( - choices=[], required=False, label="Match IPv6 address Prefix lists" + match_ipv6_address = DynamicModelMultipleChoiceField( + queryset=PrefixList.objects.all(), + required=False, + query_params={ + 'family': 'ipv6' + } ) match_custom = forms.JSONField( @@ -627,6 +640,7 @@ class RoutingPolicyRuleForm(NetBoxModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) instance = kwargs.get("instance", {}) + ''' if instance: _prefix_v4 = PrefixList.objects.filter(family="ipv4") _prefix_v6 = PrefixList.objects.filter(family="ipv6") @@ -634,6 +648,7 @@ def __init__(self, *args, **kwargs): prefix_v6 = list(set([(prefix.id, prefix.name) for prefix in _prefix_v6])) self.fields["match_ip_address"].choices = prefix_v4 self.fields["match_ipv6_address"].choices = prefix_v6 + ''' class Meta: model = RoutingPolicyRule diff --git a/netbox_bgp/graphql/types.py b/netbox_bgp/graphql/types.py index d44e858..598b2bb 100644 --- a/netbox_bgp/graphql/types.py +++ b/netbox_bgp/graphql/types.py @@ -82,6 +82,9 @@ class BGPPeerGroupType(NetBoxObjectType): class RoutingPolicyType(NetBoxObjectType): name: str description: str + rules: List[ + Annotated["RoutingPolicyRuleType", strawberry.lazy("netbox_bgp.graphql.types")] + ] @strawberry_django.type( @@ -102,10 +105,10 @@ class RoutingPolicyRuleType(NetBoxObjectType): Annotated["CommunityListType", strawberry.lazy("netbox_bgp.graphql.types")] ] match_ip_address: List[ - Annotated["PrefixType", strawberry.lazy("ipam.graphql.types")] + Annotated["PrefixListType", strawberry.lazy("netbox_bgp.graphql.types")] ] match_ipv6_address: List[ - Annotated["PrefixType", strawberry.lazy("ipam.graphql.types")] + Annotated["PrefixListType", strawberry.lazy("netbox_bgp.graphql.types")] ] @@ -114,6 +117,9 @@ class PrefixListType(NetBoxObjectType): name: str description: str family: str + prefrules: List[ + Annotated["PrefixListRuleType", strawberry.lazy("netbox_bgp.graphql.types")] + ] @strawberry_django.type(PrefixListRule, fields="__all__", filters=PrefixListRuleFilter) @@ -134,6 +140,9 @@ class PrefixListRuleType(NetBoxObjectType): class CommunityListType(NetBoxObjectType): name: str description: str + commlistrules: List[ + Annotated["CommunityListRuleType", strawberry.lazy("netbox_bgp.graphql.types")] + ] @strawberry_django.type( diff --git a/netbox_bgp/tables.py b/netbox_bgp/tables.py index b46f6c9..15fb667 100644 --- a/netbox_bgp/tables.py +++ b/netbox_bgp/tables.py @@ -152,7 +152,7 @@ class Meta(NetBoxTable.Meta): model = RoutingPolicyRule fields = ( 'pk', 'routing_policy', 'index', 'match_statements', - 'set_statements', 'action', 'description' + 'set_statements', 'action', 'description', 'continue_entry' ) diff --git a/netbox_bgp/version.py b/netbox_bgp/version.py index 9e78220..9da2f8f 100644 --- a/netbox_bgp/version.py +++ b/netbox_bgp/version.py @@ -1 +1 @@ -__version__ = "0.14.0" +__version__ = "0.15.0"