19
19
20
20
from .models import (
21
21
ASN , ASNStatusChoices , Community , BGPSession ,
22
- SessionStatusChoices , RoutingPolicy , BGPPeerGroup , RoutingPolicyRule
22
+ SessionStatusChoices , RoutingPolicy , BGPPeerGroup ,
23
+ RoutingPolicyRule , PrefixList , PrefixListRule
24
+
23
25
)
24
26
25
27
@@ -421,7 +423,7 @@ class RoutingPolicyForm(NetBoxModelForm):
421
423
422
424
class Meta :
423
425
model = RoutingPolicy
424
- fields = ['name' , 'description' ]
426
+ fields = ['name' , 'description' , 'tags' ]
425
427
426
428
427
429
class BGPPeerGroupFilterForm (NetBoxModelFilterSetForm ):
@@ -460,19 +462,24 @@ class Meta:
460
462
461
463
462
464
class RoutingPolicyRuleForm (NetBoxModelForm ):
465
+ continue_entry = forms .IntegerField (
466
+ required = False ,
467
+ label = 'Continue' ,
468
+ help_text = 'Null for disable, 0 to next entry, or any sequence number'
469
+ )
463
470
match_community = DynamicModelMultipleChoiceField (
464
471
queryset = Community .objects .all (),
465
472
required = False ,
466
473
)
467
- match_ip = DynamicModelMultipleChoiceField (
468
- queryset = Prefix .objects .all (),
474
+ match_ip_address = DynamicModelMultipleChoiceField (
475
+ queryset = PrefixList .objects .all (),
469
476
required = False ,
470
- label = 'Match Prefix' ,
477
+ label = 'Match IP address Prefix lists ' ,
471
478
)
472
- match_ip_cond = forms .JSONField (
473
- label = 'Match filtered prefixes' ,
474
- help_text = 'Filter for Prefixes, e.g., {"site__name": "site1", "tenant__name": "tenant1"}' ,
479
+ match_ipv6_address = DynamicModelMultipleChoiceField (
480
+ queryset = PrefixList .objects .all (),
475
481
required = False ,
482
+ label = 'Match IPv6 address Prefix lists' ,
476
483
)
477
484
match_custom = forms .JSONField (
478
485
label = 'Custom Match' ,
@@ -488,7 +495,57 @@ class RoutingPolicyRuleForm(NetBoxModelForm):
488
495
class Meta :
489
496
model = RoutingPolicyRule
490
497
fields = [
491
- 'routing_policy' , 'index' , 'action' , 'match_community' ,
492
- 'match_ip ' , 'match_ip_cond ' , 'match_custom' ,
498
+ 'routing_policy' , 'index' , 'action' , 'continue_entry' , ' match_community' ,
499
+ 'match_ip_address ' , 'match_ipv6_address ' , 'match_custom' ,
493
500
'set_actions' , 'description' ,
494
501
]
502
+
503
+
504
+ class PrefixListFilterForm (NetBoxModelFilterSetForm ):
505
+ model = PrefixList
506
+ q = forms .CharField (
507
+ required = False ,
508
+ label = 'Search'
509
+ )
510
+
511
+ tag = TagFilterField (model )
512
+
513
+
514
+ class PrefixListForm (NetBoxModelForm ):
515
+ tags = DynamicModelMultipleChoiceField (
516
+ queryset = Tag .objects .all (),
517
+ required = False
518
+ )
519
+
520
+ class Meta :
521
+ model = PrefixList
522
+ fields = ['name' , 'description' , 'tags' ]
523
+
524
+
525
+ class PrefixListRuleForm (NetBoxModelForm ):
526
+ prefix = DynamicModelChoiceField (
527
+ queryset = Prefix .objects .all (),
528
+ required = False ,
529
+ help_text = 'NetBox Prefix Object' ,
530
+ )
531
+ prefix_custom = IPNetworkFormField (
532
+ required = False ,
533
+ label = 'Prefix' ,
534
+ help_text = 'Just IP field for define special prefix like 0.0.0.0/0' ,
535
+ )
536
+ ge = forms .IntegerField (
537
+ label = 'Greater than or equal to' ,
538
+ required = False ,
539
+ )
540
+ le = forms .IntegerField (
541
+ label = 'Less than or equal to' ,
542
+ required = False ,
543
+ )
544
+
545
+ class Meta :
546
+ model = PrefixListRule
547
+ fields = [
548
+ 'prefix_list' , 'index' ,
549
+ 'action' , 'prefix' , 'prefix_custom' ,
550
+ 'ge' , 'le'
551
+ ]
0 commit comments