Skip to content

Commit c165eef

Browse files
author
Caleb Ellis
committed
Fix edit bond form not saving all values. (#1247)
1 parent edc3594 commit c165eef

File tree

3 files changed

+121
-38
lines changed

3 files changed

+121
-38
lines changed

legacy/src/app/controllers/node_details_networking.js

+48-14
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ export function filterSelectedInterfaces() {
152152

153153
return (
154154
selectedInterfaces.indexOf(itemKey) === -1 &&
155+
item.fabric &&
156+
item.vlan &&
157+
newBondInterface.fabric &&
158+
newBondInterface.vlan &&
155159
item.fabric.name === newBondInterface.fabric.name &&
156160
item.vlan.id === newBondInterface.vlan.id
157161
);
@@ -1156,12 +1160,13 @@ export function NodeNetworkingController(
11561160
bridge_stp: nic.params.bridge_stp,
11571161
bridge_type: nic.params.bridge_type,
11581162
bond_mode: nic.params.bond_mode,
1159-
xmitHashPolicy: nic.params.bond_xmit_hash_policy,
1160-
lacpRate: nic.params.bond_lacp_rate,
1163+
bond_xmit_hash_policy: nic.params.bond_xmit_hash_policy,
1164+
bond_lacp_rate: nic.params.bond_lacp_rate,
11611165
bond_downdelay: nic.params.bond_downdelay,
11621166
bond_updelay: nic.params.bond_updelay,
11631167
bond_miimon: nic.params.bond_miimon
11641168
};
1169+
$scope.editInterfaceLinkMonitoring = nic.params.bond_miimon ? "mii" : "";
11651170
if (angular.isDefined(nic.subnet) && nic.subnet !== null) {
11661171
$scope.editInterface.defaultSubnet = nic.subnet;
11671172
} else {
@@ -1191,13 +1196,13 @@ export function NodeNetworkingController(
11911196
bridge_stp: nic.params.bridge_stp,
11921197
bridge_type: nic.params.bridge_type,
11931198
bond_mode: nic.params.bond_mode,
1194-
xmitHashPolicy: nic.params.bond_xmit_hash_policy,
1195-
lacpRate: nic.params.bond_lacp_rate,
1199+
bond_xmit_hash_policy: nic.params.bond_xmit_hash_policy,
1200+
bond_lacp_rate: nic.params.bond_lacp_rate,
11961201
bond_downdelay: nic.params.bond_downdelay,
11971202
bond_updelay: nic.params.bond_updelay,
11981203
bond_miimon: nic.params.bond_miimon
11991204
};
1200-
1205+
$scope.editInterfaceLinkMonitoring = nic.params.bond_miimon ? "mii" : "";
12011206
$scope.editInterface.parents = nic.parents;
12021207
$scope.editInterface.members = nic.members;
12031208
if (nic.members && nic.members.length) {
@@ -1840,11 +1845,11 @@ export function NodeNetworkingController(
18401845
vlan: vlan,
18411846
subnet: subnet,
18421847
bond_mode: "active-backup",
1843-
lacpRate: "fast",
1844-
xmitHashPolicy: "layer2",
1848+
bond_lacp_rate: "fast",
1849+
bond_xmit_hash_policy: "layer2",
18451850
bond_updelay: 0,
18461851
bond_downdelay: 0,
1847-
bond_miimon: 100
1852+
bond_miimon: 0,
18481853
};
18491854
}
18501855
};
@@ -1899,14 +1904,14 @@ export function NodeNetworkingController(
18991904
if ($scope.editInterface) {
19001905
return (
19011906
$scope.editInterface.bond_mode === "802.3ad" &&
1902-
($scope.editInterface.xmitHashPolicy === "layer3+4" ||
1903-
$scope.editInterface.xmitHashPolicy === "encap3+4")
1907+
($scope.editInterface.bond_xmit_hash_policy === "layer3+4" ||
1908+
$scope.editInterface.bond_xmit_hash_policy === "encap3+4")
19041909
);
19051910
} else {
19061911
return (
19071912
$scope.newBondInterface.bond_mode === "802.3ad" &&
1908-
($scope.newBondInterface.xmitHashPolicy === "layer3+4" ||
1909-
$scope.newBondInterface.xmitHashPolicy === "encap3+4")
1913+
($scope.newBondInterface.bond_xmit_hash_policy === "layer3+4" ||
1914+
$scope.newBondInterface.bond_xmit_hash_policy === "encap3+4")
19101915
);
19111916
}
19121917
};
@@ -1986,8 +1991,8 @@ export function NodeNetworkingController(
19861991
}),
19871992
parents: parents,
19881993
bond_mode: $scope.newBondInterface.bond_mode,
1989-
bond_lacp_rate: $scope.newBondInterface.lacpRate,
1990-
bond_xmit_hash_policy: $scope.newBondInterface.xmitHashPolicy,
1994+
bond_lacp_rate: $scope.newBondInterface.bond_lacp_rate,
1995+
bond_xmit_hash_policy: $scope.newBondInterface.bond_xmit_hash_policy,
19911996
vlan: vlan_id,
19921997
subnet: subnet_id,
19931998
mode: $scope.newBondInterface.mode,
@@ -2349,6 +2354,35 @@ export function NodeNetworkingController(
23492354
$scope.showEditWarning = true;
23502355
};
23512356

2357+
// Set defaults or clear form fields depending on selected link monitoring.
2358+
$scope.handleEditLinkMonitoring = (linkMonitoring) => {
2359+
$scope.editInterfaceLinkMonitoring = linkMonitoring;
2360+
$scope.editInterface.bond_downdelay = 0;
2361+
$scope.editInterface.bond_updelay = 0;
2362+
2363+
if (linkMonitoring === "mii") {
2364+
$scope.editInterface.bond_miimon = 100;
2365+
} else {
2366+
$scope.editInterface.bond_miimon = 0;
2367+
}
2368+
};
2369+
2370+
// Set defaults or clear form fields depending on selected bond mode.
2371+
$scope.handleEditBondMode = (bondMode) => {
2372+
$scope.editInterface.bond_mode = bondMode;
2373+
if ($scope.showLACPRate()) {
2374+
$scope.editInterface.bond_lacp_rate = "fast";
2375+
} else {
2376+
$scope.editInterface.bond_lacp_rate = "";
2377+
}
2378+
2379+
if ($scope.showXMITHashPolicy()) {
2380+
$scope.editInterface.bond_xmit_hash_policy = "layer2";
2381+
} else {
2382+
$scope.editInterface.bond_xmit_hash_policy = "";
2383+
}
2384+
};
2385+
23522386
$scope.getNetworkTestingStatus = nic => {
23532387
const results = $scope.networkTestingResults;
23542388
const resultKey = `${nic.name} (${nic.mac_address})`;

legacy/src/app/controllers/tests/test_node_details_networking.js

+49-8
Original file line numberDiff line numberDiff line change
@@ -3690,11 +3690,11 @@ describe("NodeNetworkingController", function() {
36903690
fabric: "",
36913691
vlan: {},
36923692
subnet: "",
3693-
lacpRate: "fast",
3694-
xmitHashPolicy: "layer2",
3693+
bond_lacp_rate: "fast",
3694+
bond_xmit_hash_policy: "layer2",
36953695
bond_updelay: 0,
36963696
bond_downdelay: 0,
3697-
bond_miimon: 100
3697+
bond_miimon: 0
36983698
});
36993699
});
37003700
});
@@ -3843,14 +3843,14 @@ describe("NodeNetworkingController", function() {
38433843
it("returns true if policy is layer3+4", function() {
38443844
makeController();
38453845
$scope.newBondInterface.bond_mode = "802.3ad";
3846-
$scope.newBondInterface.xmitHashPolicy = "layer3+4";
3846+
$scope.newBondInterface.bond_xmit_hash_policy = "layer3+4";
38473847
expect($scope.showLACPRate()).toBe(true);
38483848
});
38493849

38503850
it("returns true if policy is encap3+4", function() {
38513851
makeController();
38523852
$scope.newBondInterface.bond_mode = "802.3ad";
3853-
$scope.newBondInterface.xmitHashPolicy = "encap3+4";
3853+
$scope.newBondInterface.bond_xmit_hash_policy = "encap3+4";
38543854
expect($scope.showLACPRate()).toBe(true);
38553855
});
38563856

@@ -3861,7 +3861,7 @@ describe("NodeNetworkingController", function() {
38613861
link_id: -1
38623862
};
38633863
$scope.newBondInterface.bond_mode = "802.3ad";
3864-
$scope.newBondInterface.xmitHashPolicy = "layer2+3";
3864+
$scope.newBondInterface.bond_xmit_hash_policy = "layer2+3";
38653865
expect($scope.showLACPRate()).toBe(false);
38663866
});
38673867
});
@@ -4007,7 +4007,7 @@ describe("NodeNetworkingController", function() {
40074007
subnet: subnet.id,
40084008
mode: "static",
40094009
ip_address: "192.168.1.100",
4010-
bond_miimon: 100,
4010+
bond_miimon: 0,
40114011
bond_updelay: 0,
40124012
bond_downdelay: 0
40134013
});
@@ -4060,7 +4060,7 @@ describe("NodeNetworkingController", function() {
40604060
subnet: null,
40614061
mode: undefined,
40624062
ip_address: undefined,
4063-
bond_miimon: 100,
4063+
bond_miimon: 0,
40644064
bond_updelay: 0,
40654065
bond_downdelay: 0
40664066
});
@@ -5181,6 +5181,47 @@ describe("NodeNetworkingController", function() {
51815181
});
51825182
});
51835183

