Merge lp:~mpontillo/maas/dhcp-with-aliases--bug-1600267 into lp:maas/trunk

Proposed by Mike Pontillo on 2016-07-11
Status: Merged
Approved by: Mike Pontillo on 2016-07-11
Approved revision: 5168
Merged at revision: 5166
Proposed branch: lp:~mpontillo/maas/dhcp-with-aliases--bug-1600267
Merge into: lp:maas/trunk
Diff against target: 87 lines (+16/-11)
2 files modified
src/maasserver/static/js/angular/controllers/node_details_networking.js (+8/-7)
src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js (+8/-4)
To merge this branch: bzr merge lp:~mpontillo/maas/dhcp-with-aliases--bug-1600267
Reviewer Review Type Date Requested Status
Blake Rouse (community) 2016-07-11 Approve on 2016-07-11
Review via email: mp+299723@code.launchpad.net

Commit message

Allow adding aliases to interfaces where DHCP is enabled.

Description of the change

Note: I tested this end-to-end on a real MAAS system.

To post a comment you must log in.
Blake Rouse (blake-rouse) wrote :

Looks good.

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-06-14 06:27:57 +0000
3+++ src/maasserver/static/js/angular/controllers/node_details_networking.js 2016-07-11 18:29:26 +0000
4@@ -98,15 +98,17 @@
5 }
6 });
7 } else {
8- // Don't add LINK_UP or DHCP if more than one link exists or
9+ // Don't add LINK_UP if more than one link exists or
10 // if the interface is an alias.
11- var allowLinkUpAndDHCP = (
12+ var allowLinkUp = (
13 (angular.isObject(nic.links) && nic.links.length > 1) ||
14 (nic.type === "alias"));
15 angular.forEach(modes, function(mode) {
16- if(allowLinkUpAndDHCP && (
17- mode.mode === "link_up" ||
18- mode.mode === "dhcp")) {
19+ if(allowLinkUp && mode.mode === "link_up") {
20+ return;
21+ }
22+ // Can't run DHCP twice on one NIC.
23+ if(nic.type === "alias" && mode.mode === "dhcp") {
24 return;
25 }
26 filtered.push(mode);
27@@ -882,8 +884,7 @@
28 } else if(nic.type === INTERFACE_TYPE.ALIAS) {
29 return false;
30 } else if(nic.links.length === 0 ||
31- nic.links[0].mode === LINK_MODE.LINK_UP ||
32- nic.links[0].mode === LINK_MODE.DHCP) {
33+ nic.links[0].mode === LINK_MODE.LINK_UP) {
34 return false;
35 } else {
36 return true;
37
38=== modified file 'src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js'
39--- src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js 2016-06-14 06:27:57 +0000
40+++ src/maasserver/static/js/angular/controllers/tests/test_node_details_networking.js 2016-07-11 18:29:26 +0000
41@@ -266,7 +266,7 @@
42 ]);
43 });
44
45- it("auto and static modes if more than one link", function() {
46+ it("auto, static, and dhcp modes if more than one link", function() {
47 var nic = {
48 subnet : {},
49 links: [{}, {}]
50@@ -279,6 +279,10 @@
51 {
52 "mode": "static",
53 "text": "Static assign"
54+ },
55+ {
56+ "mode": "dhcp",
57+ "text": "DHCP"
58 }
59 ]);
60 });
61@@ -1261,7 +1265,7 @@
62 it("updates newInterface.parent object", function() {
63 var controller = makeController();
64 var newInterface = {
65- type: "vlan"
66+ type: "alias"
67 };
68 setupNewInterface(controller, newInterface);
69 var parent = newInterface.parent;
70@@ -2435,7 +2439,7 @@
71 expect($scope.canAddAlias(nic)).toBe(false);
72 });
73
74- it("returns false if nic has dhcp", function() {
75+ it("returns true if nic has dhcp", function() {
76 var controller = makeController();
77 var nic = {
78 type: "physical",
79@@ -2443,7 +2447,7 @@
80 mode: "dhcp"
81 }]
82 };
83- expect($scope.canAddAlias(nic)).toBe(false);
84+ expect($scope.canAddAlias(nic)).toBe(true);
85 });
86
87 it("returns true if nic has static", function() {