Check if network settings changed
Before setting the Mac Address, Hostname, or DefaultGateway,
check to see if those settings changed.
Change-Id: Ifc735b61734ced13e2554651d74dc44d761f3432
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/services/dataService.js b/app/common/services/dataService.js
index ffe15a2..5c4f53a 100644
--- a/app/common/services/dataService.js
+++ b/app/common/services/dataService.js
@@ -30,6 +30,7 @@
this.hostname = '';
this.mac_address = '';
+ this.defaultgateway = '';
this.remote_window_active = false;
this.displayErrorModal = false;
@@ -75,6 +76,7 @@
this.setNetworkInfo = function(data) {
this.hostname = data.hostname;
+ this.defaultgateway = data.defaultgateway;
this.mac_address = data.mac_address;
};
diff --git a/app/configuration/controllers/network-controller.js b/app/configuration/controllers/network-controller.js
index 31b482c..5708ec8 100644
--- a/app/configuration/controllers/network-controller.js
+++ b/app/configuration/controllers/network-controller.js
@@ -35,17 +35,25 @@
$scope.set_network_success = false;
var promises = [];
- // TODO openbmc/openbmc#3165: check if the network settings
- // changed before setting
- promises.push(setMACAddress());
- promises.push(setDefaultGateway());
- promises.push(setHostname());
+ // MAC Address are case-insensitive
+ if ($scope.interface.MACAddress.toLowerCase() !=
+ dataService.mac_address.toLowerCase()) {
+ promises.push(setMACAddress());
+ }
+ if ($scope.defaultgateway != dataService.defaultgateway) {
+ promises.push(setDefaultGateway());
+ }
+ if ($scope.hostname != dataService.hostname) {
+ promises.push(setHostname());
+ }
- $q.all(promises).finally(function() {
- if (!$scope.set_network_error) {
- $scope.set_network_success = true;
- }
- });
+ if (promises.length) {
+ $q.all(promises).finally(function() {
+ if (!$scope.set_network_error) {
+ $scope.set_network_success = true;
+ }
+ });
+ }
};
@@ -85,6 +93,7 @@
$route.reload();
};
APIUtils.getNetworkInfo().then(function(data) {
+ dataService.setNetworkInfo(data);
$scope.network = data.formatted_data;
$scope.hostname = data.hostname;
$scope.defaultgateway = data.defaultgateway;