5184+
describe("handleEditLinkMonitoring", () => {
5185+
it("clears bond monitoring frequency value if MII not selected", () => {
5186+
makeController();
5187+
$scope.editInterface = {
5188+
bond_miimon: 0,
5189+
bond_downdelay: 0,
5190+
bond_updelay: 0,
5191+
};
5192+
$scope.handleEditLinkMonitoring("mii");
5193+
expect($scope.editInterface.bond_miimon).toBe(100);
5194+
$scope.handleEditLinkMonitoring("");
5195+
expect($scope.editInterface.bond_miimon).toBe(0);
5196+
});
5197+
});
5198+
5199+
describe("handleEditBondMode", () => {
5200+
it("clears LACP rate if bond mode does not support it", () => {
5201+
makeController();
5202+
$scope.editInterface = {
5203+
bond_lacp_rate: "",
5204+
bond_mode: "balance-rr",
5205+
};
5206+
$scope.handleEditBondMode("802.3ad");
5207+
expect($scope.editInterface.bond_lacp_rate).toBe("fast");
5208+
$scope.handleEditBondMode("balance-rr");
5209+
expect($scope.editInterface.bond_lacp_rate).toBe("");
5210+
});
5211+
5212+
it("clears hash policy if bond mode does not support it", () => {
5213+
makeController();
5214+
$scope.editInterface = {
5215+
bond_xmit_hash_policy: "",
5216+
bond_mode: "balance-rr",
5217+
};
5218+
$scope.handleEditBondMode("802.3ad");
5219+
expect($scope.editInterface.bond_xmit_hash_policy).toBe("layer2");
5220+
$scope.handleEditBondMode("balance-rr");
5221+
expect($scope.editInterface.bond_xmit_hash_policy).toBe("");
5222+
});
5223+
});
5224+
51845225
describe("canMarkAsDisconnected", () => {
51855226
it("returns false if nic type is not physical", () => {
51865227
makeController();

legacy/src/app/partials/node-details.html

+24-16
Original file line numberDiff line numberDiff line change
@@ -1807,9 +1807,12 @@ <h3 class="p-heading--five">Bond details</h3>
18071807
<div class="p-form__group row">
18081808
<label for="bond-mode" class="p-form__label col-2">Bond mode</label>
18091809
<div class="p-form__control col-4">
1810-
<select name="bond-mode"
1811-
data-ng-model="editInterface.bond_mode"
1812-
data-ng-options="mode[0] as mode[1] for mode in bondOptions.modes">
1810+
<select
1811+
name="bond-mode"
1812+
ng-change="handleEditBondMode(editInterface.bond_mode)"
1813+
ng-model="editInterface.bond_mode"
1814+
ng-options="mode[0] as mode[1] for mode in bondOptions.modes"
1815+
>
18131816
</select>
18141817
</div>
18151818
</div>
@@ -1819,7 +1822,7 @@ <h3 class="p-heading--five">Bond details</h3>
18191822
<div class="p-form__control col-4">
18201823
<select name="xmit-hash-policy"
18211824
class="p-form-validation__input"
1822-
data-ng-model="editInterface.xmitHashPolicy"
1825+
data-ng-model="editInterface.bond_xmit_hash_policy"
18231826
data-ng-options="xmit[0] as xmit[1] for xmit in bondOptions.xmit_hash_policies">
18241827
</select>
18251828
<p class="p-form-validation__message" data-ng-if="showLACPRate() && modeAndPolicyCompliant()">
@@ -1831,7 +1834,7 @@ <h3 class="p-heading--five">Bond details</h3>
18311834
<label for="lacp-rate" class="p-form__label col-2">LACP rate</label>
18321835
<div class="p-form__control col-4">
18331836
<select name="lacp-rate"
1834-
data-ng-model="editInterface.lacpRate"
1837+
data-ng-model="editInterface.bond_lacp_rate"
18351838
data-ng-options="rate[0] as rate[1] for rate in bondOptions.lacp_rates">
18361839
</select>
18371840
</div>
@@ -1933,7 +1936,12 @@ <h3 class="p-heading--five">Advanced options</h3>
19331936
<div class="p-form__group row">
19341937
<label for="link-monitoring" class="p-form__label col-2">Link monitoring</label>
19351938
<div class="p-form__control col-4">
1936-
<select name="link-monitoring" id="link-monitoring" data-ng-model="editInterfaceLinkMonitoring">
1939+
<select
1940+
id="link-monitoring"
1941+
name="link-monitoring"
1942+
ng-change="handleEditLinkMonitoring(editInterfaceLinkMonitoring)"
1943+
ng-model="editInterfaceLinkMonitoring"
1944+
>
19371945
<option value="">No link monitoring</option>
19381946
<option value="mii">MII link monitoring</option>
19391947
</select>
@@ -2089,27 +2097,27 @@ <h2 class="p-heading--four">Create bond</h2>
20892097
</td>
20902098
<td class="p-table__col--status p-double-row" aria-label="Link and interface speed">
20912099
<div class="p-double-row__icon-container">
2092-
<span ng-if="!isBond(interface) && !isBridge(interface)">
2093-
<span class="p-tooltip--top-left" data-ng-if="!interface.link_connected"
2100+
<span ng-if="!isBond(parent) && !isBridge(parent)">
2101+
<span class="p-tooltip--top-left" data-ng-if="!parent.link_connected"
20942102
aria-describedby="not-connected-tooltip">
20952103
<i class="p-icon--error"></i>
20962104
<span class="p-tooltip__message" role="tooltip" id="not-connected-tooltip">This interface is
20972105
disconnected.</span>
20982106
</span>
20992107
<span class="p-tooltip--top-left"
2100-
data-ng-if="interface.link_connected && interface.link_speed < interface.interface_speed"
2108+
data-ng-if="parent.link_connected && parent.link_speed < parent.interface_speed"
21012109
aria-describedby="link-speed-tooltip">
21022110
<i class="p-icon--warning"></i>
21032111
<span class="p-tooltip__message" role="tooltip" id="link-speed-tooltip">Link connected to slow
21042112
interface.</span>
21052113
</span>
2106-
<i data-ng-if="interface.link_connected && interface.link_speed === interface.interface_speed"
2114+
<i data-ng-if="parent.link_connected && parent.link_speed === parent.interface_speed"
21072115
class="p-icon--placeholder"></i>
21082116
</span>
21092117
</div>
21102118
<div class="p-double-row__rows-container--icon">
2111-
<span ng-if="!isBond(interface) && !isBridge(interface)">
2112-
{$ formatSpeedUnits(interface.link_speed) $}/{$ formatSpeedUnits(interface.interface_speed) $}
2119+
<span ng-if="!isBond(parent) && !isBridge(parent)">
2120+
{$ formatSpeedUnits(parent.link_speed) $}/{$ formatSpeedUnits(parent.interface_speed) $}
21132121
</span>
21142122
</div>
21152123
</td>
@@ -2300,7 +2308,7 @@ <h3 class="p-heading--five">Bond details</h3>
23002308
<div class="p-form__control col-4">
23012309
<select name="xmit-hash-policy"
23022310
class="p-form-validation__input"
2303-
data-ng-model="newBondInterface.xmitHashPolicy"
2311+
data-ng-model="newBondInterface.bond_xmit_hash_policy"
23042312
data-ng-options="xmit[0] as xmit[1] for xmit in bondOptions.xmit_hash_policies">
23052313
</select>
23062314
<p class="p-form-validation__message" data-ng-if="showLACPRate() && modeAndPolicyCompliant()">
@@ -2312,7 +2320,7 @@ <h3 class="p-heading--five">Bond details</h3>
23122320
<label for="lacp-rate" class="p-form__label col-2">LACP rate</label>
23132321
<div class="p-form__control col-4">
23142322
<select name="lacp-rate"
2315-
data-ng-model="newBondInterface.lacpRate"
2323+
data-ng-model="newBondInterface.bond_lacp_rate"
23162324
data-ng-options="rate[0] as rate[1] for rate in bondOptions.lacp_rates">
23172325
</select>
23182326
</div>
@@ -3147,7 +3155,7 @@ <h2 class="u-float--left">Create bond</h2>
31473155
<label for="lacp-rate" class="p-form__label">LACP rate</label>
31483156
<div class="p-form__control">
31493157
<select name="lacp-rate"
3150-
data-ng-model="newBondInterface.lacpRate"
3158+
data-ng-model="newBondInterface.bond_lacp_rate"
31513159
data-ng-options="rate[0] as rate[1] for rate in bondOptions.lacp_rates">
31523160
</select>
31533161
</div>
@@ -3156,7 +3164,7 @@ <h2 class="u-float--left">Create bond</h2>
31563164
<label for="xmit-hash-policy" class="p-form__label">XMIT hash policy</label>
31573165
<div class="p-form__control">
31583166
<select name="xmit-hash-policy"
3159-
data-ng-model="newBondInterface.xmitHashPolicy"
3167+
data-ng-model="newBondInterface.bond_xmit_hash_policy"
31603168
data-ng-options="xmit[0] as xmit[1] for xmit in bondOptions.xmit_hash_policies">
31613169
</select>
31623170
</div>

0 commit comments

Comments
 (0)