Coverage for ipam/choices.py: 100%
65 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1from django.utils.translation import gettext_lazy as _
3from utilities.choices import Choice, ChoiceSet
6class IPAddressFamilyChoices(ChoiceSet):
8 FAMILY_4 = 4
9 FAMILY_6 = 6
11 CHOICES = (
12 Choice(FAMILY_4, 'IPv4'),
13 Choice(FAMILY_6, 'IPv6'),
14 )
17#
18# Prefixes
19#
21class PrefixStatusChoices(ChoiceSet):
22 key = 'Prefix.status'
24 STATUS_CONTAINER = 'container'
25 STATUS_ACTIVE = 'active'
26 STATUS_RESERVED = 'reserved'
27 STATUS_DEPRECATED = 'deprecated'
29 CHOICES = [
30 Choice(STATUS_CONTAINER, _('Container'), color='gray', description=_('Organizes a set of child prefixes')),
31 Choice(STATUS_ACTIVE, _('Active'), color='blue', description=_('Provisioned and in use')),
32 Choice(STATUS_RESERVED, _('Reserved'), color='cyan', description=_('Designated for future use')),
33 Choice(STATUS_DEPRECATED, _('Deprecated'), color='red', description=_('No longer in use')),
34 ]
37#
38# IP Ranges
39#
41class IPRangeStatusChoices(ChoiceSet):
42 key = 'IPRange.status'
44 STATUS_ACTIVE = 'active'
45 STATUS_RESERVED = 'reserved'
46 STATUS_DEPRECATED = 'deprecated'
48 CHOICES = [
49 Choice(STATUS_ACTIVE, _('Active'), color='blue', description=_('Provisioned and in use')),
50 Choice(STATUS_RESERVED, _('Reserved'), color='cyan', description=_('Designated for future use')),
51 Choice(STATUS_DEPRECATED, _('Deprecated'), color='red', description=_('No longer in use')),
52 ]
55#
56# IP Addresses
57#
59class IPAddressStatusChoices(ChoiceSet):
60 key = 'IPAddress.status'
62 STATUS_ACTIVE = 'active'
63 STATUS_RESERVED = 'reserved'
64 STATUS_DEPRECATED = 'deprecated'
65 STATUS_DHCP = 'dhcp'
66 STATUS_SLAAC = 'slaac'
68 CHOICES = [
69 Choice(STATUS_ACTIVE, _('Active'), color='blue', description=_('Provisioned and in use')),
70 Choice(STATUS_RESERVED, _('Reserved'), color='cyan', description=_('Designated for future use')),
71 Choice(STATUS_DEPRECATED, _('Deprecated'), color='red', description=_('No longer in use')),
72 Choice(STATUS_DHCP, _('DHCP'), color='purple', description=_('Assigned dynamically via DHCP')),
73 Choice(
74 STATUS_SLAAC,
75 _('SLAAC'),
76 color='purple',
77 description=_('Assigned via IPv6 stateless address autoconfiguration')
78 ),
79 ]
82class IPAddressRoleChoices(ChoiceSet):
84 ROLE_LOOPBACK = 'loopback'
85 ROLE_SECONDARY = 'secondary'
86 ROLE_ANYCAST = 'anycast'
87 ROLE_VIP = 'vip'
88 ROLE_VRRP = 'vrrp'
89 ROLE_HSRP = 'hsrp'
90 ROLE_GLBP = 'glbp'
91 ROLE_CARP = 'carp'
93 CHOICES = (
94 Choice(ROLE_LOOPBACK, _('Loopback'), color='gray', description=_('A loopback interface address')),
95 Choice(ROLE_SECONDARY, _('Secondary'), color='blue', description=_('A secondary address on an interface')),
96 Choice(ROLE_ANYCAST, _('Anycast'), color='yellow', description=_('An address shared among multiple nodes')),
97 Choice(ROLE_VIP, 'VIP', color='purple', description=_('A virtual IP address')),
98 Choice(ROLE_VRRP, 'VRRP', color='green', description=_('A virtual address managed by VRRP')),
99 Choice(ROLE_HSRP, 'HSRP', color='green', description=_('A virtual address managed by HSRP')),
100 Choice(ROLE_GLBP, 'GLBP', color='green', description=_('A virtual address managed by GLBP')),
101 Choice(ROLE_CARP, 'CARP', color='green', description=_('A virtual address managed by CARP')),
102 )
105#
106# FHRP
107#
109class FHRPGroupProtocolChoices(ChoiceSet):
111 PROTOCOL_VRRP2 = 'vrrp2'
112 PROTOCOL_VRRP3 = 'vrrp3'
113 PROTOCOL_HSRP = 'hsrp'
114 PROTOCOL_GLBP = 'glbp'
115 PROTOCOL_CARP = 'carp'
116 PROTOCOL_CLUSTERXL = 'clusterxl'
117 PROTOCOL_OTHER = 'other'
119 CHOICES = (
120 (_('Standard'), (
121 Choice(PROTOCOL_VRRP2, 'VRRPv2', description=_('Virtual Router Redundancy Protocol version 2')),
122 Choice(PROTOCOL_VRRP3, 'VRRPv3', description=_('Virtual Router Redundancy Protocol version 3')),
123 Choice(PROTOCOL_CARP, 'CARP', description=_('Common Address Redundancy Protocol')),
124 )),
125 (_('CheckPoint'), (
126 Choice(PROTOCOL_CLUSTERXL, 'ClusterXL', description=_('Check Point ClusterXL high-availability protocol')),
127 )),
128 (_('Cisco'), (
129 Choice(PROTOCOL_HSRP, 'HSRP', description=_('Hot Standby Router Protocol')),
130 Choice(PROTOCOL_GLBP, 'GLBP', description=_('Gateway Load Balancing Protocol')),
131 )),
132 Choice(PROTOCOL_OTHER, 'Other'),
133 )
136class FHRPGroupAuthTypeChoices(ChoiceSet):
138 AUTHENTICATION_PLAINTEXT = 'plaintext'
139 AUTHENTICATION_MD5 = 'md5'
141 CHOICES = (
142 Choice(AUTHENTICATION_PLAINTEXT, _('Plaintext'), description=_('Authentication using a cleartext password')),
143 Choice(AUTHENTICATION_MD5, 'MD5', description=_('Authentication using an MD5 hash')),
144 )
147#
148# VLANs
149#
151class VLANStatusChoices(ChoiceSet):
152 key = 'VLAN.status'
154 STATUS_ACTIVE = 'active'
155 STATUS_RESERVED = 'reserved'
156 STATUS_DEPRECATED = 'deprecated'
158 CHOICES = [
159 Choice(STATUS_ACTIVE, _('Active'), color='blue', description=_('Provisioned and in use')),
160 Choice(STATUS_RESERVED, _('Reserved'), color='cyan', description=_('Designated for future use')),
161 Choice(STATUS_DEPRECATED, _('Deprecated'), color='red', description=_('No longer in use')),
162 ]
165class VLANQinQRoleChoices(ChoiceSet):
167 ROLE_SERVICE = 'svlan'
168 ROLE_CUSTOMER = 'cvlan'
170 CHOICES = [
171 Choice(ROLE_SERVICE, _('Service'), color='blue', description=_('An outer service VLAN (S-VLAN)')),
172 Choice(ROLE_CUSTOMER, _('Customer'), color='orange', description=_('An inner customer VLAN (C-VLAN)')),
173 ]
176#
177# Services
178#
180class ServiceProtocolChoices(ChoiceSet):
182 PROTOCOL_TCP = 'tcp'
183 PROTOCOL_UDP = 'udp'
184 PROTOCOL_SCTP = 'sctp'
186 CHOICES = (
187 Choice(PROTOCOL_TCP, 'TCP'),
188 Choice(PROTOCOL_UDP, 'UDP'),
189 Choice(PROTOCOL_SCTP, 'SCTP'),
190 )