Skip to content

Commit b26ba89

Browse files
authored
Merge pull request #389 from innogames/k_af_aware_supernet
AF-aware supernet calculation
2 parents 4f61f23 + 5f184d4 commit b26ba89

File tree

4 files changed

+365
-147
lines changed

4 files changed

+365
-147
lines changed

serveradmin/serverdb/fixtures/ip_addr_type.json

Lines changed: 141 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@
4141
},
4242
{
4343
"model": "serverdb.attribute",
44-
"pk": "ip_config",
44+
"pk": "ip_config_ipv4",
4545
"fields": {
4646
"type": "inet",
47+
"inet_address_family": "IPV4",
4748
"multi": false,
4849
"hovertext": "",
4950
"group": "other",
@@ -55,6 +56,73 @@
5556
"regexp": "\\A.*\\Z"
5657
}
5758
},
59+
{
60+
"model": "serverdb.attribute",
61+
"pk": "ip_config_ipv6",
62+
"fields": {
63+
"type": "inet",
64+
"inet_address_family": "IPV6",
65+
"multi": false,
66+
"hovertext": "",
67+
"group": "other",
68+
"help_link": null,
69+
"readonly": false,
70+
"target_servertype": null,
71+
"reversed_attribute": null,
72+
"clone": false,
73+
"regexp": "\\A.*\\Z"
74+
}
75+
},
76+
{
77+
"model": "serverdb.attribute",
78+
"pk": "supernet_no_af",
79+
"fields": {
80+
"type": "supernet",
81+
"multi": false,
82+
"hovertext": "",
83+
"group": "other",
84+
"help_link": null,
85+
"readonly": true,
86+
"target_servertype": "network",
87+
"reversed_attribute": null,
88+
"clone": false,
89+
"regexp": "\\A.*\\Z"
90+
}
91+
},
92+
{
93+
"model": "serverdb.attribute",
94+
"pk": "supernet_ipv4",
95+
"fields": {
96+
"type": "supernet",
97+
"inet_address_family": "IPV4",
98+
"multi": false,
99+
"hovertext": "",
100+
"group": "other",
101+
"help_link": null,
102+
"readonly": true,
103+
"target_servertype": "network",
104+
"reversed_attribute": null,
105+
"clone": false,
106+
"regexp": "\\A.*\\Z"
107+
}
108+
},
109+
{
110+
"model": "serverdb.attribute",
111+
"pk": "supernet_ipv6",
112+
"fields": {
113+
"type": "supernet",
114+
"inet_address_family": "IPV6",
115+
"multi": false,
116+
"hovertext": "",
117+
"group": "other",
118+
"help_link": null,
119+
"readonly": true,
120+
"target_servertype": "network",
121+
"reversed_attribute": null,
122+
"clone": false,
123+
"regexp": "\\A.*\\Z"
124+
}
125+
},
58126
{
59127
"model": "serverdb.attribute",
60128
"pk": "ip_config_new",
@@ -76,7 +144,7 @@
76144
"pk": 7,
77145
"fields": {
78146
"servertype": "loadbalancer",
79-
"attribute": "ip_config",
147+
"attribute": "ip_config_ipv4",
80148
"related_via_attribute": null,
81149
"consistent_via_attribute": null,
82150
"required": false,
@@ -89,7 +157,20 @@
89157
"pk": 9,
90158
"fields": {
91159
"servertype": "network",
92-
"attribute": "ip_config",
160+
"attribute": "ip_config_ipv4",
161+
"related_via_attribute": null,
162+
"consistent_via_attribute": null,
163+
"required": false,
164+
"default_value": null,
165+
"default_visible": false
166+
}
167+
},
168+
{
169+
"model": "serverdb.servertypeattribute",
170+
"pk": 10,
171+
"fields": {
172+
"servertype": "network",
173+
"attribute": "ip_config_ipv6",
93174
"related_via_attribute": null,
94175
"consistent_via_attribute": null,
95176
"required": false,
@@ -102,7 +183,7 @@
102183
"pk": 12,
103184
"fields": {
104185
"servertype": "host",
105-
"attribute": "ip_config",
186+
"attribute": "ip_config_ipv4",
106187
"related_via_attribute": null,
107188
"consistent_via_attribute": null,
108189
"required": false,
@@ -114,8 +195,8 @@
114195
"model": "serverdb.servertypeattribute",
115196
"pk": 13,
116197
"fields": {
117-
"servertype": "other_network",
118-
"attribute": "ip_config",
198+
"servertype": "host",
199+
"attribute": "ip_config_ipv6",
119200
"related_via_attribute": null,
120201
"consistent_via_attribute": null,
121202
"required": false,
@@ -128,7 +209,7 @@
128209
"pk": 14,
129210
"fields": {
130211
"servertype": "host",
131-
"attribute": "ip_config_new",
212+
"attribute": "supernet_no_af",
132213
"related_via_attribute": null,
133214
"consistent_via_attribute": null,
134215
"required": false,
@@ -139,6 +220,58 @@
139220
{
140221
"model": "serverdb.servertypeattribute",
141222
"pk": 15,
223+
"fields": {
224+
"servertype": "host",
225+
"attribute": "supernet_ipv4",
226+
"related_via_attribute": null,
227+
"consistent_via_attribute": null,
228+
"required": false,
229+
"default_value": null,
230+
"default_visible": false
231+
}
232+
},
233+
{
234+
"model": "serverdb.servertypeattribute",
235+
"pk": 16,
236+
"fields": {
237+
"servertype": "host",
238+
"attribute": "supernet_ipv6",
239+
"related_via_attribute": null,
240+
"consistent_via_attribute": null,
241+
"required": false,
242+
"default_value": null,
243+
"default_visible": false
244+
}
245+
},
246+
{
247+
"model": "serverdb.servertypeattribute",
248+
"pk": 17,
249+
"fields": {
250+
"servertype": "other_network",
251+
"attribute": "ip_config_ipv4",
252+
"related_via_attribute": null,
253+
"consistent_via_attribute": null,
254+
"required": false,
255+
"default_value": null,
256+
"default_visible": false
257+
}
258+
},
259+
{
260+
"model": "serverdb.servertypeattribute",
261+
"pk": 18,
262+
"fields": {
263+
"servertype": "host",
264+
"attribute": "ip_config_new",
265+
"related_via_attribute": null,
266+
"consistent_via_attribute": null,
267+
"required": false,
268+
"default_value": null,
269+
"default_visible": false
270+
}
271+
},
272+
{
273+
"model": "serverdb.servertypeattribute",
274+
"pk": 19,
142275
"fields": {
143276
"servertype": "loadbalancer",
144277
"attribute": "ip_config_new",
@@ -151,7 +284,7 @@
151284
},
152285
{
153286
"model": "serverdb.servertypeattribute",
154-
"pk": 16,
287+
"pk": 20,
155288
"fields": {
156289
"servertype": "network",
157290
"attribute": "ip_config_new",

serveradmin/serverdb/models.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,6 @@ class Meta:
517517
def __str__(self):
518518
return self.hostname
519519

520-
def get_supernet(self, servertype):
521-
return Server.objects.get(
522-
servertype=servertype,
523-
intern_ip__net_contains_or_equals=self.intern_ip,
524-
)
525-
526520
def clean(self):
527521
super(Server, self).clean()
528522

0 commit comments

Comments
 (0)