Merge lp:~trapnine/maas/fix-1576267 into lp:~maas-committers/maas/trunk
- fix-1576267
- Merge into trunk
Proposed by
Jeffrey C Jones
Status: | Merged |
---|---|
Approved by: | Jeffrey C Jones |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4988 |
Proposed branch: | lp:~trapnine/maas/fix-1576267 |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
485 lines (+188/-94) 7 files modified
src/maasserver/static/js/angular/controllers/node_details_networking.js (+11/-5) src/maasserver/static/js/angular/controllers/tests/test_fabric_details.js (+0/-1) src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js (+177/-41) src/maasserver/static/js/angular/factories/tests/test_vlans.js (+0/-25) src/maasserver/static/js/angular/factories/vlans.js (+0/-14) src/maasserver/websockets/handlers/tests/test_vlan.py (+0/-4) src/maasserver/websockets/handlers/vlan.py (+0/-4) |
To merge this branch: | bzr merge lp:~trapnine/maas/fix-1576267 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeffrey C Jones (community) | Approve | ||
Blake Rouse (community) | Approve | ||
Review via email: mp+293706@code.launchpad.net |
Commit message
Adding new subnets now auto-updates controller details 'Served VLANs' Table.
Description of the change
Adding new subnets now auto-updates controller details 'Served VLANs' Table.
To post a comment you must log in.
Revision history for this message
Jeffrey C Jones (trapnine) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/maasserver/static/js/angular/controllers/node_details_networking.js' | |||
2 | --- src/maasserver/static/js/angular/controllers/node_details_networking.js 2016-03-28 13:54:47 +0000 | |||
3 | +++ src/maasserver/static/js/angular/controllers/node_details_networking.js 2016-05-04 16:20:37 +0000 | |||
4 | @@ -279,7 +279,8 @@ | |||
5 | 279 | var vlanRecord = { | 279 | var vlanRecord = { |
6 | 280 | "fabric": nic.fabric, | 280 | "fabric": nic.fabric, |
7 | 281 | "vlan": nic.vlan, | 281 | "vlan": nic.vlan, |
9 | 282 | "subnets": VLANsManager.getSubnets(nic.vlan), | 282 | "subnets": $filter('filter')( |
10 | 283 | $scope.subnets, {vlan:nic.vlan.id}, true), | ||
11 | 283 | "primary_rack": null, | 284 | "primary_rack": null, |
12 | 284 | "secondary_rack": null, | 285 | "secondary_rack": null, |
13 | 285 | "sort_key": nic.fabric.name + "|" + | 286 | "sort_key": nic.fabric.name + "|" + |
14 | @@ -502,7 +503,10 @@ | |||
15 | 502 | // Called by $parent when the node has been loaded. | 503 | // Called by $parent when the node has been loaded. |
16 | 503 | $scope.nodeLoaded = function() { | 504 | $scope.nodeLoaded = function() { |
17 | 504 | $scope.$watch("node.interfaces", updateInterfaces); | 505 | $scope.$watch("node.interfaces", updateInterfaces); |
19 | 505 | $scope.$watchCollection($scope.subnets, updateInterfaces); | 506 | // Watch subnets for the served VLANs section. |
20 | 507 | if ($scope.$parent.isController) { | ||
21 | 508 | $scope.$watch("subnets", updateInterfaces, true); | ||
22 | 509 | } | ||
23 | 506 | $scope.nodeHasLoaded = true; | 510 | $scope.nodeHasLoaded = true; |
24 | 507 | updateLoaded(); | 511 | updateLoaded(); |
25 | 508 | }; | 512 | }; |
26 | @@ -955,7 +959,8 @@ | |||
27 | 955 | // Alias used defaults based from its parent. | 959 | // Alias used defaults based from its parent. |
28 | 956 | if(type === INTERFACE_TYPE.ALIAS) { | 960 | if(type === INTERFACE_TYPE.ALIAS) { |
29 | 957 | defaultVLAN = nic.vlan; | 961 | defaultVLAN = nic.vlan; |
31 | 958 | defaultSubnet = VLANsManager.getSubnets(defaultVLAN)[0]; | 962 | defaultSubnet = $filter('filter')( |
32 | 963 | $scope.subnets, {vlan:defaultVLAN.id}, true)[0]; | ||
33 | 959 | defaultMode = LINK_MODE.AUTO; | 964 | defaultMode = LINK_MODE.AUTO; |
34 | 960 | } | 965 | } |
35 | 961 | 966 | ||
36 | @@ -996,8 +1001,9 @@ | |||
37 | 996 | $scope.addTypeChanged = function() { | 1001 | $scope.addTypeChanged = function() { |
38 | 997 | if($scope.newInterface.type === INTERFACE_TYPE.ALIAS) { | 1002 | if($scope.newInterface.type === INTERFACE_TYPE.ALIAS) { |
39 | 998 | $scope.newInterface.vlan = $scope.newInterface.parent.vlan; | 1003 | $scope.newInterface.vlan = $scope.newInterface.parent.vlan; |
42 | 999 | $scope.newInterface.subnet = VLANsManager.getSubnets( | 1004 | $scope.newInterface.subnet = $filter('filter')( |
43 | 1000 | $scope.newInterface.vlan)[0]; | 1005 | $scope.subnets, |
44 | 1006 | {vlan:$scope.newInterface.vlan.id}, true)[0]; | ||
45 | 1001 | $scope.newInterface.mode = LINK_MODE.AUTO; | 1007 | $scope.newInterface.mode = LINK_MODE.AUTO; |
46 | 1002 | } else if($scope.newInterface.type === INTERFACE_TYPE.VLAN) { | 1008 | } else if($scope.newInterface.type === INTERFACE_TYPE.VLAN) { |
47 | 1003 | var vlans = getUnusedVLANs($scope.newInterface.parent); | 1009 | var vlans = getUnusedVLANs($scope.newInterface.parent); |
48 | 1004 | 1010 | ||
49 | === modified file 'src/maasserver/static/js/angular/controllers/tests/test_fabric_details.js' | |||
50 | --- src/maasserver/static/js/angular/controllers/tests/test_fabric_details.js 2016-04-27 03:53:55 +0000 | |||
51 | +++ src/maasserver/static/js/angular/controllers/tests/test_fabric_details.js 2016-05-04 16:20:37 +0000 | |||
52 | @@ -182,7 +182,6 @@ | |||
53 | 182 | ]; | 182 | ]; |
54 | 183 | fabric.vlan_ids = [1]; | 183 | fabric.vlan_ids = [1]; |
55 | 184 | spaces[0].subnet_ids = [0]; | 184 | spaces[0].subnet_ids = [0]; |
56 | 185 | vlans[0].subnet_ids = [0]; | ||
57 | 186 | SpacesManager._items.push(spaces[0]); | 185 | SpacesManager._items.push(spaces[0]); |
58 | 187 | VLANsManager._items.push(vlans[0]); | 186 | VLANsManager._items.push(vlans[0]); |
59 | 188 | SubnetsManager._items.push(subnets[0]); | 187 | SubnetsManager._items.push(subnets[0]); |
60 | 189 | 188 | ||
61 | === modified file 'src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js' | |||
62 | --- src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js 2016-03-28 13:54:47 +0000 | |||
63 | +++ src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js 2016-05-04 16:20:37 +0000 | |||
64 | @@ -420,7 +420,29 @@ | |||
65 | 420 | } | 420 | } |
66 | 421 | 421 | ||
67 | 422 | expect(watches).toEqual(["node.interfaces"]); | 422 | expect(watches).toEqual(["node.interfaces"]); |
69 | 423 | expect(watchCollections).toEqual([ $scope.subnets ]); | 423 | expect(watchCollections).toEqual([]); |
70 | 424 | }); | ||
71 | 425 | |||
72 | 426 | it("watches interfaces and subnets once nodeLoaded called", function() { | ||
73 | 427 | var controller = makeController(); | ||
74 | 428 | spyOn($scope, "$watch"); | ||
75 | 429 | spyOn($scope, "$watchCollection"); | ||
76 | 430 | $parentScope.isController = true; | ||
77 | 431 | $scope.nodeLoaded(); | ||
78 | 432 | |||
79 | 433 | var watches = []; | ||
80 | 434 | var i, calls = $scope.$watch.calls.allArgs(); | ||
81 | 435 | for(i = 0; i < calls.length; i++) { | ||
82 | 436 | watches.push(calls[i][0]); | ||
83 | 437 | } | ||
84 | 438 | var watchCollections = []; | ||
85 | 439 | calls = $scope.$watchCollection.calls.allArgs(); | ||
86 | 440 | for(i = 0; i < calls.length; i++) { | ||
87 | 441 | watchCollections.push(calls[i][0]); | ||
88 | 442 | } | ||
89 | 443 | |||
90 | 444 | expect(watches).toEqual(["node.interfaces", "subnets"]); | ||
91 | 445 | expect(watchCollections).toEqual([]); | ||
92 | 424 | }); | 446 | }); |
93 | 425 | 447 | ||
94 | 426 | describe("updateInterfaces", function() { | 448 | describe("updateInterfaces", function() { |
95 | @@ -799,7 +821,6 @@ | |||
96 | 799 | vlan_id: 0 | 821 | vlan_id: 0 |
97 | 800 | }; | 822 | }; |
98 | 801 | SubnetsManager._items = []; | 823 | SubnetsManager._items = []; |
99 | 802 | spyOn(VLANsManager, "getSubnets").and.returnValue([]); | ||
100 | 803 | FabricsManager._items = [fabric0]; | 824 | FabricsManager._items = [fabric0]; |
101 | 804 | VLANsManager._items = [vlan0]; | 825 | VLANsManager._items = [vlan0]; |
102 | 805 | node.interfaces = [nic0]; | 826 | node.interfaces = [nic0]; |
103 | @@ -819,14 +840,13 @@ | |||
104 | 819 | }); | 840 | }); |
105 | 820 | 841 | ||
106 | 821 | it("renders single entry vlanTable", function() { | 842 | it("renders single entry vlanTable", function() { |
108 | 822 | var subnet0 = { id: 0 }; | 843 | var subnet0 = { id: 0, vlan: 0 }; |
109 | 823 | var fabric0 = { | 844 | var fabric0 = { |
110 | 824 | id: 0 | 845 | id: 0 |
111 | 825 | }; | 846 | }; |
112 | 826 | var vlan0 = { | 847 | var vlan0 = { |
113 | 827 | id: 0, | 848 | id: 0, |
116 | 828 | fabric: 0, | 849 | fabric: 0 |
115 | 829 | subnet_ids: [0] | ||
117 | 830 | }; | 850 | }; |
118 | 831 | var nic0 = { | 851 | var nic0 = { |
119 | 832 | id: 0, | 852 | id: 0, |
120 | @@ -857,27 +877,27 @@ | |||
121 | 857 | ]); | 877 | ]); |
122 | 858 | }); | 878 | }); |
123 | 859 | 879 | ||
129 | 860 | it("renders multi-entry vlanTable", function() { | 880 | var makeInterestingNetwork = function() { |
130 | 861 | var subnet0 = { id: 0 }; | 881 | var net = {}; |
131 | 862 | var subnet1 = { id: 1 }; | 882 | net.space0 = { id: 0 }; |
132 | 863 | var subnet2 = { id: 2 }; | 883 | net.subnet0 = { id: 0, vlan:0, cidr: "10.0.0.0/16" }; |
133 | 864 | var fabric0 = { | 884 | net.subnet1 = { id: 1, vlan:0, cidr: "10.10.0.0/16" }; |
134 | 885 | net.subnet2 = { id: 2, vlan:1, cidr: "10.20.0.0/16" }; | ||
135 | 886 | net.fabric0 = { | ||
136 | 865 | id: 0 | 887 | id: 0 |
137 | 866 | }; | 888 | }; |
139 | 867 | var fabric1 = { | 889 | net.fabric1 = { |
140 | 868 | id: 1 | 890 | id: 1 |
141 | 869 | }; | 891 | }; |
143 | 870 | var vlan0 = { | 892 | net.vlan0 = { |
144 | 871 | id: 0, | 893 | id: 0, |
147 | 872 | fabric: 0, | 894 | fabric: 0 |
146 | 873 | subnet_ids: [0, 1] | ||
148 | 874 | }; | 895 | }; |
150 | 875 | var vlan1 = { | 896 | net.vlan1 = { |
151 | 876 | id: 1, | 897 | id: 1, |
154 | 877 | fabric: 1, | 898 | fabric: 1 |
153 | 878 | subnet_ids: [2] | ||
155 | 879 | }; | 899 | }; |
157 | 880 | var nic0 = { | 900 | net.nic0 = { |
158 | 881 | id: 0, | 901 | id: 0, |
159 | 882 | name: "eth0", | 902 | name: "eth0", |
160 | 883 | type: "physical", | 903 | type: "physical", |
161 | @@ -886,7 +906,7 @@ | |||
162 | 886 | links: [], | 906 | links: [], |
163 | 887 | vlan_id: 0 | 907 | vlan_id: 0 |
164 | 888 | }; | 908 | }; |
166 | 889 | var nic1 = { | 909 | net.nic1 = { |
167 | 890 | id: 1, | 910 | id: 1, |
168 | 891 | name: "eth1", | 911 | name: "eth1", |
169 | 892 | type: "physical", | 912 | type: "physical", |
170 | @@ -895,30 +915,37 @@ | |||
171 | 895 | links: [], | 915 | links: [], |
172 | 896 | vlan_id: 1 | 916 | vlan_id: 1 |
173 | 897 | }; | 917 | }; |
178 | 898 | SubnetsManager._items = [subnet0, subnet1, subnet2]; | 918 | //SpacesManager._items = [net.space0]; |
179 | 899 | FabricsManager._items = [fabric0, fabric1]; | 919 | SubnetsManager._items = [net.subnet0, net.subnet1, net.subnet2]; |
180 | 900 | VLANsManager._items = [vlan0, vlan1]; | 920 | FabricsManager._items = [net.fabric0, net.fabric1]; |
181 | 901 | node.interfaces = [nic0, nic1]; | 921 | VLANsManager._items = [net.vlan0, net.vlan1]; |
182 | 922 | node.interfaces = [net.nic0, net.nic1]; | ||
183 | 923 | return net; | ||
184 | 924 | }; | ||
185 | 902 | 925 | ||
186 | 926 | it("renders multi-entry vlanTable", function() { | ||
187 | 927 | var net = makeInterestingNetwork(); | ||
188 | 903 | // Should not blank for a controller. | 928 | // Should not blank for a controller. |
189 | 904 | $parentScope.isController = true; | 929 | $parentScope.isController = true; |
190 | 905 | updateInterfaces(); | 930 | updateInterfaces(); |
191 | 906 | expect($scope.vlanTable).toEqual([ | 931 | expect($scope.vlanTable).toEqual([ |
192 | 907 | { | 932 | { |
196 | 908 | fabric: fabric0, | 933 | fabric: net.fabric0, |
197 | 909 | vlan: vlan0, | 934 | vlan: net.vlan0, |
198 | 910 | subnets: [subnet0, subnet1], | 935 | subnets: [net.subnet0, net.subnet1], |
199 | 911 | primary_rack: null, | 936 | primary_rack: null, |
200 | 912 | secondary_rack: null, | 937 | secondary_rack: null, |
202 | 913 | sort_key: fabric0.name + "|" + $scope.getVLANText(vlan0) | 938 | sort_key: net.fabric0.name + "|" + |
203 | 939 | $scope.getVLANText(net.vlan0) | ||
204 | 914 | }, | 940 | }, |
205 | 915 | { | 941 | { |
209 | 916 | fabric: fabric1, | 942 | fabric: net.fabric1, |
210 | 917 | vlan: vlan1, | 943 | vlan: net.vlan1, |
211 | 918 | subnets: [subnet2], | 944 | subnets: [net.subnet2], |
212 | 919 | primary_rack: null, | 945 | primary_rack: null, |
213 | 920 | secondary_rack: null, | 946 | secondary_rack: null, |
215 | 921 | sort_key: fabric0.name + "|" + $scope.getVLANText(vlan1) | 947 | sort_key: net.fabric0.name + "|" + |
216 | 948 | $scope.getVLANText(net.vlan1) | ||
217 | 922 | } | 949 | } |
218 | 923 | ]); | 950 | ]); |
219 | 924 | }); | 951 | }); |
220 | @@ -926,14 +953,13 @@ | |||
221 | 926 | it("no duplicate vlans", function() { | 953 | it("no duplicate vlans", function() { |
222 | 927 | // Regression for https://bugs.launchpad.net/maas/+bug/1559332. | 954 | // Regression for https://bugs.launchpad.net/maas/+bug/1559332. |
223 | 928 | // Same vlan on two nics shouldn't result in two vlans in table. | 955 | // Same vlan on two nics shouldn't result in two vlans in table. |
225 | 929 | var subnet0 = { id: 0 }; | 956 | var subnet0 = { id: 0, vlan:0 }; |
226 | 930 | var fabric0 = { | 957 | var fabric0 = { |
227 | 931 | id: 0 | 958 | id: 0 |
228 | 932 | }; | 959 | }; |
229 | 933 | var vlan0 = { | 960 | var vlan0 = { |
230 | 934 | id: 0, | 961 | id: 0, |
233 | 935 | fabric: 0, | 962 | fabric: 0 |
232 | 936 | subnet_ids: [0, 1] | ||
234 | 937 | }; | 963 | }; |
235 | 938 | var nic0 = { | 964 | var nic0 = { |
236 | 939 | id: 0, | 965 | id: 0, |
237 | @@ -973,6 +999,117 @@ | |||
238 | 973 | ]); | 999 | ]); |
239 | 974 | }); | 1000 | }); |
240 | 975 | 1001 | ||
241 | 1002 | // Regression for https://bugs.launchpad.net/maas/+bug/1576267. | ||
242 | 1003 | it("updates vlanTable when add subnet", function() { | ||
243 | 1004 | var net = makeInterestingNetwork(); | ||
244 | 1005 | |||
245 | 1006 | // Should not blank for a controller. | ||
246 | 1007 | $parentScope.isController = true; | ||
247 | 1008 | updateInterfaces(); | ||
248 | 1009 | expect($scope.vlanTable).toEqual([ | ||
249 | 1010 | { | ||
250 | 1011 | fabric: net.fabric0, | ||
251 | 1012 | vlan: net.vlan0, | ||
252 | 1013 | subnets: [net.subnet0, net.subnet1], | ||
253 | 1014 | primary_rack: null, | ||
254 | 1015 | secondary_rack: null, | ||
255 | 1016 | sort_key: net.fabric0.name + "|" + | ||
256 | 1017 | $scope.getVLANText(net.vlan0) | ||
257 | 1018 | }, | ||
258 | 1019 | { | ||
259 | 1020 | fabric: net.fabric1, | ||
260 | 1021 | vlan: net.vlan1, | ||
261 | 1022 | subnets: [net.subnet2], | ||
262 | 1023 | primary_rack: null, | ||
263 | 1024 | secondary_rack: null, | ||
264 | 1025 | sort_key: net.fabric0.name + "|" + | ||
265 | 1026 | $scope.getVLANText(net.vlan1) | ||
266 | 1027 | } | ||
267 | 1028 | ]); | ||
268 | 1029 | |||
269 | 1030 | // Add subnet and make sure it shows up in vlanTable. | ||
270 | 1031 | var subnet = { | ||
271 | 1032 | id: 3, name:"subnet3", vlan: 0, space: 0, cidr: "10.30.0.0/16" | ||
272 | 1033 | }; | ||
273 | 1034 | SubnetsManager._items.push(subnet); | ||
274 | 1035 | $scope.$digest(); | ||
275 | 1036 | expect($scope.vlanTable).toEqual([ | ||
276 | 1037 | { | ||
277 | 1038 | fabric: net.fabric0, | ||
278 | 1039 | vlan: net.vlan0, | ||
279 | 1040 | subnets: [net.subnet0, net.subnet1, subnet], | ||
280 | 1041 | primary_rack: null, | ||
281 | 1042 | secondary_rack: null, | ||
282 | 1043 | sort_key: net.fabric0.name + "|" + | ||
283 | 1044 | $scope.getVLANText(net.vlan0) | ||
284 | 1045 | }, | ||
285 | 1046 | { | ||
286 | 1047 | fabric: net.fabric1, | ||
287 | 1048 | vlan: net.vlan1, | ||
288 | 1049 | subnets: [net.subnet2], | ||
289 | 1050 | primary_rack: null, | ||
290 | 1051 | secondary_rack: null, | ||
291 | 1052 | sort_key: net.fabric0.name + "|" + | ||
292 | 1053 | $scope.getVLANText(net.vlan1) | ||
293 | 1054 | } | ||
294 | 1055 | ]); | ||
295 | 1056 | }); | ||
296 | 1057 | |||
297 | 1058 | // Regression for https://bugs.launchpad.net/maas/+bug/1576267. | ||
298 | 1059 | it("updates empty vlanTable when add subnet", function() { | ||
299 | 1060 | var fabric0 = { | ||
300 | 1061 | id: 0, | ||
301 | 1062 | name: 'fabric0' | ||
302 | 1063 | }; | ||
303 | 1064 | var vlan0 = { | ||
304 | 1065 | id: 0, | ||
305 | 1066 | fabric: 0, | ||
306 | 1067 | name: 'vlan0' | ||
307 | 1068 | }; | ||
308 | 1069 | var nic0 = { | ||
309 | 1070 | id: 0, | ||
310 | 1071 | name: "eth0", | ||
311 | 1072 | type: "physical", | ||
312 | 1073 | parents: [], | ||
313 | 1074 | children: [], | ||
314 | 1075 | links: [], | ||
315 | 1076 | vlan_id: 0 | ||
316 | 1077 | }; | ||
317 | 1078 | SubnetsManager._items = []; | ||
318 | 1079 | FabricsManager._items = [fabric0]; | ||
319 | 1080 | VLANsManager._items = [vlan0]; | ||
320 | 1081 | node.interfaces = [nic0]; | ||
321 | 1082 | |||
322 | 1083 | $parentScope.isController = true; | ||
323 | 1084 | updateInterfaces(); | ||
324 | 1085 | expect($scope.vlanTable).toEqual([ | ||
325 | 1086 | { | ||
326 | 1087 | fabric: fabric0, | ||
327 | 1088 | vlan: vlan0, | ||
328 | 1089 | subnets: [], | ||
329 | 1090 | primary_rack: null, | ||
330 | 1091 | secondary_rack: null, | ||
331 | 1092 | sort_key: fabric0.name + "|" + $scope.getVLANText(vlan0) | ||
332 | 1093 | } | ||
333 | 1094 | ]); | ||
334 | 1095 | // Add subnet and make sure it shows up in vlanTable. | ||
335 | 1096 | var subnet = { | ||
336 | 1097 | id: 3, name:"subnet3", vlan: 0, space: 0, cidr: "10.30.0.0/16" | ||
337 | 1098 | }; | ||
338 | 1099 | SubnetsManager._items.push(subnet); | ||
339 | 1100 | $scope.$digest(); | ||
340 | 1101 | expect($scope.vlanTable).toEqual([ | ||
341 | 1102 | { | ||
342 | 1103 | fabric: fabric0, | ||
343 | 1104 | vlan: vlan0, | ||
344 | 1105 | subnets: [subnet], | ||
345 | 1106 | primary_rack: null, | ||
346 | 1107 | secondary_rack: null, | ||
347 | 1108 | sort_key: fabric0.name + "|" + $scope.getVLANText(vlan0) | ||
348 | 1109 | } | ||
349 | 1110 | ]); | ||
350 | 1111 | }); | ||
351 | 1112 | |||
352 | 976 | it("creates interfaceLinksMap", function() { | 1113 | it("creates interfaceLinksMap", function() { |
353 | 977 | var links = [ | 1114 | var links = [ |
354 | 978 | { | 1115 | { |
355 | @@ -2679,7 +2816,9 @@ | |||
356 | 2679 | 2816 | ||
357 | 2680 | it("sets up newInterface for alias", function() { | 2817 | it("sets up newInterface for alias", function() { |
358 | 2681 | var controller = makeController(); | 2818 | var controller = makeController(); |
360 | 2682 | var vlan = {}; | 2819 | var vlan = {id:0}; |
361 | 2820 | var subnet = {id:0, vlan:0}; | ||
362 | 2821 | $scope.subnets = [subnet]; | ||
363 | 2683 | var nic = { | 2822 | var nic = { |
364 | 2684 | id: makeInteger(0, 100), | 2823 | id: makeInteger(0, 100), |
365 | 2685 | type: "physical", | 2824 | type: "physical", |
366 | @@ -2687,9 +2826,6 @@ | |||
367 | 2687 | vlan: vlan | 2826 | vlan: vlan |
368 | 2688 | }; | 2827 | }; |
369 | 2689 | 2828 | ||
370 | 2690 | var subnet = {}; | ||
371 | 2691 | spyOn(VLANsManager, "getSubnets").and.returnValue([subnet]); | ||
372 | 2692 | |||
373 | 2693 | $scope.add('alias', nic); | 2829 | $scope.add('alias', nic); |
374 | 2694 | expect($scope.newInterface).toEqual({ | 2830 | expect($scope.newInterface).toEqual({ |
375 | 2695 | type: "alias", | 2831 | type: "alias", |
376 | @@ -2847,15 +2983,15 @@ | |||
377 | 2847 | 2983 | ||
378 | 2848 | it("reset properties based on the new type alias", function() { | 2984 | it("reset properties based on the new type alias", function() { |
379 | 2849 | var controller = makeController(); | 2985 | var controller = makeController(); |
382 | 2850 | var vlan = {}; | 2986 | var vlan = {id:0}; |
383 | 2851 | var subnet = {}; | 2987 | var subnet = {id:0, vlan:0}; |
384 | 2988 | $scope.subnets = [subnet]; | ||
385 | 2852 | var parent = { | 2989 | var parent = { |
386 | 2853 | id: makeInteger(0, 100), | 2990 | id: makeInteger(0, 100), |
387 | 2854 | name: name, | 2991 | name: name, |
388 | 2855 | link_id: makeInteger(0, 100), | 2992 | link_id: makeInteger(0, 100), |
389 | 2856 | vlan: vlan | 2993 | vlan: vlan |
390 | 2857 | }; | 2994 | }; |
391 | 2858 | spyOn(VLANsManager, "getSubnets").and.returnValue([subnet]); | ||
392 | 2859 | $scope.newInterface = { | 2995 | $scope.newInterface = { |
393 | 2860 | type: "alias", | 2996 | type: "alias", |
394 | 2861 | parent: parent | 2997 | parent: parent |
395 | 2862 | 2998 | ||
396 | === modified file 'src/maasserver/static/js/angular/factories/tests/test_vlans.js' | |||
397 | --- src/maasserver/static/js/angular/factories/tests/test_vlans.js 2016-04-22 17:28:15 +0000 | |||
398 | +++ src/maasserver/static/js/angular/factories/tests/test_vlans.js 2016-05-04 16:20:37 +0000 | |||
399 | @@ -31,31 +31,6 @@ | |||
400 | 31 | expect(VLANsManager._handler).toBe("vlan"); | 31 | expect(VLANsManager._handler).toBe("vlan"); |
401 | 32 | }); | 32 | }); |
402 | 33 | 33 | ||
403 | 34 | describe("getSubnets", function() { | ||
404 | 35 | |||
405 | 36 | it("returns subnet objects", function() { | ||
406 | 37 | var i, subnets = [], vlan_subnets = []; | ||
407 | 38 | for(i = 0; i < 6; i++) { | ||
408 | 39 | var subnet = makeSubnet(); | ||
409 | 40 | subnets.push(subnet); | ||
410 | 41 | if(i < 3) { | ||
411 | 42 | vlan_subnets.push(subnet); | ||
412 | 43 | } | ||
413 | 44 | } | ||
414 | 45 | |||
415 | 46 | var subnet_ids = []; | ||
416 | 47 | angular.forEach(vlan_subnets, function(subnet) { | ||
417 | 48 | subnet_ids.push(subnet.id); | ||
418 | 49 | }); | ||
419 | 50 | |||
420 | 51 | SubnetsManager._items = subnets; | ||
421 | 52 | var vlan = { | ||
422 | 53 | "subnet_ids": subnet_ids | ||
423 | 54 | }; | ||
424 | 55 | expect(vlan_subnets).toEqual(VLANsManager.getSubnets(vlan)); | ||
425 | 56 | }); | ||
426 | 57 | }); | ||
427 | 58 | |||
428 | 59 | describe("configureDHCP", function() { | 34 | describe("configureDHCP", function() { |
429 | 60 | 35 | ||
430 | 61 | it("calls the region with expected parameters", function() { | 36 | it("calls the region with expected parameters", function() { |
431 | 62 | 37 | ||
432 | === modified file 'src/maasserver/static/js/angular/factories/vlans.js' | |||
433 | --- src/maasserver/static/js/angular/factories/vlans.js 2016-03-28 13:54:47 +0000 | |||
434 | +++ src/maasserver/static/js/angular/factories/vlans.js 2016-05-04 16:20:37 +0000 | |||
435 | @@ -29,20 +29,6 @@ | |||
436 | 29 | 29 | ||
437 | 30 | VLANsManager.prototype = new Manager(); | 30 | VLANsManager.prototype = new Manager(); |
438 | 31 | 31 | ||
439 | 32 | // Return the Subnet objects that are part of this VLAN. The returned | ||
440 | 33 | // array is calculated on each call, you should not watch this array, | ||
441 | 34 | // instead you should watch this function. | ||
442 | 35 | VLANsManager.prototype.getSubnets = function(vlan) { | ||
443 | 36 | var subnets = []; | ||
444 | 37 | angular.forEach(vlan.subnet_ids, function(subnet_id) { | ||
445 | 38 | var subnet = SubnetsManager.getItemFromList(subnet_id); | ||
446 | 39 | if(angular.isObject(subnet)) { | ||
447 | 40 | subnets.push(subnet); | ||
448 | 41 | } | ||
449 | 42 | }); | ||
450 | 43 | return subnets; | ||
451 | 44 | }; | ||
452 | 45 | |||
453 | 46 | VLANsManager.prototype.getName = function(vlan) { | 32 | VLANsManager.prototype.getName = function(vlan) { |
454 | 47 | var name = vlan.vid; | 33 | var name = vlan.vid; |
455 | 48 | if(vlan.vid === 0) { | 34 | if(vlan.vid === 0) { |
456 | 49 | 35 | ||
457 | === modified file 'src/maasserver/websockets/handlers/tests/test_vlan.py' | |||
458 | --- src/maasserver/websockets/handlers/tests/test_vlan.py 2016-04-28 13:34:34 +0000 | |||
459 | +++ src/maasserver/websockets/handlers/tests/test_vlan.py 2016-05-04 16:20:37 +0000 | |||
460 | @@ -36,10 +36,6 @@ | |||
461 | 36 | "external_dhcp": vlan.external_dhcp, | 36 | "external_dhcp": vlan.external_dhcp, |
462 | 37 | "primary_rack": vlan.primary_rack, | 37 | "primary_rack": vlan.primary_rack, |
463 | 38 | "secondary_rack": vlan.secondary_rack, | 38 | "secondary_rack": vlan.secondary_rack, |
464 | 39 | "subnet_ids": sorted([ | ||
465 | 40 | subnet.id | ||
466 | 41 | for subnet in vlan.subnet_set.all() | ||
467 | 42 | ]), | ||
468 | 43 | } | 39 | } |
469 | 44 | data['rack_sids'] = sorted(list({ | 40 | data['rack_sids'] = sorted(list({ |
470 | 45 | interface.node.system_id | 41 | interface.node.system_id |
471 | 46 | 42 | ||
472 | === modified file 'src/maasserver/websockets/handlers/vlan.py' | |||
473 | --- src/maasserver/websockets/handlers/vlan.py 2016-03-28 13:54:47 +0000 | |||
474 | +++ src/maasserver/websockets/handlers/vlan.py 2016-05-04 16:20:37 +0000 | |||
475 | @@ -58,10 +58,6 @@ | |||
476 | 58 | data["primary_rack_sid"] = obj.primary_rack.system_id | 58 | data["primary_rack_sid"] = obj.primary_rack.system_id |
477 | 59 | if obj.secondary_rack is not None: | 59 | if obj.secondary_rack is not None: |
478 | 60 | data["secondary_rack_sid"] = obj.secondary_rack.system_id | 60 | data["secondary_rack_sid"] = obj.secondary_rack.system_id |
479 | 61 | data["subnet_ids"] = sorted([ | ||
480 | 62 | subnet.id | ||
481 | 63 | for subnet in obj.subnet_set.all() | ||
482 | 64 | ]) | ||
483 | 65 | nodes = { | 61 | nodes = { |
484 | 66 | interface.node | 62 | interface.node |
485 | 67 | for interface in obj.interface_set.all() | 63 | for interface in obj.interface_set.all() |
Looks good. Very well test that is really nice to see. I do have a few comments.