Coverage for vpn/ui/panels.py: 100%

71 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 18:35 +0000

1from django.utils.translation import gettext_lazy as _ 

2 

3from netbox.ui import attrs, panels 

4 

5 

6class TunnelGroupPanel(panels.OrganizationalObjectPanel): 

7 pass 

8 

9 

10class TunnelPanel(panels.ObjectAttributesPanel): 

11 name = attrs.TextAttr('name') 

12 status = attrs.ChoiceAttr('status') 

13 group = attrs.RelatedObjectAttr('group', linkify=True) 

14 description = attrs.TextAttr('description') 

15 encapsulation = attrs.ChoiceAttr('encapsulation') 

16 ipsec_profile = attrs.RelatedObjectAttr('ipsec_profile', linkify=True, label=_('IPSec profile')) 

17 tunnel_id = attrs.TextAttr('tunnel_id', label=_('Tunnel ID')) 

18 tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group') 

19 

20 

21class TunnelTerminationPanel(panels.ObjectAttributesPanel): 

22 tunnel = attrs.RelatedObjectAttr('tunnel', linkify=True) 

23 role = attrs.ChoiceAttr('role') 

24 parent_object = attrs.RelatedObjectAttr( 

25 'termination.parent_object', linkify=True, label=_('Parent') 

26 ) 

27 termination = attrs.RelatedObjectAttr('termination', linkify=True, label=_('Interface')) 

28 outside_ip = attrs.RelatedObjectAttr('outside_ip', linkify=True, label=_('Outside IP')) 

29 

30 

31class IKEProposalPanel(panels.ObjectAttributesPanel): 

32 name = attrs.TextAttr('name') 

33 description = attrs.TextAttr('description') 

34 authentication_method = attrs.ChoiceAttr('authentication_method', label=_('Authentication method')) 

35 encryption_algorithm = attrs.ChoiceAttr('encryption_algorithm', label=_('Encryption algorithm')) 

36 authentication_algorithm = attrs.ChoiceAttr('authentication_algorithm', label=_('Authentication algorithm')) 

37 group = attrs.ChoiceAttr('group', label=_('DH group')) 

38 sa_lifetime = attrs.TextAttr('sa_lifetime', label=_('SA lifetime (seconds)')) 

39 

40 

41class IKEPolicyPanel(panels.ObjectAttributesPanel): 

42 name = attrs.TextAttr('name') 

43 description = attrs.TextAttr('description') 

44 version = attrs.ChoiceAttr('version', label=_('IKE version')) 

45 mode = attrs.ChoiceAttr('mode') 

46 preshared_key = attrs.TemplatedAttr( 

47 'preshared_key', 

48 label=_('Pre-shared key'), 

49 template_name='vpn/attrs/preshared_key.html', 

50 ) 

51 

52 

53class IPSecProposalPanel(panels.ObjectAttributesPanel): 

54 name = attrs.TextAttr('name') 

55 description = attrs.TextAttr('description') 

56 encryption_algorithm = attrs.ChoiceAttr('encryption_algorithm', label=_('Encryption algorithm')) 

57 authentication_algorithm = attrs.ChoiceAttr('authentication_algorithm', label=_('Authentication algorithm')) 

58 sa_lifetime_seconds = attrs.TextAttr('sa_lifetime_seconds', label=_('SA lifetime (seconds)')) 

59 sa_lifetime_data = attrs.TextAttr('sa_lifetime_data', label=_('SA lifetime (KB)')) 

60 

61 

62class IPSecPolicyPanel(panels.ObjectAttributesPanel): 

63 name = attrs.TextAttr('name') 

64 description = attrs.TextAttr('description') 

65 pfs_group = attrs.ChoiceAttr('pfs_group', label=_('PFS group')) 

66 

67 

68class IPSecProfilePanel(panels.ObjectAttributesPanel): 

69 name = attrs.TextAttr('name') 

70 description = attrs.TextAttr('description') 

71 mode = attrs.ChoiceAttr('mode') 

72 

73 

74class IPSecProfileIKEPolicyPanel(panels.ObjectAttributesPanel): 

75 title = _('IKE Policy') 

76 name = attrs.RelatedObjectAttr('ike_policy', linkify=True) 

77 description = attrs.TextAttr('ike_policy.description') 

78 version = attrs.ChoiceAttr('ike_policy.version', label=_('IKE version')) 

79 mode = attrs.ChoiceAttr('ike_policy.mode') 

80 proposals = attrs.RelatedObjectListAttr('ike_policy.proposals', linkify=True) 

81 

82 

83class IPSecProfileIPSecPolicyPanel(panels.ObjectAttributesPanel): 

84 title = _('IPSec Policy') 

85 name = attrs.RelatedObjectAttr('ipsec_policy', linkify=True) 

86 description = attrs.TextAttr('ipsec_policy.description') 

87 proposals = attrs.RelatedObjectListAttr('ipsec_policy.proposals', linkify=True) 

88 pfs_group = attrs.ChoiceAttr('ipsec_policy.pfs_group', label=_('PFS group')) 

89 

90 

91class L2VPNPanel(panels.ObjectAttributesPanel): 

92 name = attrs.TextAttr('name') 

93 identifier = attrs.TextAttr('identifier') 

94 type = attrs.ChoiceAttr('type') 

95 status = attrs.ChoiceAttr('status') 

96 description = attrs.TextAttr('description') 

97 tenant = attrs.RelatedObjectAttr('tenant', linkify=True) 

98 

99 

100class L2VPNTerminationPanel(panels.ObjectAttributesPanel): 

101 l2vpn = attrs.RelatedObjectAttr('l2vpn', linkify=True, label=_('L2VPN')) 

102 assigned_object = attrs.RelatedObjectAttr('assigned_object', linkify=True, label=_('Assigned object'))